From ba0746778e20637ff78ee798e31048d4805f1a8c Mon Sep 17 00:00:00 2001 From: Vincent Date: Sun, 29 Dec 2024 19:00:42 +0800 Subject: [PATCH] Fixed member grade not working in 10.6.76 solved #19 --- app/build.gradle | 4 +- .../im/hoho/alipayInstallB/MainActivity.java | 30 ++++++ .../im/hoho/alipayInstallB/PluginMain.java | 95 +++++++++++++++---- 3 files changed, 106 insertions(+), 23 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index edb4447..834bdf8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "im.hoho.alipayInstallB" minSdkVersion 23 targetSdkVersion 33 - versionCode 107 - versionName "2.5.4" + versionCode 111 + versionName "2.6.0" } namespace 'im.hoho.alipayInstallB' buildToolsVersion '34.0.0' diff --git a/app/src/main/java/im/hoho/alipayInstallB/MainActivity.java b/app/src/main/java/im/hoho/alipayInstallB/MainActivity.java index 22027bc..11754de 100644 --- a/app/src/main/java/im/hoho/alipayInstallB/MainActivity.java +++ b/app/src/main/java/im/hoho/alipayInstallB/MainActivity.java @@ -2,8 +2,11 @@ import android.Manifest; import android.app.Activity; +import android.app.AlertDialog; import android.content.ActivityNotFoundException; +import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; @@ -54,6 +57,9 @@ public class MainActivity extends Activity { private Handler mainHandler; private Spinner spinnerMemberGrade; + private static final String PREFS_NAME = "AppPreferences"; + private static final String KEY_FIRST_RUN = "isFirstRun"; + @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == PERMISSION_REQUEST_CODE) { @@ -70,6 +76,30 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + // 检查是否首次运行 + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + boolean isFirstRun = settings.getBoolean(KEY_FIRST_RUN, true); + + if (isFirstRun) { + new AlertDialog.Builder(this) + .setTitle("隐私说明") + .setMessage("本应用不会收集、不会上传任何用户信息或使用数据。\n\n" + + "应用仅在本地运行,不会与任何服务器通信(除非您主动点击\"下载资源包\"按钮从 Github 下载资源)。\n\n" + + "所有操作均在您的设备本地完成,请放心使用。") + .setPositiveButton("我知道了", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // 标记已经显示过隐私说明 + SharedPreferences.Editor editor = settings.edit(); + editor.putBoolean(KEY_FIRST_RUN, false); + editor.apply(); + } + }) + .setCancelable(false) + .show(); + } + setContentView(R.layout.activity_main); spinnerMemberGrade = findViewById(R.id.spinnerMemberGrade); diff --git a/app/src/main/java/im/hoho/alipayInstallB/PluginMain.java b/app/src/main/java/im/hoho/alipayInstallB/PluginMain.java index 03e0e43..7cdd903 100644 --- a/app/src/main/java/im/hoho/alipayInstallB/PluginMain.java +++ b/app/src/main/java/im/hoho/alipayInstallB/PluginMain.java @@ -43,29 +43,82 @@ public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) thr XposedBridge.log("Powered by HOHO`` 20230927 杭州亚运会版 sd source changed 20231129"); final boolean[] isDbUpdated = {false}; - // 设置插件已加载状态 - isModuleLoaded = true; - - XposedHelpers.findAndHookMethod("com.alipay.mobilegw.biz.shared.processer.login.UserLoginResult", lpparam.classLoader, "getExtResAttrs", new XC_MethodHook() { - protected void afterHookedMethod(MethodHookParam param1MethodHookParam) throws Throwable { - XposedBridge.log("Now, let's install B..."); - Map map = (Map) param1MethodHookParam.getResult(); - if (map.containsKey("memberGrade")) { - XposedBridge.log("Original member grade: " + map.get("memberGrade")); - - String newGrade = getCurrentMemberGrade(); - if (!newGrade.equals("原有")) { - XposedBridge.log("Putting " + newGrade + " into dict..."); - map.put("memberGrade", newGrade); - XposedBridge.log("Member grade changed to: " + map.get("memberGrade")); - } else { - XposedBridge.log("Member grade not modified."); + // 添加对MergeMemberGrade的hook + try { + Class memberGradeEnumClass = XposedHelpers.findClass("com.alipay.mobile.onsitepay9.utils.MergeMemberGradeEnum", lpparam.classLoader); + if (memberGradeEnumClass != null) { + XposedHelpers.findAndHookMethod("com.alipay.mobile.onsitepay9.utils.MergeMemberGradeEnum", + lpparam.classLoader, + "convertMemberGrade", + String.class, + new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + String newGrade = getCurrentMemberGrade(); + XposedBridge.log("Member grade changing to: " + newGrade); + if (!newGrade.equals("原有")) { + switch(newGrade) { + case "primary": + param.setResult(XposedHelpers.getStaticObjectField(memberGradeEnumClass, "PRIMARY")); + break; + case "golden": + param.setResult(XposedHelpers.getStaticObjectField(memberGradeEnumClass, "GOLDEN")); + break; + case "platinum": + param.setResult(XposedHelpers.getStaticObjectField(memberGradeEnumClass, "PLATINUM")); + break; + case "diamond": + param.setResult(XposedHelpers.getStaticObjectField(memberGradeEnumClass, "DIAMOND")); + break; + default: + param.setResult(XposedHelpers.getStaticObjectField(memberGradeEnumClass, "NULL")); + break; + } + XposedBridge.log("Member grade changed to: " + newGrade); + } + } + }); + XposedBridge.log("convertMemberGrade hooked."); + } else { + XposedBridge.log("MergeMemberGradeEnum class not found."); + } + } catch (XposedHelpers.ClassNotFoundError e) { + XposedBridge.log("MergeMemberGradeEnum class not found: " + e.getMessage()); + } catch (NoSuchMethodError e) { + XposedBridge.log("convertMemberGrade method not found: " + e.getMessage()); + } catch (Exception e) { + XposedBridge.log("Error while hooking convertMemberGrade: " + e.getMessage()); + } + + try { + Class UserLoginResultClass = XposedHelpers.findClass("com.alipay.mobilegw.biz.shared.processer.login.UserLoginResult", lpparam.classLoader); + if (UserLoginResultClass != null) { + XposedHelpers.findAndHookMethod("com.alipay.mobilegw.biz.shared.processer.login.UserLoginResult", lpparam.classLoader, "getExtResAttrs", new XC_MethodHook() { + protected void afterHookedMethod(MethodHookParam param1MethodHookParam) throws Throwable { + XposedBridge.log("Now, let's install B..."); + Map map = (Map) param1MethodHookParam.getResult(); + if (map.containsKey("memberGrade")) { + XposedBridge.log("Original member grade: " + map.get("memberGrade")); + + String newGrade = getCurrentMemberGrade(); + if (!newGrade.equals("原有")) { + XposedBridge.log("Putting " + newGrade + " into dict..."); + map.put("memberGrade", newGrade); + XposedBridge.log("Member grade changed to: " + map.get("memberGrade")); + } else { + XposedBridge.log("Member grade not modified."); + } + } else { + XposedBridge.log("Can not get the member grade in return value...WTF?"); + } } - } else { - XposedBridge.log("Can not get the member grade in return value...WTF?"); - } + }); + } else { + XposedBridge.log("UserLoginResult class not found."); } - }); + } catch (Exception e) { + XposedBridge.log("UserLoginResult class not found."); + } XposedHelpers.findAndHookMethod("android.app.Activity", lpparam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() { @Override