OSDN Git Service

Drop REASON_FORCED_DEXOPT.
authorNicolas Geoffray <ngeoffray@google.com>
Fri, 21 Apr 2017 14:41:13 +0000 (15:41 +0100)
committerNicolas Geoffray <ngeoffray@google.com>
Fri, 21 Apr 2017 14:43:19 +0000 (15:43 +0100)
This can already be configured with the default compiler filter.

Also remove unused performDexOptIfNeeded.

bug:35794392
Test: device boots, forced dexopt works.
Change-Id: I14fc86c4783b2d7ac9cf8972b6619ba303e79659

core/java/android/content/pm/IPackageManager.aidl
services/core/java/com/android/server/pm/PackageManagerService.java
services/core/java/com/android/server/pm/PackageManagerServiceCompilerMapping.java

index bc7a612..c7dd1fa 100644 (file)
@@ -474,15 +474,6 @@ interface IPackageManager {
     void notifyDexLoad(String loadingPackageName, in List<String> dexPaths, String loaderIsa);
 
     /**
-     * Ask the package manager to perform dex-opt (if needed) on the given
-     * package if it already hasn't done so.
-     *
-     * In most cases, apps are dexopted in advance and this function will
-     * be a no-op.
-     */
-    boolean performDexOptIfNeeded(String packageName);
-
-    /**
      * Ask the package manager to perform a dex-opt for the given reason. The package
      * manager will map the reason to a compiler filter according to the current system
      * configuration.
index a8d492b..77df971 100644 (file)
@@ -96,7 +96,7 @@ import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
 import static com.android.server.pm.InstructionSets.getPreferredInstructionSet;
 import static com.android.server.pm.InstructionSets.getPrimaryInstructionSet;
 import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
-import static com.android.server.pm.PackageManagerServiceCompilerMapping.getFullCompilerFilter;
+import static com.android.server.pm.PackageManagerServiceCompilerMapping.getDefaultCompilerFilter;
 import static com.android.server.pm.PackageManagerServiceCompilerMapping.getNonProfileGuidedCompilerFilter;
 import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_FAILURE;
 import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS;
@@ -536,9 +536,8 @@ 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_FORCED_DEXOPT = 5;
 
-    public static final int REASON_LAST = REASON_FORCED_DEXOPT;
+    public static final int REASON_LAST = REASON_AB_OTA;
 
     /** All dangerous permission names in the same order as the events in MetricsEvent */
     private static final List<String> ALL_DANGEROUS_PERMISSIONS = Arrays.asList(
@@ -8579,14 +8578,6 @@ public class PackageManagerService extends IPackageManager.Stub
         mDexManager.notifyDexLoad(ai, dexPaths, loaderIsa, userId);
     }
 
-    // TODO: this is not used nor needed. Delete it.
-    @Override
-    public boolean performDexOptIfNeeded(String packageName) {
-        int dexOptStatus = performDexOptTraced(packageName,
-                false /* checkProfiles */, getFullCompilerFilter(), false /* force */);
-        return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
-    }
-
     @Override
     public boolean performDexOpt(String packageName,
             boolean checkProfiles, int compileReason, boolean force) {
@@ -8863,10 +8854,10 @@ public class PackageManagerService extends IPackageManager.Stub
         synchronized (mInstallLock) {
             Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
 
-            // Whoever is calling forceDexOpt wants a fully compiled package.
+            // Whoever is calling forceDexOpt wants a compiled package.
             // Don't use profiles since that may cause compilation to be skipped.
             final int res = performDexOptInternalWithDependenciesLI(pkg,
-                    false /* checkProfiles */, getCompilerFilterForReason(REASON_FORCED_DEXOPT),
+                    false /* checkProfiles */, getDefaultCompilerFilter(),
                     true /* force */);
 
             Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
index f6872e4..284bb3f 100644 (file)
@@ -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", "forced-dexopt"
+            "first-boot", "boot", "install", "bg-dexopt", "ab-ota"
     };
 
     // Static block to ensure the strings array is of the right length.
@@ -54,16 +54,6 @@ public class PackageManagerServiceCompilerMapping {
                     + "(reason " + REASON_STRINGS[reason] + ")");
         }
 
-        // Ensure that some reasons are not mapped to profile-guided filters.
-        switch (reason) {
-            case PackageManagerService.REASON_FORCED_DEXOPT:
-                if (DexFile.isProfileGuidedCompilerFilter(sysPropValue)) {
-                    throw new IllegalStateException("\"" + sysPropValue + "\" is profile-guided, "
-                            + "but not allowed for " + REASON_STRINGS[reason]);
-                }
-                break;
-        }
-
         return sysPropValue;
     }
 
@@ -103,12 +93,12 @@ public class PackageManagerServiceCompilerMapping {
     }
 
     /**
-     * Return the compiler filter for "full" compilation.
+     * Return the default compiler filter for compilation.
      *
      * We derive that from the traditional "dalvik.vm.dex2oat-filter" property and just make
      * sure this isn't profile-guided. Returns "speed" in case of invalid (or missing) values.
      */
-    public static String getFullCompilerFilter() {
+    public static String getDefaultCompilerFilter() {
         String value = SystemProperties.get("dalvik.vm.dex2oat-filter");
         if (value == null || value.isEmpty()) {
             return "speed";