API coverage for Builder#requireDeviceIdle
Add a property to simulate idle jobs during test. Bug: 262614529 Bug: 235306967 Test: atest CtsStagedInstallHostTestCases Change-Id: Ieddce6f571e1a01793c360d05228d78b335b195e
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user