Skip to content

Commit

Permalink
Clean up loaded module callbacks for blacklisted app
Browse files Browse the repository at this point in the history
Otherwise a few applications would get stuck at launch screen,
for unknown reason.
  • Loading branch information
solohsu committed Mar 10, 2019
1 parent c28c2cb commit 47c500b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.elderdrivers.riru.xposed.util.ProcessUtils;
import com.elderdrivers.riru.xposed.util.Utils;

import de.robv.android.xposed.XposedBridge;

import static com.elderdrivers.riru.xposed.Main.isAppNeedHook;
import static com.elderdrivers.riru.xposed.util.FileUtils.getDataPathPrefix;

Expand Down Expand Up @@ -80,6 +82,7 @@ private static void onForkPreForNonDynamicMode(boolean isSystemServer) {
// because installed hooks would be propagated to all child processes of zygote
Router.startWorkAroundHook();
// loadModules once for all child processes of zygote
// TODO maybe just save initZygote callbacks and call them when whitelisted process forked?
Router.loadModulesSafely(true);
}

Expand Down Expand Up @@ -112,6 +115,15 @@ private static boolean checkNeedHook(String appDataDir, String niceName) {
// FIXME some process cannot read app_data_file because of MLS, e.g. bluetooth
needHook = isAppNeedHook(appDataDir);
}
if (!needHook) {
// clean up the scene
onBlackListed();
}
return needHook;
}

private static void onBlackListed() {
XposedBridge.clearLoadedPackages();
XposedBridge.clearInitPackageResources();
}
}
6 changes: 6 additions & 0 deletions Bridge/src/main/java/de/robv/android/xposed/XposedBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ public static void hookInitPackageResources(XC_InitPackageResources callback) {
// }
}

public static void clearInitPackageResources() {
synchronized (sInitPackageResourcesCallbacks) {
sInitPackageResourcesCallbacks.clear();
}
}

/**
* Intercept every call to the specified method and call a handler function instead.
* @param method The method to intercept
Expand Down

0 comments on commit 47c500b

Please sign in to comment.