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

Commit 418815ec authored by Kweku Adams's avatar Kweku Adams
Browse files

Remove unnecessary cancel().

JobScheduler.schedule() will cancel any existing job with the same ID,
so calling getPendingJob() and then cancel() before schedule() is unnecessary.

Bug: 238764917
Test: atest ReviewNotificationPermissionsJobServiceTest
Change-Id: I7af83edf9f8971a82dd8ef32d9480a803707facc
parent 10b857af
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -42,10 +42,6 @@ public class ReviewNotificationPermissionsJobService extends JobService {
     */
    public static void scheduleJob(Context context, long rescheduleTimeMillis) {
        JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
        // if the job already exists for some reason, cancel & reschedule
        if (jobScheduler.getPendingJob(JOB_ID) != null) {
            jobScheduler.cancel(JOB_ID);
        }
        ComponentName component = new ComponentName(
                context, ReviewNotificationPermissionsJobService.class);
        JobInfo newJob = new JobInfo.Builder(JOB_ID, component)
+0 −5
Original line number Diff line number Diff line
@@ -20,10 +20,8 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.job.JobInfo;
import android.app.job.JobParameters;
@@ -75,9 +73,6 @@ public class ReviewNotificationPermissionsJobServiceTest extends UiServiceTestCa

    @Test
    public void testScheduleJob() {
        // if asked, the job doesn't currently exist yet
        when(mMockJobScheduler.getPendingJob(anyInt())).thenReturn(null);

        final int rescheduleTimeMillis = 350;  // arbitrary number

        // attempt to schedule the job