diff options
author | Narayan Kamath <narayan@google.com> | 2014-06-16 13:46:27 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-06-10 21:16:15 +0000 |
commit | 076dc0135b153cbcedbe584645c93cfe4390cdb0 (patch) | |
tree | 2694e860fb0bbb183fe94c3de7820c2dfececf99 /services/java/com/android/server/pm/PackageManagerService.java | |
parent | 1083573c2feb6677ae5627a9ee41f82a697e22d4 (diff) | |
parent | 5b95e026842012be81e4cf6b8f5fac3ede625ab9 (diff) |
Merge "Move dex file pruning to installd."
Diffstat (limited to 'services/java/com/android/server/pm/PackageManagerService.java')
-rwxr-xr-x | services/java/com/android/server/pm/PackageManagerService.java | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index ab59e6a2e63b..2dad8abb2240 100755 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -1433,7 +1433,21 @@ public class PackageManagerService extends IPackageManager.Stub { } if (didDexOptLibraryOrTool) { - pruneDexFiles(new File(dataDir, "dalvik-cache")); + // If we dexopted a library or tool, 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. + // + // TODO: This should be revisited because it isn't as good an indicator + // as it used to be. It used to include the boot classpath but at some point + // DexFile.isDexOptNeeded started returning false for the boot + // class path files in all cases. It is very possible in a + // small maintenance release update that the library and tool + // jars may be unchanged but APK could be removed resulting in + // unused dalvik-cache files. + mInstaller.pruneDexCache(); } // Collect vendor overlay packages. @@ -1661,45 +1675,6 @@ 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. - // - // Note: This isn't as good an indicator as it used to be. It - // used to include the boot classpath but at some point - // DexFile.isDexOptNeeded started returning false for the boot - // class path files in all cases. It is very possible in a - // small maintenance release update that the library and tool - // jars may be unchanged but APK could be removed resulting in - // unused dalvik-cache files. - 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(); - } - } - } - } - } - } - } - @Override public boolean isFirstBoot() { return !mRestoredSettings || mPackageUsage.isFirstBoot(); |