[core] Fix apk path update (#956)

When an app is updated, the old apk will still exist
This commit is contained in:
LoveSy 2021-08-20 15:45:43 +08:00 committed by GitHub
parent 6dfaf67a07
commit 904b8ec6a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -76,6 +76,7 @@ import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@ -453,10 +454,6 @@ public class ConfigManager {
String apkPath = cursor.getString(apkPathIdx); String apkPath = cursor.getString(apkPathIdx);
// if still present after removeIf, this package did not change. // if still present after removeIf, this package did not change.
var oldModule = cachedModule.get(packageName); var oldModule = cachedModule.get(packageName);
if (oldModule != null && oldModule.appId != -1) {
Log.d(TAG, packageName + " did not change, skip caching it");
continue;
}
PackageInfo pkgInfo = null; PackageInfo pkgInfo = null;
try { try {
pkgInfo = PackageService.getPackageInfo(packageName, MATCH_ALL_FLAGS, 0); pkgInfo = PackageService.getPackageInfo(packageName, MATCH_ALL_FLAGS, 0);
@ -467,9 +464,17 @@ public class ConfigManager {
obsoleteModules.add(packageName); obsoleteModules.add(packageName);
continue; continue;
} }
// cache from system server, keep it and set only the appId if (oldModule != null &&
if (oldModule != null) { pkgInfo.applicationInfo.sourceDir != null &&
oldModule.appId = pkgInfo.applicationInfo.uid; apkPath != null && oldModule.apkPath != null &&
Objects.equals(apkPath, oldModule.apkPath) &&
Objects.equals(new File(pkgInfo.applicationInfo.sourceDir).getParent(), new File(apkPath).getParent())) {
if (oldModule.appId != -1) {
Log.d(TAG, packageName + " did not change, skip caching it");
} else {
// cache from system server, keep it and set only the appId
oldModule.appId = pkgInfo.applicationInfo.uid;
}
continue; continue;
} }
var path = apkPath; var path = apkPath;