| Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java
|
| index 08ae69a4ee97bff5ba81806b8aead7f13431114d..802dedcc22c13e626f6fa354beda2f27992450f3 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java
|
| @@ -4,6 +4,7 @@
|
|
|
| package org.chromium.chrome.browser.notifications;
|
|
|
| +import android.annotation.TargetApi;
|
| import android.app.IntentService;
|
| import android.app.job.JobInfo;
|
| import android.app.job.JobScheduler;
|
| @@ -14,6 +15,7 @@ import android.content.Intent;
|
| import android.os.Build;
|
| import android.os.PersistableBundle;
|
| import android.os.StrictMode;
|
| +import android.os.SystemClock;
|
| import android.util.Log;
|
|
|
| import org.chromium.base.ThreadUtils;
|
| @@ -45,8 +47,10 @@ public class NotificationService extends IntentService {
|
| // rather than GcmNetworkManager or FirebaseJobDispatcher since the JobScheduler
|
| // allows us to execute immediately by setting an override deadline of zero
|
| // milliseconds.
|
| - // TODO(crbug.com/685210): UMA to check this does not introduce noticeable latency.
|
| + JobScheduler scheduler =
|
| + (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
|
| PersistableBundle extras = NotificationJobService.getJobExtrasFromIntent(intent);
|
| + putJobScheduledTimeInExtras(extras);
|
| JobInfo job =
|
| new JobInfo
|
| .Builder(TaskIds.NOTIFICATION_SERVICE_JOB_ID,
|
| @@ -54,8 +58,6 @@ public class NotificationService extends IntentService {
|
| .setExtras(extras)
|
| .setOverrideDeadline(0)
|
| .build();
|
| - JobScheduler scheduler =
|
| - (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
|
| scheduler.schedule(job);
|
| } else {
|
| // TODO(peter): Do we need to acquire a wake lock here?
|
| @@ -64,6 +66,12 @@ public class NotificationService extends IntentService {
|
| context.startService(intent);
|
| }
|
| }
|
| +
|
| + @TargetApi(Build.VERSION_CODES.N)
|
| + private static void putJobScheduledTimeInExtras(PersistableBundle extras) {
|
| + extras.putLong(NotificationConstants.EXTRA_JOB_SCHEDULED_TIME_MS,
|
| + SystemClock.elapsedRealtime());
|
| + }
|
| }
|
|
|
| public NotificationService() {
|
|
|