From 2ab076f611cecb771fe546580634583a27c61aa5 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Sun, 26 Mar 2017 14:31:34 +0100 Subject: [PATCH] Drop REASON_SHARED_APK. This reason was only used by "system shared libraries", not shared APKs like GMS. Code that uses this reason is now obsolete, as we do compile these shared libraries when we see an apk that uses it. bug:33799337 Test: m -j32 && boot Change-Id: I2eef22797551401a5c39ed339bc2486cf0d091a8 (cherry picked from commit 86d1e9e23e79687ae94854fc6aa22c3d4ad98423) --- .../server/pm/PackageManagerService.java | 56 +------------------ .../PackageManagerServiceCompilerMapping.java | 3 +- 2 files changed, 2 insertions(+), 57 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 6ef0a2542713d..43558af3413b4 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -537,8 +537,7 @@ public class PackageManagerService extends IPackageManager.Stub { public static final int REASON_INSTALL = 2; public static final int REASON_BACKGROUND_DEXOPT = 3; public static final int REASON_AB_OTA = 4; - public static final int REASON_SHARED_APK = 5; - public static final int REASON_FORCED_DEXOPT = 6; + public static final int REASON_FORCED_DEXOPT = 5; public static final int REASON_LAST = REASON_FORCED_DEXOPT; @@ -2376,59 +2375,6 @@ public class PackageManagerService extends IPackageManager.Stub { Slog.w(TAG, "No SYSTEMSERVERCLASSPATH found!"); } - final List allInstructionSets = InstructionSets.getAllInstructionSets(); - final String[] dexCodeInstructionSets = - getDexCodeInstructionSets( - allInstructionSets.toArray(new String[allInstructionSets.size()])); - - /** - * Ensure all external libraries have had dexopt run on them. - */ - if (mSharedLibraries.size() > 0) { - Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt"); - // NOTE: For now, we're compiling these system "shared libraries" - // (and framework jars) into all available architectures. It's possible - // to compile them only when we come across an app that uses them (there's - // already logic for that in scanPackageLI) but that adds some complexity. - for (String dexCodeInstructionSet : dexCodeInstructionSets) { - final int libCount = mSharedLibraries.size(); - for (int i = 0; i < libCount; i++) { - SparseArray versionedLib = mSharedLibraries.valueAt(i); - final int versionCount = versionedLib.size(); - for (int j = 0; j < versionCount; j++) { - SharedLibraryEntry libEntry = versionedLib.valueAt(j); - final String libPath = libEntry.path != null - ? libEntry.path : libEntry.apk; - if (libPath == null) { - continue; - } - try { - // Shared libraries do not have profiles so we perform a full - // AOT compilation (if needed). - int dexoptNeeded = DexFile.getDexOptNeeded( - libPath, dexCodeInstructionSet, - getCompilerFilterForReason(REASON_SHARED_APK), - false /* newProfile */); - if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) { - mInstaller.dexopt(libPath, Process.SYSTEM_UID, "*", - dexCodeInstructionSet, dexoptNeeded, null, - DEXOPT_PUBLIC, - getCompilerFilterForReason(REASON_SHARED_APK), - StorageManager.UUID_PRIVATE_INTERNAL, - PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK); - } - } catch (FileNotFoundException e) { - Slog.w(TAG, "Library not found: " + libPath); - } catch (IOException | InstallerException e) { - Slog.w(TAG, "Cannot dexopt " + libPath + "; is it an APK or JAR? " - + e.getMessage()); - } - } - } - } - Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); - } - File frameworkDir = new File(Environment.getRootDirectory(), "framework"); final VersionInfo ver = mSettings.getInternalVersion(); diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceCompilerMapping.java b/services/core/java/com/android/server/pm/PackageManagerServiceCompilerMapping.java index 987a801c4e1c5..f6872e4373fdb 100644 --- a/services/core/java/com/android/server/pm/PackageManagerServiceCompilerMapping.java +++ b/services/core/java/com/android/server/pm/PackageManagerServiceCompilerMapping.java @@ -26,7 +26,7 @@ import dalvik.system.DexFile; public class PackageManagerServiceCompilerMapping { // Names for compilation reasons. static final String REASON_STRINGS[] = { - "first-boot", "boot", "install", "bg-dexopt", "ab-ota", "shared-apk", "forced-dexopt" + "first-boot", "boot", "install", "bg-dexopt", "ab-ota", "forced-dexopt" }; // Static block to ensure the strings array is of the right length. @@ -56,7 +56,6 @@ public class PackageManagerServiceCompilerMapping { // Ensure that some reasons are not mapped to profile-guided filters. switch (reason) { - case PackageManagerService.REASON_SHARED_APK: case PackageManagerService.REASON_FORCED_DEXOPT: if (DexFile.isProfileGuidedCompilerFilter(sysPropValue)) { throw new IllegalStateException("\"" + sysPropValue + "\" is profile-guided, "