[core] Fix system module path update (#1126)

This commit is contained in:
LoveSy 2021-09-18 11:19:36 +08:00 committed by GitHub
parent 1cce235c46
commit ec0dac1683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 10 deletions

View File

@ -416,7 +416,7 @@ public class ConfigManager {
} }
if (PackageService.isAlive()) { if (PackageService.isAlive()) {
obsoleteModules.forEach(this::removeModuleWithoutCache); obsoleteModules.forEach(this::removeModuleWithoutCache);
obsoletePaths.forEach(this::updateModuleApkPath); obsoletePaths.forEach((packageName, path) -> updateModuleApkPath(packageName, path, true));
} else { } else {
Log.w(TAG, "pm is dead while caching. invalidating..."); Log.w(TAG, "pm is dead while caching. invalidating...");
clearCache(); clearCache();
@ -424,8 +424,8 @@ public class ConfigManager {
} }
} }
Log.d(TAG, "cached modules"); Log.d(TAG, "cached modules");
for (String module : cachedModule.keySet()) { for (var module : cachedModule.entrySet()) {
Log.d(TAG, module); Log.d(TAG, module.getKey() + " " + module.getValue().apkPath);
} }
cacheScopes(); cacheScopes();
} }
@ -577,7 +577,7 @@ public class ConfigManager {
return apkPath.orElse(null); return apkPath.orElse(null);
} }
public boolean updateModuleApkPath(String packageName, String apkPath) { public boolean updateModuleApkPath(String packageName, String apkPath, boolean force) {
if (apkPath == null) return false; if (apkPath == null) return false;
if (db.inTransaction()) { if (db.inTransaction()) {
Log.w(TAG, "update module apk path should not be called inside transaction"); Log.w(TAG, "update module apk path should not be called inside transaction");
@ -591,7 +591,7 @@ public class ConfigManager {
int count = (int) db.insertWithOnConflict("modules", null, values, SQLiteDatabase.CONFLICT_IGNORE); int count = (int) db.insertWithOnConflict("modules", null, values, SQLiteDatabase.CONFLICT_IGNORE);
if (count < 0) { if (count < 0) {
var cached = cachedModule.getOrDefault(packageName, null); var cached = cachedModule.getOrDefault(packageName, null);
if (cached == null || cached.apkPath == null || !cached.apkPath.equals(apkPath)) if (force || cached == null || cached.apkPath == null || !cached.apkPath.equals(apkPath))
count = db.updateWithOnConflict("modules", values, "module_pkg_name=?", new String[]{packageName}, SQLiteDatabase.CONFLICT_IGNORE); count = db.updateWithOnConflict("modules", values, "module_pkg_name=?", new String[]{packageName}, SQLiteDatabase.CONFLICT_IGNORE);
else else
count = 0; count = 0;
@ -731,7 +731,7 @@ public class ConfigManager {
} }
public boolean enableModule(String packageName, ApplicationInfo info) { public boolean enableModule(String packageName, ApplicationInfo info) {
if (!updateModuleApkPath(packageName, getModuleApkPath(info))) return false; if (!updateModuleApkPath(packageName, getModuleApkPath(info), false)) return false;
int mid = getModuleId(packageName); int mid = getModuleId(packageName);
if (mid == -1) return false; if (mid == -1) return false;
try { try {
@ -884,10 +884,6 @@ public class ConfigManager {
ConfigFileManager.deleteFolderIfExists(path); ConfigFileManager.deleteFolderIfExists(path);
} }
public String getManagerPackageName() {
return manager;
}
public boolean isSepolicyLoaded() { public boolean isSepolicyLoaded() {
return sepolicyLoaded; return sepolicyLoaded;
} }