Merge "Remove orphaned cached result"

This commit is contained in:
Jackal Guo
2020-08-07 01:46:59 +00:00
committed by Android (Google) Code Review

View File

@@ -10351,6 +10351,7 @@ public class PackageManagerService extends IPackageManager.Stub
mInstaller.rmPackageDir(codePath.getAbsolutePath());
if (codePathParent.getName().startsWith(RANDOM_DIR_PREFIX)) {
mInstaller.rmPackageDir(codePathParent.getAbsolutePath());
removeCachedResult(codePathParent);
}
} catch (InstallerException e) {
Slog.w(TAG, "Failed to remove code path", e);
@@ -10360,6 +10361,16 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
private void removeCachedResult(@NonNull File codePath) {
if (mCacheDir == null) {
return;
}
final PackageCacher cacher = new PackageCacher(mCacheDir);
// Find and delete the cached result belong to the given codePath.
cacher.cleanCachedResult(codePath);
}
private int[] resolveUserIds(int userId) {
return (userId == UserHandle.USER_ALL) ? mUserManager.getUserIds() : new int[] { userId };
}