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

Commit 48b9a472 authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

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
parent b75a0dfe
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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,8 +1021,16 @@ public final class DexOptHelper {
                pm.getDexOptHelper().new DexoptDoneHandler());
        LocalManagerRegistry.addManager(ArtManagerLocal.class, artManager);

        // 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));
    }

    /**
     * Returns the registered {@link ArtManagerLocal} instance, or else throws an unchecked error.
+4 −4
Original line number Diff line number Diff line
@@ -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();