OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.omaha; | 5 package org.chromium.chrome.browser.omaha; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.IntentService; | 8 import android.app.IntentService; |
9 import android.app.job.JobService; | 9 import android.app.job.JobService; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 @Override | 110 @Override |
111 @TargetApi(Build.VERSION_CODES.M) | 111 @TargetApi(Build.VERSION_CODES.M) |
112 public boolean onStopTask(Context context, TaskParameters taskParameters) { | 112 public boolean onStopTask(Context context, TaskParameters taskParameters) { |
113 if (mJobServiceTask != null) { | 113 if (mJobServiceTask != null) { |
114 mJobServiceTask.cancel(false); | 114 mJobServiceTask.cancel(false); |
115 mJobServiceTask = null; | 115 mJobServiceTask = null; |
116 } | 116 } |
117 return false; | 117 return false; |
118 } | 118 } |
119 | 119 |
| 120 @Override |
| 121 @TargetApi(Build.VERSION_CODES.M) |
| 122 public void reschedule(Context context) { |
| 123 // Needs appropriate implementation. |
| 124 } |
| 125 |
120 /** | 126 /** |
121 * Schedules the Omaha code to run at the given time. | 127 * Schedules the Omaha code to run at the given time. |
122 * @param context Context to use. | 128 * @param context Context to use. |
123 * @param delayMs How long to wait until the job should be triggered. | 129 * @param delayMs How long to wait until the job should be triggered. |
124 */ | 130 */ |
125 @TargetApi(Build.VERSION_CODES.M) | 131 @TargetApi(Build.VERSION_CODES.M) |
126 static boolean scheduleJobService(Context context, long delayMs) { | 132 static boolean scheduleJobService(Context context, long delayMs) { |
127 long latency = Math.max(0, delayMs); | 133 long latency = Math.max(0, delayMs); |
128 | 134 |
129 TaskInfo taskInfo = TaskInfo.createOneOffTask(TaskIds.OMAHA_JOB_ID, Omah
aService.class, | 135 TaskInfo taskInfo = TaskInfo.createOneOffTask(TaskIds.OMAHA_JOB_ID, Omah
aService.class, |
130 latency, latency) | 136 latency, latency) |
131 .build(); | 137 .build(); |
132 return BackgroundTaskSchedulerFactory.getScheduler().schedule(context, t
askInfo); | 138 return BackgroundTaskSchedulerFactory.getScheduler().schedule(context, t
askInfo); |
133 } | 139 } |
134 } | 140 } |
OLD | NEW |