Merge "Skip cancelling jobs with FLAG_WILL_BE_FOREGROUND." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9bdf289f0a
@@ -662,11 +662,13 @@ public final class JobSchedulerService extends com.android.server.SystemService
|
|||||||
public void onDeviceIdleStateChanged(boolean deviceIdle) {
|
public void onDeviceIdleStateChanged(boolean deviceIdle) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (deviceIdle) {
|
if (deviceIdle) {
|
||||||
// When becoming idle, make sure no jobs are actively running.
|
// When becoming idle, make sure no jobs are actively running,
|
||||||
|
// except those using the idle exemption flag.
|
||||||
for (int i=0; i<mActiveServices.size(); i++) {
|
for (int i=0; i<mActiveServices.size(); i++) {
|
||||||
JobServiceContext jsc = mActiveServices.get(i);
|
JobServiceContext jsc = mActiveServices.get(i);
|
||||||
final JobStatus executing = jsc.getRunningJob();
|
final JobStatus executing = jsc.getRunningJob();
|
||||||
if (executing != null) {
|
if (executing != null
|
||||||
|
&& (executing.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0) {
|
||||||
jsc.cancelExecutingJob(JobParameters.REASON_DEVICE_IDLE);
|
jsc.cancelExecutingJob(JobParameters.REASON_DEVICE_IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user