Fix ART Service initialization order problems.
- Move ArtManagerLocal initialization before the boot compilation step (UpdatePackagesIfNeeded). - Delay scheduling the background dexopt job because the job scheduler hasn't been started at that point. Test: Boot with dalvik.vm.useartservice=true and check logcat that ART Service starts up and a first-boot dexopt runs without errors. Bug: 266028904 Change-Id: I108b877f2a99c69c20f7209339cd193c2d41e7ea
This commit is contained in:
@@ -40,8 +40,10 @@ import static dalvik.system.DexFile.isProfileGuidedCompilerFilter;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.AppGlobals;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.SharedLibraryInfo;
|
||||
import android.content.pm.dex.ArtManager;
|
||||
@@ -1019,7 +1021,15 @@ public final class DexOptHelper {
|
||||
pm.getDexOptHelper().new DexoptDoneHandler());
|
||||
LocalManagerRegistry.addManager(ArtManagerLocal.class, artManager);
|
||||
|
||||
artManager.scheduleBackgroundDexoptJob();
|
||||
// Schedule the background job when boot is complete. This decouples us from when
|
||||
// JobSchedulerService is initialized.
|
||||
systemContext.registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
context.unregisterReceiver(this);
|
||||
artManager.scheduleBackgroundDexoptJob();
|
||||
}
|
||||
}, new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1789,6 +1789,10 @@ public final class SystemServer implements Dumpable {
|
||||
}
|
||||
t.traceEnd();
|
||||
|
||||
t.traceBegin("ArtManagerLocal");
|
||||
DexOptHelper.initializeArtManagerLocal(context, mPackageManagerService);
|
||||
t.traceEnd();
|
||||
|
||||
t.traceBegin("UpdatePackagesIfNeeded");
|
||||
try {
|
||||
Watchdog.getInstance().pauseWatchingCurrentThread("dexopt");
|
||||
@@ -2737,10 +2741,6 @@ public final class SystemServer implements Dumpable {
|
||||
mSystemServiceManager.startService(PermissionPolicyService.class);
|
||||
t.traceEnd();
|
||||
|
||||
t.traceBegin("ArtManagerLocal");
|
||||
DexOptHelper.initializeArtManagerLocal(context, mPackageManagerService);
|
||||
t.traceEnd();
|
||||
|
||||
t.traceBegin("MakePackageManagerServiceReady");
|
||||
mPackageManagerService.systemReady();
|
||||
t.traceEnd();
|
||||
|
||||
Reference in New Issue
Block a user