return;
}
Set<String> dexFilesToRemove = new HashSet<>();
+ boolean updated = false;
for (Map.Entry<String, DexUseInfo> entry : useInfo.getDexUseInfoMap().entrySet()) {
String dexPath = entry.getKey();
DexUseInfo dexUseInfo = entry.getValue();
Slog.d(TAG, "Could not find package when compiling secondary dex " + packageName
+ " for user " + dexUseInfo.getOwnerUserId());
// Update the usage and continue, another user might still have the package.
- mPackageDexUsage.removeUserPackage(packageName, dexUseInfo.getOwnerUserId());
+ updated = mPackageDexUsage.removeUserPackage(
+ packageName, dexUseInfo.getOwnerUserId()) || updated;
continue;
}
ApplicationInfo info = pkg.applicationInfo;
flags |= StorageManager.FLAG_STORAGE_CE;
} else {
Slog.e(TAG, "Could not infer CE/DE storage for package " + info.packageName);
- mPackageDexUsage.removeUserPackage(packageName, dexUseInfo.getOwnerUserId());
+ updated = mPackageDexUsage.removeUserPackage(
+ packageName, dexUseInfo.getOwnerUserId()) || updated;
continue;
}
}
}
if (!dexStillExists) {
- mPackageDexUsage.removeDexFile(packageName, dexPath, dexUseInfo.getOwnerUserId());
+ updated = mPackageDexUsage.removeDexFile(
+ packageName, dexPath, dexUseInfo.getOwnerUserId()) || updated;
}
+
+ }
+ if (updated) {
+ mPackageDexUsage.maybeWriteAsync();
}
}
/**
* Remove all the records about package {@code packageName} belonging to user {@code userId}.
+ * @return true if the record was found and actually deleted,
+ * false if the record doesn't exist
*/
public boolean removeUserPackage(String packageName, int userId) {
synchronized (mPackageUseInfoMap) {
/**
* Remove the secondary dex file record belonging to the package {@code packageName}
* and user {@code userId}.
+ * @return true if the record was found and actually deleted,
+ * false if the record doesn't exist
*/
public boolean removeDexFile(String packageName, String dexFile, int userId) {
synchronized (mPackageUseInfoMap) {