Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Use packageName "system" for system dialogues
Browse files Browse the repository at this point in the history
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 6b49688
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/de/robv/android/xposed/XposedBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
});
Expand Down

0 comments on commit 6b49688

Please sign in to comment.