[core] Optmize caching (#1231)
This commit is contained in:
parent
e2651eb4b2
commit
4a1fb57d86
|
|
@ -451,6 +451,7 @@ public class ConfigManager {
|
||||||
final var obsoletePackages = new HashSet<Application>();
|
final var obsoletePackages = new HashSet<Application>();
|
||||||
final var obsoleteModules = new HashSet<Application>();
|
final var obsoleteModules = new HashSet<Application>();
|
||||||
final var moduleAvailability = new HashMap<Pair<String, Integer>, Boolean>();
|
final var moduleAvailability = new HashMap<Pair<String, Integer>, Boolean>();
|
||||||
|
final var cachedProcessScope = new HashMap<Pair<String, Integer>, List<ProcessScope>>();
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
Application app = new Application();
|
Application app = new Application();
|
||||||
app.packageName = cursor.getString(appPkgNameIdx);
|
app.packageName = cursor.getString(appPkgNameIdx);
|
||||||
|
|
@ -478,7 +479,13 @@ public class ConfigManager {
|
||||||
if (app.packageName.equals("android")) continue;
|
if (app.packageName.equals("android")) continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<ProcessScope> processesScope = getAssociatedProcesses(app);
|
List<ProcessScope> processesScope = cachedProcessScope.computeIfAbsent(new Pair<>(app.packageName, app.userId), (k) -> {
|
||||||
|
try {
|
||||||
|
return getAssociatedProcesses(app);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
});
|
||||||
if (processesScope.isEmpty()) {
|
if (processesScope.isEmpty()) {
|
||||||
obsoletePackages.add(app);
|
obsoletePackages.add(app);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue