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

Commit a6d73457 authored by JW Wang's avatar JW Wang
Browse files

API coverage for Builder#requireDeviceIdle

Add a property to simulate idle jobs during test.

Bug: 262614529
Bug: 235306967
Test: atest CtsStagedInstallHostTestCases
Change-Id: Ieddce6f571e1a01793c360d05228d78b335b195e
parent 3d43d701
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.text.format.DateUtils;
import android.util.Slog;

@@ -167,6 +168,14 @@ public class GentleUpdateHelper {

    @WorkerThread
    private void scheduleIdleJob() {
        // Simulate idle jobs during test. Otherwise we need to wait for
        // more than 30 mins for JS to trigger the job.
        boolean isIdle = SystemProperties.getBoolean("debug.pm.gentle_update_test.is_idle", false);
        if (isIdle) {
            mHandler.post(this::runIdleJob);
            return;
        }

        if (mHasPendingIdleJob) {
            // No need to schedule the job again
            return;