[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()) {
obsoleteModules.forEach(this::removeModuleWithoutCache);
obsoletePaths.forEach(this::updateModuleApkPath);
obsoletePaths.forEach((packageName, path) -> updateModuleApkPath(packageName, path, true));
} else {
Log.w(TAG, "pm is dead while caching. invalidating...");
clearCache();
@ -424,8 +424,8 @@ public class ConfigManager {
}
}
Log.d(TAG, "cached modules");
for (String module : cachedModule.keySet()) {
Log.d(TAG, module);
for (var module : cachedModule.entrySet()) {
Log.d(TAG, module.getKey() + " " + module.getValue().apkPath);
}
cacheScopes();
}
@ -577,7 +577,7 @@ public class ConfigManager {
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 (db.inTransaction()) {
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);
if (count < 0) {
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);
else
count = 0;
@ -731,7 +731,7 @@ public class ConfigManager {
}
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);
if (mid == -1) return false;
try {
@ -884,10 +884,6 @@ public class ConfigManager {
ConfigFileManager.deleteFolderIfExists(path);
}
public String getManagerPackageName() {
return manager;
}
public boolean isSepolicyLoaded() {
return sepolicyLoaded;
}