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

Commit 80dff2f2 authored by JW Wang's avatar JW Wang
Browse files

Dispatch pre-reboot verification tasks to the installer thread

Sometimes the system becomes busy and tasks dispatched to the background
thread are queued without running for a long time.

This causes test failures for the staged sessions didn't become ready
within the timeout. See b/185863896#comment2.

The issue is alleviated by using the installer thread instead of the
background thread. See comment#7 for the improvement.

Also, we have more consistency with this change by running all
installation tasks on the same thread for both staged and non-staged
sessions.

Bug: 185863896
Test: atest StagedRollbackTest MultiUserRollbackTest
Change-Id: Iec7e09defcfd1526bd84f71b97e0fa4ef734a37f
parent dbc61d67
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -239,7 +239,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        mSessionsDir.mkdirs();

        mApexManager = ApexManager.getInstance();
        mStagingManager = new StagingManager(context, apexParserSupplier);
        mStagingManager = new StagingManager(context, apexParserSupplier,
                mInstallThread.getLooper());

        LocalServices.getService(SystemServiceManager.class).startService(
                new Lifecycle(context, this));
+8 −4
Original line number Diff line number Diff line
@@ -142,20 +142,24 @@ public class StagingManager {
        void verifySession();
    }

    StagingManager(Context context, Supplier<PackageParser2> packageParserSupplier) {
        this(context, packageParserSupplier, ApexManager.getInstance());
    StagingManager(Context context, Supplier<PackageParser2> packageParserSupplier, Looper looper) {
        this(context, packageParserSupplier, ApexManager.getInstance(), looper);
    }

    @VisibleForTesting
    StagingManager(Context context, Supplier<PackageParser2> packageParserSupplier,
            ApexManager apexManager) {
        this(context, packageParserSupplier, apexManager, BackgroundThread.get().getLooper());
    }

    StagingManager(Context context, Supplier<PackageParser2> packageParserSupplier,
            ApexManager apexManager, Looper looper) {
        mContext = context;
        mPackageParserSupplier = packageParserSupplier;

        mApexManager = apexManager;
        mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mPreRebootVerificationHandler = new PreRebootVerificationHandler(
                BackgroundThread.get().getLooper());
        mPreRebootVerificationHandler = new PreRebootVerificationHandler(looper);

        if (mFailureReasonFile.exists()) {
            try (BufferedReader reader = new BufferedReader(new FileReader(mFailureReasonFile))) {