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

Commit 0182fb2d authored by JW Wang's avatar JW Wang
Browse files

Skip APEX when doing dexopt

APEX is not dex-optimized and doesn't have a valid UID.

Bug: 225756739
Fix: 234312670
Test: tradefed.sh run host --class \
      com.google.android.tradefed.dexoptota.PostRebootTest
Test: tradefed.sh run host --class \
      com.google.android.tradefed.dexoptota.PreRebootTest
Change-Id: I87482f87453ef6bb73c96d4e3a9c8d3cb1d7c428
parent 050b5a83
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3252,7 +3252,8 @@ public class ComputerEngine implements Computer {

                for (PackageStateInternal pkgSetting : pkgSettings) {
                    final AndroidPackage pkg = pkgSetting.getPkg();
                    if (pkg == null) {
                    if (pkg == null || pkg.isApex()) {
                        // Skip APEX which is not dex-optimized
                        continue;
                    }
                    final String pkgName = pkg.getPackageName();
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.server.pm.PackageManagerService.STUB_SUFFIX;
import static com.android.server.pm.PackageManagerService.TAG;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getDefaultCompilerFilter;
import static com.android.server.pm.PackageManagerServiceUtils.REMOVE_IF_APEX_PKG;
import static com.android.server.pm.PackageManagerServiceUtils.REMOVE_IF_NULL_PKG;

import android.Manifest;
@@ -572,6 +573,7 @@ final class DexOptHelper {

        // First, remove all settings without available packages
        remainingPkgSettings.removeIf(REMOVE_IF_NULL_PKG);
        remainingPkgSettings.removeIf(REMOVE_IF_APEX_PKG);

        ArrayList<PackageStateInternal> sortTemp = new ArrayList<>(remainingPkgSettings.size());

+1 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
        others = new ArrayList<>(allPackageStates);
        others.removeAll(important);
        others.removeIf(PackageManagerServiceUtils.REMOVE_IF_NULL_PKG);
        others.removeIf(PackageManagerServiceUtils.REMOVE_IF_APEX_PKG);
        others.removeIf(isPlatformPackage);

        // Pre-size the array list by over-allocating by a factor of 1.5.
+4 −1
Original line number Diff line number Diff line
@@ -135,7 +135,10 @@ public class PackageManagerServiceUtils {

    private static final boolean DEBUG = Build.IS_DEBUGGABLE;

    public final static Predicate<PackageStateInternal> REMOVE_IF_NULL_PKG =
    // Skip APEX which doesn't have a valid UID
    public static final Predicate<PackageStateInternal> REMOVE_IF_APEX_PKG =
            pkgSetting -> pkgSetting.getPkg().isApex();
    public static final Predicate<PackageStateInternal> REMOVE_IF_NULL_PKG =
            pkgSetting -> pkgSetting.getPkg() == null;

    /**