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

Commit 0752a9c1 authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Tweaks to reduce flakiness of job related test

Increasing timeout for waiting for the test app to report job start /
stop events and elevating broadcast priority to foreground.

Test: atest FrameworksServicesTests:BackgroundRestrictionsTest

Bug: 254836785
Change-Id: I49cd4d259a361c8b059b521adf2746fc656dbf7a
parent 53e2c9f9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class BackgroundRestrictionsTest {
    private static final String TEST_APP_PACKAGE = "com.android.servicestests.apps.jobtestapp";
    private static final String TEST_APP_ACTIVITY = TEST_APP_PACKAGE + ".TestJobActivity";
    private static final long POLL_INTERVAL = 500;
    private static final long DEFAULT_WAIT_TIMEOUT = 5000;
    private static final long DEFAULT_WAIT_TIMEOUT = 10_000;

    private Context mContext;
    private AppOpsManager mAppOpsManager;
+4 −2
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ public class TestJobService extends JobService {
    public boolean onStartJob(JobParameters params) {
        Log.i(TAG, "Test job executing: " + params.getJobId());
        Intent reportJobStartIntent = new Intent(ACTION_JOB_STARTED);
        reportJobStartIntent.putExtra(JOB_PARAMS_EXTRA_KEY, params);
        reportJobStartIntent.putExtra(JOB_PARAMS_EXTRA_KEY, params)
                        .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        sendBroadcast(reportJobStartIntent);
        return true;
    }
@@ -43,7 +44,8 @@ public class TestJobService extends JobService {
    public boolean onStopJob(JobParameters params) {
        Log.i(TAG, "Test job stopped executing: " + params.getJobId());
        Intent reportJobStopIntent = new Intent(ACTION_JOB_STOPPED);
        reportJobStopIntent.putExtra(JOB_PARAMS_EXTRA_KEY, params);
        reportJobStopIntent.putExtra(JOB_PARAMS_EXTRA_KEY, params)
                        .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        sendBroadcast(reportJobStopIntent);
        // Deadline constraint is dropped on reschedule, so it's more reliable to use a new job.
        return false;