Skip to content
Permalink
Browse files

Use packageName "system" for system dialogues

The actual package name from the activity info is "android". However, the
same name is also used for the system_server. It has been a common pattern
to check for this package name before hooking any system services. Now,
this check would also be true for certain system dialogues and break
existing modules (causing ClassNotFoundExceptions).

For the very few cases where a module needs to hook into this process, it
can simply check for package name "system" instead.
  • Loading branch information...
rovo89 committed Mar 7, 2015
1 parent edf1015 commit 6b49688c929a7768f3113b4c65b429c7a7032afa
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/de/robv/android/xposed/XposedBridge.java
@@ -183,9 +183,10 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
SELinuxHelper.initForProcess();
ActivityThread activityThread = (ActivityThread) param.thisObject;
ApplicationInfo appInfo = (ApplicationInfo) getObjectField(param.args[0], "appInfo");
String reportedPackageName = appInfo.packageName.equals("android") ? "system" : appInfo.packageName;
ComponentName instrumentationName = (ComponentName) getObjectField(param.args[0], "instrumentationName");
if (instrumentationName != null) {
XposedBridge.log("Instrumentation detected, disabling framework for " + appInfo.packageName);
XposedBridge.log("Instrumentation detected, disabling framework for " + reportedPackageName);
disableHooks = true;
return;
}
@@ -194,19 +195,19 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
return;

setObjectField(activityThread, "mBoundApplication", param.args[0]);
loadedPackagesInProcess.add(appInfo.packageName);
loadedPackagesInProcess.add(reportedPackageName);
LoadedApk loadedApk = activityThread.getPackageInfoNoCheck(appInfo, compatInfo);
XResources.setPackageNameForResDir(appInfo.packageName, loadedApk.getResDir());

LoadPackageParam lpparam = new LoadPackageParam(sLoadedPackageCallbacks);
lpparam.packageName = appInfo.packageName;
lpparam.packageName = reportedPackageName;
lpparam.processName = (String) getObjectField(param.args[0], "processName");
lpparam.classLoader = loadedApk.getClassLoader();
lpparam.appInfo = appInfo;
lpparam.isFirstApplication = true;
XC_LoadPackage.callAll(lpparam);

if (appInfo.packageName.equals(INSTALLER_PACKAGE_NAME))
if (reportedPackageName.equals(INSTALLER_PACKAGE_NAME))
hookXposedInstaller(lpparam.classLoader);
}
});

0 comments on commit 6b49688

Please sign in to comment.
You can’t perform that action at this time.