Skip to content

Commit

Permalink
Port some fixes for Android 13 to 11
Browse files Browse the repository at this point in the history
Fix #71
  • Loading branch information
yujincheng08 committed Nov 19, 2022
1 parent dc0af17 commit b815113
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/toolkit/coderstory/CorePatchForR.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
Expand Down Expand Up @@ -238,6 +239,19 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
}
});

var utilClass = findClass("com.android.server.pm.PackageManagerServiceUtils", loadPackageParam.classLoader);
if (utilClass != null) {
for (var m : utilClass.getDeclaredMethods()) {
if ("verifySignatures".equals(m.getName())) {
try {
XposedBridge.class.getDeclaredMethod("deoptimizeMethod", Member.class).invoke(null, m);
} catch (Throwable e) {
Log.e("CorePatch", "deoptimizing failed", e);
}
}
}
}
}

Class<?> getSigningDetails(ClassLoader classLoader) {
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/java/toolkit/coderstory/CorePatchForT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.util.Log;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
Expand All @@ -21,7 +20,6 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam)
"android.content.pm.PackageInfoLite",
new ReturnConstant(prefs, "downgrade", null));

var utilClass = findClass("com.android.server.pm.PackageManagerServiceUtils", loadPackageParam.classLoader);
Class<?> signingDetails = getSigningDetails(loadPackageParam.classLoader);
//New package has a different signature
//处理覆盖安装但签名不一致
Expand All @@ -37,17 +35,6 @@ protected void beforeHookedMethod(MethodHookParam param) {
}
});

if (utilClass != null) {
for (var m : utilClass.getDeclaredMethods()) {
if ("verifySignatures".equals(m.getName())) {
try {
XposedBridge.class.getDeclaredMethod("deoptimizeMethod", Member.class).invoke(null, m);
} catch (Throwable e) {
Log.e("CorePatch", "deoptimizing failed", e);
}
}
}
}
// Package " + packageName + " signatures do not match previously installed version; ignoring!"
// public boolean checkCapability(String sha256String, @CertCapabilities int flags) {
// public boolean checkCapability(SigningDetails oldDetails, @CertCapabilities int flags)
Expand Down

0 comments on commit b815113

Please sign in to comment.