Workaround Binder transaction limits

This commit is contained in:
topjohnwu 2019-03-07 02:07:34 -05:00
parent 9a15365a57
commit a49328edd3
2 changed files with 37 additions and 19 deletions

View File

@ -74,7 +74,7 @@ dependencies {
fullImplementation "androidx.recyclerview:recyclerview:${androidXVersion}" fullImplementation "androidx.recyclerview:recyclerview:${androidXVersion}"
fullImplementation "androidx.cardview:cardview:${androidXVersion}" fullImplementation "androidx.cardview:cardview:${androidXVersion}"
fullImplementation "com.google.android.material:material:${androidXVersion}" fullImplementation "com.google.android.material:material:${androidXVersion}"
fullImplementation 'android.arch.work:work-runtime:1.0.0-rc02' fullImplementation 'android.arch.work:work-runtime:1.0.0'
fullImplementation 'androidx.room:room-runtime:2.0.0' fullImplementation 'androidx.room:room-runtime:2.0.0'
fullImplementation 'androidx.transition:transition:1.0.1' fullImplementation 'androidx.transition:transition:1.0.1'

View File

@ -41,7 +41,8 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
private static final List<String> HIDE_BLACKLIST = Arrays.asList( private static final List<String> HIDE_BLACKLIST = Arrays.asList(
App.self.getPackageName(), App.self.getPackageName(),
"android", "android",
"com.android.chrome" "com.android.chrome",
"com.google.android.webview"
); );
private static final String SAFETYNET_PROCESS = "com.google.android.gms.unstable"; private static final String SAFETYNET_PROCESS = "com.google.android.gms.unstable";
private static final String GMS_PACKAGE = "com.google.android.gms"; private static final String GMS_PACKAGE = "com.google.android.gms";
@ -73,12 +74,28 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
set.add(info.processName); set.add(info.processName);
} }
@WorkerThread private PackageInfo getPackageInfo(String pkg) {
private void loadApps() { // Try super hard to get as much info as possible
// Get package info with all components try {
List<PackageInfo> installed = pm.getInstalledPackages( return pm.getPackageInfo(pkg,
PackageManager.GET_ACTIVITIES | PackageManager.GET_SERVICES | PackageManager.GET_ACTIVITIES | PackageManager.GET_SERVICES |
PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS); PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS);
} catch (Exception e1) {
try {
PackageInfo info = pm.getPackageInfo(pkg, PackageManager.GET_ACTIVITIES);
info.services = pm.getPackageInfo(pkg, PackageManager.GET_SERVICES).services;
info.receivers = pm.getPackageInfo(pkg, PackageManager.GET_RECEIVERS).receivers;
info.providers = pm.getPackageInfo(pkg, PackageManager.GET_PROVIDERS).providers;
return info;
} catch (Exception e2) {
return null;
}
}
}
@WorkerThread
private void loadApps() {
List<ApplicationInfo> installed = pm.getInstalledApplications(0);
fullList.clear(); fullList.clear();
hideList.clear(); hideList.clear();
@ -86,19 +103,20 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
for (String line : Shell.su("magiskhide --ls").exec().getOut()) for (String line : Shell.su("magiskhide --ls").exec().getOut())
hideList.add(new HideTarget(line)); hideList.add(new HideTarget(line));
for (PackageInfo pkg : installed) { for (ApplicationInfo info : installed) {
if (!HIDE_BLACKLIST.contains(pkg.packageName) && // Do not show black-listed and disabled apps
/* Do not show disabled apps */ if (!HIDE_BLACKLIST.contains(info.packageName) && info.enabled) {
pkg.applicationInfo.enabled) { Set<String> set = new ArraySet<>();
// Add all possible process names set.add(info.packageName);
Set<String> procSet = new ArraySet<>(); PackageInfo pkg = getPackageInfo(info.packageName);
addProcesses(procSet, pkg.activities); if (pkg != null) {
addProcesses(procSet, pkg.services); addProcesses(set, pkg.activities);
addProcesses(procSet, pkg.receivers); addProcesses(set, pkg.services);
addProcesses(procSet, pkg.providers); addProcesses(set, pkg.receivers);
for (String proc : procSet) { addProcesses(set, pkg.providers);
fullList.add(new HideAppInfo(pkg.applicationInfo, proc));
} }
for (String process : set)
fullList.add(new HideAppInfo(info, process));
} }
} }
@ -222,7 +240,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
Comparator<HideAppInfo> c; Comparator<HideAppInfo> c;
c = Comparators.comparing((HideAppInfo t) -> t.hidden); c = Comparators.comparing((HideAppInfo t) -> t.hidden);
c = Comparators.reversed(c); c = Comparators.reversed(c);
c = Comparators.thenComparing(c, (a, b) -> a.name.compareToIgnoreCase(b.name)); c = Comparators.thenComparing(c, t -> t.name, String::compareToIgnoreCase);
c = Comparators.thenComparing(c, t -> t.info.packageName); c = Comparators.thenComparing(c, t -> t.info.packageName);
c = Comparators.thenComparing(c, t -> t.process); c = Comparators.thenComparing(c, t -> t.process);
return c.compare(this, o); return c.compare(this, o);