Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 557fc241 authored by Andreas Gampe's avatar Andreas Gampe Committed by android-build-merger
Browse files

Merge "PackageManager: Move compilation reasons to PMS" into nyc-dev am: e37ce3db

am: 103c45ed

* commit '103c45ed':
  PackageManager: Move compilation reasons to PMS
parents a6d4d4f8 103c45ed
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.server.pm;

import static com.android.server.pm.PackageManagerServiceCompilerMapping.REASON_BACKGROUND_DEXOPT;

import android.app.AlarmManager;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
@@ -26,7 +24,6 @@ import android.app.job.JobService;
import android.content.ComponentName;
import android.content.Context;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.util.ArraySet;
import android.util.Log;

@@ -94,7 +91,7 @@ public class BackgroundDexOptService extends JobService {
                        continue;
                    }
                    if (!pm.performDexOpt(pkg, /* instruction set */ null, /* checkProfiles */ true,
                            REASON_BACKGROUND_DEXOPT, /* force */ false)) {
                            PackageManagerService.REASON_BACKGROUND_DEXOPT, /* force */ false)) {
                        // there was a problem running dexopt,
                        // remember this so we do not keep retrying.
                        sFailedPackageNames.add(pkg);
+1 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static com.android.server.pm.Installer.DEXOPT_OTA;
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.REASON_AB_OTA;

import android.content.Context;
import android.content.pm.IOtaDexopt;
@@ -144,7 +143,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
        }

        mPackageDexOptimizer.performDexOpt(nextPackage, null /* ISAs */, false /* useProfiles */,
                getCompilerFilterForReason(REASON_AB_OTA));
                getCompilerFilterForReason(PackageManagerService.REASON_AB_OTA));
    }

    private void moveAbArtifacts(Installer installer) {
+11 −5
Original line number Diff line number Diff line
@@ -94,11 +94,6 @@ 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.REASON_BOOT;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.REASON_FORCED_DEXOPT;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.REASON_INSTALL;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.REASON_NON_SYSTEM_LIBRARY;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.REASON_SHARED_APK;
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_FAILURE;
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS;
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED;
@@ -448,6 +443,17 @@ public class PackageManagerService extends IPackageManager.Stub {
        sBrowserIntent.setData(Uri.parse("http:"));
    }
    // Compilation reasons.
    public static final int REASON_BOOT = 0;
    public static final int REASON_INSTALL = 1;
    public static final int REASON_BACKGROUND_DEXOPT = 2;
    public static final int REASON_AB_OTA = 3;
    public static final int REASON_NON_SYSTEM_LIBRARY = 4;
    public static final int REASON_SHARED_APK = 5;
    public static final int REASON_FORCED_DEXOPT = 6;
    public static final int REASON_LAST = REASON_FORCED_DEXOPT;
    final ServiceThread mHandlerThread;
    final PackageHandler mHandler;
+4 −15
Original line number Diff line number Diff line
@@ -24,17 +24,6 @@ import dalvik.system.DexFile;
 * Manage (retrieve) mappings from compilation reason to compilation filter.
 */
class PackageManagerServiceCompilerMapping {
    // Compilation reasons.
    public static final int REASON_BOOT = 0;
    public static final int REASON_INSTALL = 1;
    public static final int REASON_BACKGROUND_DEXOPT = 2;
    public static final int REASON_AB_OTA = 3;
    public static final int REASON_NON_SYSTEM_LIBRARY = 4;
    public static final int REASON_SHARED_APK = 5;
    public static final int REASON_FORCED_DEXOPT = 6;

    private static final int REASON_LAST = REASON_FORCED_DEXOPT;

    // Names for compilation reasons.
    static final String REASON_STRINGS[] = {
            "boot", "install", "bg-dexopt", "ab-ota", "nsys-library", "shared-apk", "forced-dexopt"
@@ -42,7 +31,7 @@ class PackageManagerServiceCompilerMapping {

    // Static block to ensure the strings array is of the right length.
    static {
        if (REASON_LAST + 1 != REASON_STRINGS.length) {
        if (PackageManagerService.REASON_LAST + 1 != REASON_STRINGS.length) {
            throw new IllegalStateException("REASON_STRINGS not correct");
        }
    }
@@ -67,8 +56,8 @@ class PackageManagerServiceCompilerMapping {

        // Ensure that some reasons are not mapped to profile-guided filters.
        switch (reason) {
            case REASON_SHARED_APK:
            case REASON_FORCED_DEXOPT:
            case PackageManagerService.REASON_SHARED_APK:
            case PackageManagerService.REASON_FORCED_DEXOPT:
                if (DexFile.isProfileGuidedCompilerFilter(sysPropValue)) {
                    throw new IllegalStateException("\"" + sysPropValue + "\" is profile-guided, "
                            + "but not allowed for " + REASON_STRINGS[reason]);
@@ -86,7 +75,7 @@ class PackageManagerServiceCompilerMapping {
        // overview. Store the exceptions here.
        RuntimeException toThrow = null;

        for (int reason = 0; reason <= REASON_LAST; reason++) {
        for (int reason = 0; reason <= PackageManagerService.REASON_LAST; reason++) {
            try {
                // Check that the system property name is legal.
                String sysPropName = getSystemPropertyName(reason);
+2 −3
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ShellCommand;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.PrintWriterPrinter;
@@ -331,12 +330,12 @@ class PackageManagerShellCommand extends ShellCommand {
                // Use the default mode for background dexopt.
                targetCompilerFilter =
                        PackageManagerServiceCompilerMapping.getCompilerFilterForReason(
                                PackageManagerServiceCompilerMapping.REASON_BACKGROUND_DEXOPT);
                                PackageManagerService.REASON_BACKGROUND_DEXOPT);
            } else if ("reset".equals(compilerFilter)) {
                // Use the default mode for install.
                targetCompilerFilter =
                        PackageManagerServiceCompilerMapping.getCompilerFilterForReason(
                                PackageManagerServiceCompilerMapping.REASON_INSTALL);
                                PackageManagerService.REASON_INSTALL);
            } else {
                if (!DexFile.isValidCompilerFilter(compilerFilter)) {
                    pw.println("Error: \"" + compilerFilter +