Fix module re-enable (#1631)

This commit is contained in:
LoveSy 2022-02-05 16:42:41 +08:00 committed by GitHub
parent d8908d7ff8
commit bde9990c50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -825,17 +825,17 @@ public class ConfigManager {
} }
public boolean enableModule(String packageName) throws RemoteException { public boolean enableModule(String packageName) throws RemoteException {
if (packageName.equals("lspd")) return false;
PackageInfo pkgInfo = PackageService.getPackageInfoFromAllUsers(packageName, PackageService.MATCH_ALL_FLAGS).values().stream().findFirst().orElse(null); PackageInfo pkgInfo = PackageService.getPackageInfoFromAllUsers(packageName, PackageService.MATCH_ALL_FLAGS).values().stream().findFirst().orElse(null);
if (pkgInfo == null || pkgInfo.applicationInfo == null) { if (pkgInfo == null || pkgInfo.applicationInfo == null) return false;
return false; var modulePath = getModuleApkPath(pkgInfo.applicationInfo);
} if (modulePath == null) return true;
if (packageName.equals("lspd") || !updateModuleApkPath(packageName, getModuleApkPath(pkgInfo.applicationInfo), false)) boolean changed = updateModuleApkPath(packageName, modulePath, false) ||
return false; executeInTransaction(() -> {
boolean changed = executeInTransaction(() -> { ContentValues values = new ContentValues();
ContentValues values = new ContentValues(); values.put("enabled", 1);
values.put("enabled", 1); return db.update("modules", values, "module_pkg_name = ?", new String[]{packageName}) > 0;
return db.update("modules", values, "module_pkg_name = ?", new String[]{packageName}) > 0; });
});
if (changed) { if (changed) {
// Called by manager, should be async // Called by manager, should be async
updateCaches(false); updateCaches(false);