[core] Remove duplicated UID check (#1219)

This commit is contained in:
Wang Han 2021-10-04 01:05:58 +08:00 committed by GitHub
parent 226d14a3cd
commit f0c4eeeea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 31 deletions

View File

@ -142,6 +142,7 @@ public class ParasiticManagerHooker {
return null; return null;
} }
}); });
XposedBridge.hookAllMethods(ActivityThread.class, "installProvider", new XC_MethodHook() { XposedBridge.hookAllMethods(ActivityThread.class, "installProvider", new XC_MethodHook() {
private Context originalContext = null; private Context originalContext = null;
@ -184,38 +185,36 @@ public class ParasiticManagerHooker {
} }
}); });
if (Process.myUid() == BuildConfig.MANAGER_INJECTED_UID) { XposedHelpers.findAndHookMethod(WebViewFactory.class, "getProvider", new XC_MethodReplacement() {
XposedHelpers.findAndHookMethod(WebViewFactory.class, "getProvider", new XC_MethodReplacement() { @Override
@Override protected Object replaceHookedMethod(MethodHookParam param) {
protected Object replaceHookedMethod(MethodHookParam param) { var sProviderInstance = XposedHelpers.getStaticObjectField(WebViewFactory.class, "sProviderInstance");
var sProviderInstance = XposedHelpers.getStaticObjectField(WebViewFactory.class, "sProviderInstance"); if (sProviderInstance != null) return sProviderInstance;
if (sProviderInstance != null) return sProviderInstance; //noinspection unchecked
//noinspection unchecked var providerClass = (Class<WebViewFactoryProvider>) XposedHelpers.callStaticMethod(WebViewFactory.class, "getProviderClass");
var providerClass = (Class<WebViewFactoryProvider>) XposedHelpers.callStaticMethod(WebViewFactory.class, "getProviderClass"); Method staticFactory = null;
Method staticFactory = null; try {
try { staticFactory = providerClass.getMethod(
staticFactory = providerClass.getMethod( CHROMIUM_WEBVIEW_FACTORY_METHOD, WebViewDelegate.class);
CHROMIUM_WEBVIEW_FACTORY_METHOD, WebViewDelegate.class); } catch (Exception e) {
} catch (Exception e) { Hookers.logE("error instantiating provider with static factory method", e);
Hookers.logE("error instantiating provider with static factory method", e);
}
try {
var webViewDelegateConstructor = WebViewDelegate.class.getDeclaredConstructor();
webViewDelegateConstructor.setAccessible(true);
if (staticFactory != null) {
sProviderInstance = staticFactory.invoke(null, webViewDelegateConstructor.newInstance());
}
XposedHelpers.setStaticObjectField(WebViewFactory.class, "sProviderInstance", sProviderInstance);
Hookers.logD("Loaded provider: " + sProviderInstance);
return sProviderInstance;
} catch (Exception e) {
Hookers.logE("error instantiating provider", e);
throw new AndroidRuntimeException(e);
}
} }
});
} try {
var webViewDelegateConstructor = WebViewDelegate.class.getDeclaredConstructor();
webViewDelegateConstructor.setAccessible(true);
if (staticFactory != null) {
sProviderInstance = staticFactory.invoke(null, webViewDelegateConstructor.newInstance());
}
XposedHelpers.setStaticObjectField(WebViewFactory.class, "sProviderInstance", sProviderInstance);
Hookers.logD("Loaded provider: " + sProviderInstance);
return sProviderInstance;
} catch (Exception e) {
Hookers.logE("error instantiating provider", e);
throw new AndroidRuntimeException(e);
}
}
});
} }
private static void checkIntent(ILSPManagerService managerService, Intent intent) { private static void checkIntent(ILSPManagerService managerService, Intent intent) {