Skip to content

Commit f8842ae

Browse files
maxweneldainosor
authored andcommitted
base: fix pm cache directory invalidate on new builds
This was before in PackageManagerService.jave like final String cacheName = FORCE_PACKAGE_PARSED_CACHE_ENABLED ? "debug" : SystemProperties.digestOf(ro.build.date.utc); Now they switched to PackagePartitions.FINGERPRINT which broke the invalidate of the cache for new builds also add a missed usage of changed fingerprint in StorageEventHelper.java Change-Id: I6cca07659a8e7a4f99ed58761dc727e0e5e20ef8
1 parent 52c2116 commit f8842ae

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

services/core/java/com/android/server/pm/PackageManagerServiceUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ public static void enforceSystemOrRoot(String message) {
13211321
// identify cached items. In particular, changing the value of certain
13221322
// feature flags should cause us to invalidate any caches.
13231323
final String cacheName = FORCE_PACKAGE_PARSED_CACHE_ENABLED ? "debug"
1324-
: PackagePartitions.FINGERPRINT;
1324+
: SystemProperties.digestOf(String.valueOf(Build.TIME));
13251325

13261326
// Reconcile cache directories, keeping only what we'd actually use.
13271327
for (File cacheDir : FileUtils.listFilesOrEmpty(cacheBaseDir)) {
@@ -1350,16 +1350,15 @@ public static void enforceSystemOrRoot(String message) {
13501350
// NOTE: When no BUILD_NUMBER is set by the build system, it defaults to a build
13511351
// that starts with "eng." to signify that this is an engineering build and not
13521352
// destined for release.
1353-
if (isUpgrade || incrementalVersion.startsWith("eng.")) {
1354-
Slog.w(TAG, "Wiping cache directory because the system partition changed.");
1355-
1353+
if (isUserDebugBuild && incrementalVersion.startsWith("eng.")) {
13561354
// Heuristic: If the /system directory has been modified recently due to an "adb sync"
13571355
// or a regular make, then blow away the cache. Note that mtimes are *NOT* reliable
13581356
// in general and should not be used for production changes. In this specific case,
13591357
// we know that they will work.
13601358
File frameworkDir =
13611359
new File(Environment.getRootDirectory(), "framework");
13621360
if (cacheDir.lastModified() < frameworkDir.lastModified()) {
1361+
Slog.w(TAG, "Wiping cache directory because the system partition changed.");
13631362
FileUtils.deleteContents(cacheBaseDir);
13641363
cacheDir = FileUtils.createDir(cacheBaseDir, cacheName);
13651364
}

services/core/java/com/android/server/pm/StorageEventHelper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import android.content.pm.PackagePartitions;
3434
import android.content.pm.UserInfo;
3535
import android.content.pm.VersionedPackage;
36+
import android.os.Build;
3637
import android.os.Environment;
3738
import android.os.FileUtils;
3839
import android.os.UserHandle;
@@ -166,7 +167,7 @@ private void loadPrivatePackagesInner(VolumeInfo vol) {
166167
Slog.w(TAG, "Failed to scan " + ps.getPath() + ": " + e.getMessage());
167168
}
168169

169-
if (!PackagePartitions.FINGERPRINT.equals(ver.fingerprint)) {
170+
if (!String.valueOf(Build.TIME).equals(ver.fingerprint)) {
170171
appDataHelper.clearAppDataLIF(
171172
ps.getPkg(), UserHandle.USER_ALL, FLAG_STORAGE_DE | FLAG_STORAGE_CE
172173
| FLAG_STORAGE_EXTERNAL | Installer.FLAG_CLEAR_CODE_CACHE_ONLY
@@ -204,10 +205,10 @@ private void loadPrivatePackagesInner(VolumeInfo vol) {
204205
}
205206

206207
synchronized (mPm.mLock) {
207-
final boolean isUpgrade = !PackagePartitions.FINGERPRINT.equals(ver.fingerprint);
208+
final boolean isUpgrade = !String.valueOf(Build.TIME).equals(ver.fingerprint);
208209
if (isUpgrade) {
209210
logCriticalInfo(Log.INFO, "Build fingerprint changed from " + ver.fingerprint
210-
+ " to " + PackagePartitions.FINGERPRINT + "; regranting permissions for "
211+
+ " to " + String.valueOf(Build.TIME) + "; regranting permissions for "
211212
+ volumeUuid);
212213
}
213214
mPm.mPermissionManager.onStorageVolumeMounted(volumeUuid, isUpgrade);

0 commit comments

Comments
 (0)