Loading apex/jobscheduler/framework/java/android/app/job/JobServiceEngine.java +1 −5 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.app.job; import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.Handler; import android.os.IBinder; Loading @@ -26,8 +25,6 @@ import android.os.Message; import android.os.RemoteException; import android.util.Log; import com.android.internal.annotations.GuardedBy; import java.lang.ref.WeakReference; /** Loading Loading @@ -206,8 +203,7 @@ public abstract class JobServiceEngine { /** * Call in to engine to report that a job has finished executing. See * {@link JobService#jobFinished(JobParameters, boolean)} JobService.jobFinished} for more * information. * {@link JobService#jobFinished(JobParameters, boolean)} for more information. */ public void jobFinished(JobParameters params, boolean needsReschedule) { if (params == null) { Loading apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -1054,6 +1054,7 @@ public class JobSchedulerService extends com.android.server.SystemService public int scheduleAsPackage(JobInfo job, JobWorkItem work, int uId, String packageName, int userId, String tag) { // Rate limit excessive schedule() calls. final String servicePkg = job.getService().getPackageName(); if (job.isPersisted() && (packageName == null || packageName.equals(servicePkg))) { // Only limit schedule calls for persisted jobs scheduled by the app itself. Loading Loading @@ -1358,8 +1359,7 @@ public class JobSchedulerService extends com.android.server.SystemService for (int i=0; i<mActiveServices.size(); i++) { JobServiceContext jsc = mActiveServices.get(i); final JobStatus executing = jsc.getRunningJobLocked(); if (executing != null && (executing.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0) { if (executing != null && !executing.canRunInDoze()) { jsc.cancelExecutingJobLocked(JobParameters.REASON_DEVICE_IDLE, "cancelled due to doze"); } Loading Loading @@ -1411,7 +1411,7 @@ public class JobSchedulerService extends com.android.server.SystemService final JobServiceContext jsc = mActiveServices.get(i); final JobStatus job = jsc.getRunningJobLocked(); if (job != null && (job.getJob().getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0 && !job.canRunInDoze() && !job.dozeWhitelisted && !job.uidActive) { // We will report active if we have a job running and it is not an exception Loading apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java +1 −2 Original line number Diff line number Diff line Loading @@ -189,8 +189,7 @@ public final class BackgroundJobsController extends StateController { final String packageName = jobStatus.getSourcePackageName(); final boolean canRun = !mAppStateTracker.areJobsRestricted(uid, packageName, (jobStatus.getInternalFlags() & JobStatus.INTERNAL_FLAG_HAS_FOREGROUND_EXEMPTION) != 0); jobStatus.canRunInBatterySaver()); final boolean isActive; if (activeState == UNKNOWN) { Loading apex/jobscheduler/service/java/com/android/server/job/controllers/ConnectivityController.java +1 −1 Original line number Diff line number Diff line Loading @@ -464,7 +464,7 @@ public final class ConnectivityController extends RestrictingController implemen NetworkCapabilities capabilities) { // TODO: consider matching against non-active networks final boolean ignoreBlocked = (jobStatus.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; final boolean ignoreBlocked = jobStatus.shouldIgnoreNetworkBlocking(); final NetworkInfo info = mConnManager.getNetworkInfoForUid(network, jobStatus.getSourceUid(), ignoreBlocked); Loading apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java +23 −5 Original line number Diff line number Diff line Loading @@ -470,7 +470,7 @@ public final class JobStatus { } this.requiredConstraints = requiredConstraints; mRequiredConstraintsOfInterest = requiredConstraints & CONSTRAINTS_OF_INTEREST; mReadyNotDozing = (job.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; mReadyNotDozing = canRunInDoze(); if (standbyBucket == RESTRICTED_INDEX) { addDynamicConstraints(DYNAMIC_RESTRICTED_CONSTRAINTS); } else { Loading Loading @@ -1036,6 +1036,22 @@ public final class JobStatus { mPersistedUtcTimes = null; } /** * @return true if the job is exempted from Doze restrictions and therefore allowed to run * in Doze. */ public boolean canRunInDoze() { return (getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; } boolean canRunInBatterySaver() { return (getInternalFlags() & INTERNAL_FLAG_HAS_FOREGROUND_EXEMPTION) != 0; } boolean shouldIgnoreNetworkBlocking() { return (getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; } /** @return true if the constraint was changed, false otherwise. */ boolean setChargingConstraintSatisfied(boolean state) { return setConstraintSatisfied(CONSTRAINT_CHARGING, state); Loading Loading @@ -1086,7 +1102,7 @@ public final class JobStatus { dozeWhitelisted = whitelisted; if (setConstraintSatisfied(CONSTRAINT_DEVICE_NOT_DOZING, state)) { // The constraint was changed. Update the ready flag. mReadyNotDozing = state || (job.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; mReadyNotDozing = state || canRunInDoze(); return true; } return false; Loading Loading @@ -1771,9 +1787,11 @@ public final class JobStatus { pw.print(prefix); pw.print(" readyDeadlineSatisfied: "); pw.println(mReadyDeadlineSatisfied); } if (mDynamicConstraints != 0) { pw.print(prefix); pw.print(" readyDynamicSatisfied: "); pw.println(mReadyDynamicSatisfied); } pw.print(prefix); pw.print(" readyComponentEnabled: "); pw.println(serviceInfo != null); Loading Loading
apex/jobscheduler/framework/java/android/app/job/JobServiceEngine.java +1 −5 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.app.job; import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.Handler; import android.os.IBinder; Loading @@ -26,8 +25,6 @@ import android.os.Message; import android.os.RemoteException; import android.util.Log; import com.android.internal.annotations.GuardedBy; import java.lang.ref.WeakReference; /** Loading Loading @@ -206,8 +203,7 @@ public abstract class JobServiceEngine { /** * Call in to engine to report that a job has finished executing. See * {@link JobService#jobFinished(JobParameters, boolean)} JobService.jobFinished} for more * information. * {@link JobService#jobFinished(JobParameters, boolean)} for more information. */ public void jobFinished(JobParameters params, boolean needsReschedule) { if (params == null) { Loading
apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -1054,6 +1054,7 @@ public class JobSchedulerService extends com.android.server.SystemService public int scheduleAsPackage(JobInfo job, JobWorkItem work, int uId, String packageName, int userId, String tag) { // Rate limit excessive schedule() calls. final String servicePkg = job.getService().getPackageName(); if (job.isPersisted() && (packageName == null || packageName.equals(servicePkg))) { // Only limit schedule calls for persisted jobs scheduled by the app itself. Loading Loading @@ -1358,8 +1359,7 @@ public class JobSchedulerService extends com.android.server.SystemService for (int i=0; i<mActiveServices.size(); i++) { JobServiceContext jsc = mActiveServices.get(i); final JobStatus executing = jsc.getRunningJobLocked(); if (executing != null && (executing.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0) { if (executing != null && !executing.canRunInDoze()) { jsc.cancelExecutingJobLocked(JobParameters.REASON_DEVICE_IDLE, "cancelled due to doze"); } Loading Loading @@ -1411,7 +1411,7 @@ public class JobSchedulerService extends com.android.server.SystemService final JobServiceContext jsc = mActiveServices.get(i); final JobStatus job = jsc.getRunningJobLocked(); if (job != null && (job.getJob().getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0 && !job.canRunInDoze() && !job.dozeWhitelisted && !job.uidActive) { // We will report active if we have a job running and it is not an exception Loading
apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java +1 −2 Original line number Diff line number Diff line Loading @@ -189,8 +189,7 @@ public final class BackgroundJobsController extends StateController { final String packageName = jobStatus.getSourcePackageName(); final boolean canRun = !mAppStateTracker.areJobsRestricted(uid, packageName, (jobStatus.getInternalFlags() & JobStatus.INTERNAL_FLAG_HAS_FOREGROUND_EXEMPTION) != 0); jobStatus.canRunInBatterySaver()); final boolean isActive; if (activeState == UNKNOWN) { Loading
apex/jobscheduler/service/java/com/android/server/job/controllers/ConnectivityController.java +1 −1 Original line number Diff line number Diff line Loading @@ -464,7 +464,7 @@ public final class ConnectivityController extends RestrictingController implemen NetworkCapabilities capabilities) { // TODO: consider matching against non-active networks final boolean ignoreBlocked = (jobStatus.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; final boolean ignoreBlocked = jobStatus.shouldIgnoreNetworkBlocking(); final NetworkInfo info = mConnManager.getNetworkInfoForUid(network, jobStatus.getSourceUid(), ignoreBlocked); Loading
apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java +23 −5 Original line number Diff line number Diff line Loading @@ -470,7 +470,7 @@ public final class JobStatus { } this.requiredConstraints = requiredConstraints; mRequiredConstraintsOfInterest = requiredConstraints & CONSTRAINTS_OF_INTEREST; mReadyNotDozing = (job.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; mReadyNotDozing = canRunInDoze(); if (standbyBucket == RESTRICTED_INDEX) { addDynamicConstraints(DYNAMIC_RESTRICTED_CONSTRAINTS); } else { Loading Loading @@ -1036,6 +1036,22 @@ public final class JobStatus { mPersistedUtcTimes = null; } /** * @return true if the job is exempted from Doze restrictions and therefore allowed to run * in Doze. */ public boolean canRunInDoze() { return (getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; } boolean canRunInBatterySaver() { return (getInternalFlags() & INTERNAL_FLAG_HAS_FOREGROUND_EXEMPTION) != 0; } boolean shouldIgnoreNetworkBlocking() { return (getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; } /** @return true if the constraint was changed, false otherwise. */ boolean setChargingConstraintSatisfied(boolean state) { return setConstraintSatisfied(CONSTRAINT_CHARGING, state); Loading Loading @@ -1086,7 +1102,7 @@ public final class JobStatus { dozeWhitelisted = whitelisted; if (setConstraintSatisfied(CONSTRAINT_DEVICE_NOT_DOZING, state)) { // The constraint was changed. Update the ready flag. mReadyNotDozing = state || (job.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0; mReadyNotDozing = state || canRunInDoze(); return true; } return false; Loading Loading @@ -1771,9 +1787,11 @@ public final class JobStatus { pw.print(prefix); pw.print(" readyDeadlineSatisfied: "); pw.println(mReadyDeadlineSatisfied); } if (mDynamicConstraints != 0) { pw.print(prefix); pw.print(" readyDynamicSatisfied: "); pw.println(mReadyDynamicSatisfied); } pw.print(prefix); pw.print(" readyComponentEnabled: "); pw.println(serviceInfo != null); Loading