Merge "Schedule the background dexopt job in ART Service if it should be used."
This commit is contained in:
committed by
Android (Google) Code Review
commit
fd2d7ead2e
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,11 +4298,14 @@ public class PackageManagerService implements PackageSender, TestUtilityService
|
||||
}
|
||||
});
|
||||
|
||||
// TODO(b/251903639): Call into ART Service.
|
||||
try {
|
||||
mBackgroundDexOptService.systemReady();
|
||||
} catch (LegacyDexoptDisabledException e) {
|
||||
throw new RuntimeException(e);
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user