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

Commit 7366e8c1 authored by Nicolas Geoffray's avatar Nicolas Geoffray Committed by Android (Google) Code Review
Browse files

Merge changes I7a052a8e,Idb11b1c0 into nyc-mr1-dev

* changes:
  [RFC] Special case system apps for profile optimizations
  Compile core-apps according to their own "reason" for A/B
parents acef1eb7 0bd77620
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -285,6 +285,11 @@ public class Environment {
        return buildPath(getDataDirectory(), "misc", "profiles", "cur", String.valueOf(userId));
        return buildPath(getDataDirectory(), "misc", "profiles", "cur", String.valueOf(userId));
    }
    }


    /** {@hide} */
    public static File getReferenceProfile(String packageName) {
        return buildPath(getDataDirectory(), "misc", "profiles", "ref", packageName);
    }

    /** {@hide} */
    /** {@hide} */
    public static File getDataProfilesDePackageDirectory(int userId, String packageName) {
    public static File getDataProfilesDePackageDirectory(int userId, String packageName) {
        return buildPath(getDataProfilesDeDirectory(userId), packageName);
        return buildPath(getDataProfilesDeDirectory(userId), packageName);
+11 −1
Original line number Original line Diff line number Diff line
@@ -213,9 +213,19 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
        // Use the package manager install and install lock here for the OTA dex optimizer.
        // Use the package manager install and install lock here for the OTA dex optimizer.
        PackageDexOptimizer optimizer = new OTADexoptPackageDexOptimizer(
        PackageDexOptimizer optimizer = new OTADexoptPackageDexOptimizer(
                collectingInstaller, mPackageManagerService.mInstallLock, mContext);
                collectingInstaller, mPackageManagerService.mInstallLock, mContext);
        // Make sure that core apps are optimized according to their own "reason".
        // If the core apps are not preopted in the B OTA, and REASON_AB_OTA is not speed
        // (by default is speed-profile) they will be interepreted/JITed. This in itself is not a
        // problem as we will end up doing profile guided compilation. However, some core apps may
        // be loaded by system server which doesn't JIT and we need to make sure we don't
        // interpret-only
        int compilationReason = nextPackage.coreApp
                ? PackageManagerService.REASON_CORE_APP
                : PackageManagerService.REASON_AB_OTA;

        optimizer.performDexOpt(nextPackage, nextPackage.usesLibraryFiles,
        optimizer.performDexOpt(nextPackage, nextPackage.usesLibraryFiles,
                null /* ISAs */, false /* checkProfiles */,
                null /* ISAs */, false /* checkProfiles */,
                getCompilerFilterForReason(PackageManagerService.REASON_AB_OTA));
                getCompilerFilterForReason(compilationReason));


        mCommandsForCurrentPackage = collectingConnection.commands;
        mCommandsForCurrentPackage = collectingConnection.commands;
        if (mCommandsForCurrentPackage.isEmpty()) {
        if (mCommandsForCurrentPackage.isEmpty()) {
+17 −3
Original line number Original line Diff line number Diff line
@@ -95,6 +95,7 @@ import static com.android.server.pm.InstructionSets.getPreferredInstructionSet;
import static com.android.server.pm.InstructionSets.getPrimaryInstructionSet;
import static com.android.server.pm.InstructionSets.getPrimaryInstructionSet;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getFullCompilerFilter;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getFullCompilerFilter;
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_FAILURE;
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS;
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS;
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED;
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED;
@@ -2800,7 +2801,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                    }
                    }
                }
                }
                int[] stats = performDexOpt(coreApps, false,
                int[] stats = performDexOptUpgrade(coreApps, false,
                        getCompilerFilterForReason(REASON_CORE_APP));
                        getCompilerFilterForReason(REASON_CORE_APP));
                final int elapsedTimeSeconds =
                final int elapsedTimeSeconds =
@@ -7324,7 +7325,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
        }
        final long startTime = System.nanoTime();
        final long startTime = System.nanoTime();
        final int[] stats = performDexOpt(pkgs, mIsPreNUpgrade /* showDialog */,
        final int[] stats = performDexOptUpgrade(pkgs, mIsPreNUpgrade /* showDialog */,
                    getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT));
                    getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT));
        final int elapsedTimeSeconds =
        final int elapsedTimeSeconds =
@@ -7343,7 +7344,7 @@ public class PackageManagerService extends IPackageManager.Stub {
     * which are (in order) {@code numberOfPackagesOptimized}, {@code numberOfPackagesSkipped}
     * which are (in order) {@code numberOfPackagesOptimized}, {@code numberOfPackagesSkipped}
     * and {@code numberOfPackagesFailed}.
     * and {@code numberOfPackagesFailed}.
     */
     */
    private int[] performDexOpt(List<PackageParser.Package> pkgs, boolean showDialog,
    private int[] performDexOptUpgrade(List<PackageParser.Package> pkgs, boolean showDialog,
            String compilerFilter) {
            String compilerFilter) {
        int numberOfPackagesVisited = 0;
        int numberOfPackagesVisited = 0;
@@ -7377,6 +7378,19 @@ public class PackageManagerService extends IPackageManager.Stub {
                }
                }
            }
            }
            // If the OTA updates a system app which was previously preopted to a non-preopted state
            // the app might end up being verified at runtime. That's because by default the apps
            // are verify-profile but for preopted apps there's no profile.
            // Do a hacky check to ensure that if we have no profiles (a reasonable indication
            // that before the OTA the app was preopted) the app gets compiled with a non-profile
            // filter (by default interpret-only).
            // Note that at this stage unused apps are already filtered.
            if (isSystemApp(pkg) &&
                    DexFile.isProfileGuidedCompilerFilter(compilerFilter) &&
                    !Environment.getReferenceProfile(pkg.packageName).exists()) {
                compilerFilter = getNonProfileGuidedCompilerFilter(compilerFilter);
            }
            // checkProfiles is false to avoid merging profiles during boot which
            // checkProfiles is false to avoid merging profiles during boot which
            // might interfere with background compilation (b/28612421).
            // might interfere with background compilation (b/28612421).
            // Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
            // Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will