diff options
author | Narayan Kamath <narayan@google.com> | 2014-04-29 16:49:27 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-05-01 13:56:22 +0000 |
commit | 57156572a7284c3b774480f9b0138d5cd110a182 (patch) | |
tree | 0b7728d57dbf31a14e7944e80af67f960620cd4d /services/java | |
parent | bcc3b312b0662ae2f8b8444eaedd5f35fc75c411 (diff) | |
download | frameworks_base-57156572a7284c3b774480f9b0138d5cd110a182.zip frameworks_base-57156572a7284c3b774480f9b0138d5cd110a182.tar.gz frameworks_base-57156572a7284c3b774480f9b0138d5cd110a182.tar.bz2 |
Fix dex file pruning logic.
We should now prune all normal files from /data/dalvik-cache
in addition to looking for dex files in all subdirectories of
/data/dalvik-cache.
(cherry picked from commit 51a6f9253399588eedf77d75c578d9aa23d11529)
Change-Id: I536dfdc48e94155e7be64eb4efd9f7f2a1d2d00a
Diffstat (limited to 'services/java')
-rwxr-xr-x | services/java/com/android/server/pm/PackageManagerService.java | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 7183a17..c214c83 100755 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -1289,24 +1289,7 @@ public class PackageManagerService extends IPackageManager.Stub { } if (didDexOpt) { - File dalvikCacheDir = new File(dataDir, "dalvik-cache"); - - // If we had to do a dexopt of one of the previous - // things, then something on the system has changed. - // Consider this significant, and wipe away all other - // existing dexopt files to ensure we don't leave any - // dangling around. - String[] files = dalvikCacheDir.list(); - if (files != null) { - for (int i=0; i<files.length; i++) { - String fn = files[i]; - if (fn.startsWith("data@app@") - || fn.startsWith("data@app-private@")) { - Slog.i(TAG, "Pruning dalvik file: " + fn); - (new File(dalvikCacheDir, fn)).delete(); - } - } - } + pruneDexFiles(new File(dataDir, "dalvik-cache")); } // Collect vendor overlay packages. @@ -1528,6 +1511,37 @@ public class PackageManagerService extends IPackageManager.Stub { } // synchronized (mInstallLock) } + private static void pruneDexFiles(File cacheDir) { + // If we had to do a dexopt of one of the previous + // things, then something on the system has changed. + // Consider this significant, and wipe away all other + // existing dexopt files to ensure we don't leave any + // dangling around. + // + // Additionally, delete all dex files from the root directory + // since there shouldn't be any there anyway. + File[] files = cacheDir.listFiles(); + if (files != null) { + for (File file : files) { + if (!file.isDirectory()) { + Slog.i(TAG, "Pruning dalvik file: " + file.getAbsolutePath()); + file.delete(); + } else { + File[] subDirList = file.listFiles(); + if (subDirList != null) { + for (File subDirFile : subDirList) { + final String fn = subDirFile.getName(); + if (fn.startsWith("data@app@") || fn.startsWith("data@app-private@")) { + Slog.i(TAG, "Pruning dalvik file: " + fn); + subDirFile.delete(); + } + } + } + } + } + } + } + public boolean isFirstBoot() { return !mRestoredSettings; } |