Commit e641faa1 authored by Gustav Sennton's avatar Gustav Sennton Committed by Commit Bot

[WebView] Replace use of JobScheduler.getPendingJob (API level 24).

AwVariationsConfigurationService uses JobScheduler.getPendingJob to
check whether a specific job is pending. This method was introduced in
Android version 24, but WebView supports version 21+, so replace the use
of JobScheduler.getPendingJob with JobScheduler.getAllPendingJobs instead.

Bug: 762607
Change-Id: Ia05815e73690ec0deff78d8d78b04d63376ec255
Reviewed-on: https://chromium-review.googlesource.com/664722
Commit-Queue: Gustav Sennton <gsennton@chromium.org>
Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501672}
parent 976fbbd6
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package org.chromium.android_webview.variations; package org.chromium.android_webview.variations;
import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Service; import android.app.Service;
import android.app.job.JobInfo; import android.app.job.JobInfo;
...@@ -143,13 +142,15 @@ public class AwVariationsConfigurationService extends Service { ...@@ -143,13 +142,15 @@ public class AwVariationsConfigurationService extends Service {
} }
} }
// TODO(crbug.com/762607): Fix getPendingJob API level and remove suppression.
@SuppressLint("NewApi")
private static boolean pendingJobExists() { private static boolean pendingJobExists() {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
JobScheduler scheduler = JobScheduler scheduler =
(JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
return scheduler.getPendingJob(TaskIds.WEBVIEW_VARIATIONS_SEED_FETCH_JOB_ID) != null; List<JobInfo> pendingJobs = scheduler.getAllPendingJobs();
for (JobInfo job : pendingJobs) {
if (job.getId() == TaskIds.WEBVIEW_VARIATIONS_SEED_FETCH_JOB_ID) return true;
}
return false;
} }
private static void scheduleSeedFetchJob() { private static void scheduleSeedFetchJob() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment