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

Commit 1d3de140 authored by Calin Juravle's avatar Calin Juravle
Browse files

Ignore System Server dynamic dex files during A/B preopt

System Server dex files has a special dexopt path while the
OTA service uses a PackageDexOptimizer backdoor which breaks
the assumptions.

Ignore any file loaded by system server until we update the
OTA service to use the proper PMS dexopt paths.

Test: adb shell; /system/bin/otapreopt_script 1
Bug: 160735835
Change-Id: Ic3d0a3127862c99c7e29ce552f6d89c248df1d0c
parent e505016e
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.pm;

import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;

import android.annotation.Nullable;
import android.content.Context;
@@ -42,10 +43,9 @@ import java.io.FileDescriptor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;

/**
 * A service for A/B OTA dexopting.
@@ -123,15 +123,20 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
        }
        final List<PackageSetting> important;
        final List<PackageSetting> others;
        Predicate<PackageSetting> isPlatformPackage = pkgSetting ->
                PLATFORM_PACKAGE_NAME.equals(pkgSetting.pkg.getPackageName());
        synchronized (mPackageManagerService.mLock) {
            // Important: the packages we need to run with ab-ota compiler-reason.
            important = PackageManagerServiceUtils.getPackagesForDexopt(
                    mPackageManagerService.mSettings.mPackages.values(), mPackageManagerService,
                    DEBUG_DEXOPT);
            // Remove Platform Package from A/B OTA b/160735835.
            important.removeIf(isPlatformPackage);
            // Others: we should optimize this with the (first-)boot compiler-reason.
            others = new ArrayList<>(mPackageManagerService.mSettings.mPackages.values());
            others.removeAll(important);
            others.removeIf(PackageManagerServiceUtils.REMOVE_IF_NULL_PKG);
            others.removeIf(isPlatformPackage);

            // Pre-size the array list by over-allocating by a factor of 1.5.
            mDexoptCommands = new ArrayList<>(3 * mPackageManagerService.mPackages.size() / 2);