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

Commit fd2d7ead authored by Martin Stjernholm's avatar Martin Stjernholm Committed by Android (Google) Code Review
Browse files

Merge "Schedule the background dexopt job in ART Service if it should be used."

parents 6ddb6bbb 368b304f
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -189,13 +189,14 @@ public final class BackgroundDexOptService {
        void onPackagesUpdated(ArraySet<String> updatedPackages);
    }

    public BackgroundDexOptService(
            Context context, DexManager dexManager, PackageManagerService pm) {
    public BackgroundDexOptService(Context context, DexManager dexManager, PackageManagerService pm)
            throws LegacyDexoptDisabledException {
        this(new Injector(context, dexManager, pm));
    }

    @VisibleForTesting
    public BackgroundDexOptService(Injector injector) {
    public BackgroundDexOptService(Injector injector) throws LegacyDexoptDisabledException {
        Installer.checkLegacyDexoptDisabled();
        mInjector = injector;
        mDexOptHelper = mInjector.getDexOptHelper();
        LocalServices.addService(BackgroundDexOptService.class, this);
+2 −0
Original line number Diff line number Diff line
@@ -996,6 +996,8 @@ public final class DexOptHelper {
        artManager.addDexoptDoneCallback(false /* onlyIncludeUpdates */,
                Runnable::run, new DexoptDoneHandler(Objects.requireNonNull(pm)));
        LocalManagerRegistry.addManager(ArtManagerLocal.class, artManager);

        artManager.scheduleBackgroundDexoptJob();
    }

    /**
+21 −7
Original line number Diff line number Diff line
@@ -789,8 +789,10 @@ public class PackageManagerService implements PackageSender, TestUtilityService

    final ArtManagerService mArtManagerService;

    // TODO(b/260124949): Remove these.
    final PackageDexOptimizer mPackageDexOptimizer;
    final BackgroundDexOptService mBackgroundDexOptService;
    @Nullable
    final BackgroundDexOptService mBackgroundDexOptService; // null when ART Service is in use.
    // DexManager handles the usage of dex files (e.g. secondary files, whether or not a package
    // is used by other apps).
    private final DexManager mDexManager;
@@ -1567,7 +1569,16 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                new DefaultSystemWrapper(),
                LocalServices::getService,
                context::getSystemService,
                (i, pm) -> new BackgroundDexOptService(i.getContext(), i.getDexManager(), pm),
                (i, pm) -> {
                    if (useArtService()) {
                        return null;
                    }
                    try {
                        return new BackgroundDexOptService(i.getContext(), i.getDexManager(), pm);
                    } catch (LegacyDexoptDisabledException e) {
                        throw new RuntimeException(e);
                    }
                },
                (i, pm) -> IBackupManager.Stub.asInterface(ServiceManager.getService(
                        Context.BACKUP_SERVICE)),
                (i, pm) -> new SharedLibrariesImpl(pm, i),
@@ -4287,12 +4298,15 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                    }
                });

        // TODO(b/251903639): Call into ART Service.
        if (!useArtService()) {
            // The background dexopt job is scheduled in DexOptHelper.initializeArtManagerLocal when
            // ART Service is in use.
            try {
                mBackgroundDexOptService.systemReady();
            } catch (LegacyDexoptDisabledException e) {
                throw new RuntimeException(e);
            }
        }

        // Prune unused static shared libraries which have been cached a period of time
        schedulePruneUnusedStaticSharedLibraries(false /* delay */);
+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.pm;

import android.annotation.Nullable;
import android.app.ActivityManagerInternal;
import android.app.backup.IBackupManager;
import android.content.ComponentName;
@@ -138,7 +139,8 @@ public class PackageManagerServiceInjector {
    private final Singleton<DomainVerificationManagerInternal>
            mDomainVerificationManagerInternalProducer;
    private final Singleton<Handler> mHandlerProducer;
    private final Singleton<BackgroundDexOptService> mBackgroundDexOptService;
    private final Singleton<BackgroundDexOptService>
            mBackgroundDexOptService; // TODO(b/260124949): Remove this.
    private final Singleton<IBackupManager> mIBackupManager;
    private final Singleton<SharedLibrariesImpl> mSharedLibrariesProducer;
    private final Singleton<CrossProfileIntentFilterHelper> mCrossProfileIntentFilterHelperProducer;
@@ -408,6 +410,7 @@ public class PackageManagerServiceInjector {
        return getLocalService(ActivityManagerInternal.class);
    }

    @Nullable
    public BackgroundDexOptService getBackgroundDexOptService() {
        return mBackgroundDexOptService.get(this, mPackageManager);
    }
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public final class PackageManagerServiceTestParams {
    public boolean isEngBuild;
    public boolean isUserDebugBuild;
    public int sdkInt = Build.VERSION.SDK_INT;
    public BackgroundDexOptService backgroundDexOptService;
    public @Nullable BackgroundDexOptService backgroundDexOptService;
    public final String incrementalVersion = Build.VERSION.INCREMENTAL;
    public BroadcastHelper broadcastHelper;
    public AppDataHelper appDataHelper;