Skip to content

Commit

Permalink
Fixed member grade not working in 10.6.76
Browse files Browse the repository at this point in the history
solved #19
  • Loading branch information
nov30th committed Dec 29, 2024
1 parent e86103b commit ba07467
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/im/hoho/alipayInstallB/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
95 changes: 74 additions & 21 deletions app/src/main/java/im/hoho/alipayInstallB/PluginMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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<String, String> 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
Expand Down

0 comments on commit ba07467

Please sign in to comment.