Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5683,6 +5683,7 @@ package android.app.job { method public int describeContents(); method public android.os.PersistableBundle getExtras(); method public int getJobId(); method public boolean isOverrideDeadlineExpired(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } core/java/android/app/job/JobParameters.java +16 −1 Original line number Diff line number Diff line Loading @@ -32,12 +32,15 @@ public class JobParameters implements Parcelable { private final int jobId; private final PersistableBundle extras; private final IBinder callback; private final boolean overrideDeadlineExpired; /** @hide */ public JobParameters(int jobId, PersistableBundle extras, IBinder callback) { public JobParameters(IBinder callback, int jobId, PersistableBundle extras, boolean overrideDeadlineExpired) { this.jobId = jobId; this.extras = extras; this.callback = callback; this.overrideDeadlineExpired = overrideDeadlineExpired; } /** Loading @@ -56,6 +59,16 @@ public class JobParameters implements Parcelable { return extras; } /** * For jobs with {@link android.app.job.JobInfo.Builder#setOverrideDeadline(long)} set, this * provides an easy way to tell whether the job is being executed due to the deadline * expiring. Note: If the job is running because its deadline expired, it implies that its * constraints will not be met. */ public boolean isOverrideDeadlineExpired() { return overrideDeadlineExpired; } /** @hide */ public IJobCallback getCallback() { return IJobCallback.Stub.asInterface(callback); Loading @@ -65,6 +78,7 @@ public class JobParameters implements Parcelable { jobId = in.readInt(); extras = in.readPersistableBundle(); callback = in.readStrongBinder(); overrideDeadlineExpired = in.readInt() == 1; } @Override Loading @@ -77,6 +91,7 @@ public class JobParameters implements Parcelable { dest.writeInt(jobId); dest.writePersistableBundle(extras); dest.writeStrongBinder(callback); dest.writeInt(overrideDeadlineExpired ? 1 : 0); } public static final Creator<JobParameters> CREATOR = new Creator<JobParameters>() { Loading services/core/java/com/android/server/job/JobServiceContext.java +2 −1 Original line number Diff line number Diff line Loading @@ -153,7 +153,8 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne } mRunningJob = job; mParams = new JobParameters(job.getJobId(), job.getExtras(), this); mParams = new JobParameters(this, job.getJobId(), job.getExtras(), !job.isConstraintsSatisfied()); mExecutionStartTimeElapsed = SystemClock.elapsedRealtime(); mVerb = VERB_BINDING; Loading services/core/java/com/android/server/job/controllers/JobStatus.java +11 −4 Original line number Diff line number Diff line Loading @@ -195,16 +195,23 @@ public class JobStatus { } /** * @return Whether or not this job is ready to run, based on its requirements. * @return Whether or not this job is ready to run, based on its requirements. This is true if * the constraints are satisfied <strong>or</strong> the deadline on the job has expired. */ public synchronized boolean isReady() { return isConstraintsSatisfied() || (hasDeadlineConstraint() && deadlineConstraintSatisfied.get()); } /** * @return Whether the constraints set on this job are satisfied. */ public synchronized boolean isConstraintsSatisfied() { return (!hasChargingConstraint() || chargingConstraintSatisfied.get()) && (!hasTimingDelayConstraint() || timeDelayConstraintSatisfied.get()) && (!hasConnectivityConstraint() || connectivityConstraintSatisfied.get()) && (!hasUnmeteredConstraint() || unmeteredConstraintSatisfied.get()) && (!hasIdleConstraint() || idleConstraintSatisfied.get()) // Also ready if the deadline has expired - special case. || (hasDeadlineConstraint() && deadlineConstraintSatisfied.get()); && (!hasIdleConstraint() || idleConstraintSatisfied.get()); } public boolean matches(int uid, int jobId) { Loading tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java +8 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.Messenger; import android.os.RemoteException; import android.util.Log; import android.util.SparseArray; import android.widget.Toast; import com.android.demo.jobSchedulerApp.MainActivity; Loading Loading @@ -84,12 +85,15 @@ public class TestJobService extends JobService { currentId++; jobParamsMap.put(currentId, params); final int currId = this.currentId; Log.d(TAG, "putting :" + currId + " for " + params.toString()); Log.d(TAG, " pulled: " + jobParamsMap.get(currId)); if (mActivity != null) { mActivity.onReceivedStartJob(params); } Toast.makeText( this, "On start job: '" + params.getJobId() + "' deadline exceeded: " + params.isOverrideDeadlineExpired(), Toast.LENGTH_LONG).show(); return true; } Loading @@ -100,7 +104,7 @@ public class TestJobService extends JobService { int ind = jobParamsMap.indexOfValue(params); jobParamsMap.remove(ind); mActivity.onReceivedStopJob(); return true; return false; // no reschedule } static int currentId = 0; Loading Loading @@ -129,6 +133,7 @@ public class TestJobService extends JobService { return false; } else { jobFinished(params, false); jobParamsMap.removeAt(0); return true; } } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5683,6 +5683,7 @@ package android.app.job { method public int describeContents(); method public android.os.PersistableBundle getExtras(); method public int getJobId(); method public boolean isOverrideDeadlineExpired(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; }
core/java/android/app/job/JobParameters.java +16 −1 Original line number Diff line number Diff line Loading @@ -32,12 +32,15 @@ public class JobParameters implements Parcelable { private final int jobId; private final PersistableBundle extras; private final IBinder callback; private final boolean overrideDeadlineExpired; /** @hide */ public JobParameters(int jobId, PersistableBundle extras, IBinder callback) { public JobParameters(IBinder callback, int jobId, PersistableBundle extras, boolean overrideDeadlineExpired) { this.jobId = jobId; this.extras = extras; this.callback = callback; this.overrideDeadlineExpired = overrideDeadlineExpired; } /** Loading @@ -56,6 +59,16 @@ public class JobParameters implements Parcelable { return extras; } /** * For jobs with {@link android.app.job.JobInfo.Builder#setOverrideDeadline(long)} set, this * provides an easy way to tell whether the job is being executed due to the deadline * expiring. Note: If the job is running because its deadline expired, it implies that its * constraints will not be met. */ public boolean isOverrideDeadlineExpired() { return overrideDeadlineExpired; } /** @hide */ public IJobCallback getCallback() { return IJobCallback.Stub.asInterface(callback); Loading @@ -65,6 +78,7 @@ public class JobParameters implements Parcelable { jobId = in.readInt(); extras = in.readPersistableBundle(); callback = in.readStrongBinder(); overrideDeadlineExpired = in.readInt() == 1; } @Override Loading @@ -77,6 +91,7 @@ public class JobParameters implements Parcelable { dest.writeInt(jobId); dest.writePersistableBundle(extras); dest.writeStrongBinder(callback); dest.writeInt(overrideDeadlineExpired ? 1 : 0); } public static final Creator<JobParameters> CREATOR = new Creator<JobParameters>() { Loading
services/core/java/com/android/server/job/JobServiceContext.java +2 −1 Original line number Diff line number Diff line Loading @@ -153,7 +153,8 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne } mRunningJob = job; mParams = new JobParameters(job.getJobId(), job.getExtras(), this); mParams = new JobParameters(this, job.getJobId(), job.getExtras(), !job.isConstraintsSatisfied()); mExecutionStartTimeElapsed = SystemClock.elapsedRealtime(); mVerb = VERB_BINDING; Loading
services/core/java/com/android/server/job/controllers/JobStatus.java +11 −4 Original line number Diff line number Diff line Loading @@ -195,16 +195,23 @@ public class JobStatus { } /** * @return Whether or not this job is ready to run, based on its requirements. * @return Whether or not this job is ready to run, based on its requirements. This is true if * the constraints are satisfied <strong>or</strong> the deadline on the job has expired. */ public synchronized boolean isReady() { return isConstraintsSatisfied() || (hasDeadlineConstraint() && deadlineConstraintSatisfied.get()); } /** * @return Whether the constraints set on this job are satisfied. */ public synchronized boolean isConstraintsSatisfied() { return (!hasChargingConstraint() || chargingConstraintSatisfied.get()) && (!hasTimingDelayConstraint() || timeDelayConstraintSatisfied.get()) && (!hasConnectivityConstraint() || connectivityConstraintSatisfied.get()) && (!hasUnmeteredConstraint() || unmeteredConstraintSatisfied.get()) && (!hasIdleConstraint() || idleConstraintSatisfied.get()) // Also ready if the deadline has expired - special case. || (hasDeadlineConstraint() && deadlineConstraintSatisfied.get()); && (!hasIdleConstraint() || idleConstraintSatisfied.get()); } public boolean matches(int uid, int jobId) { Loading
tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java +8 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.Messenger; import android.os.RemoteException; import android.util.Log; import android.util.SparseArray; import android.widget.Toast; import com.android.demo.jobSchedulerApp.MainActivity; Loading Loading @@ -84,12 +85,15 @@ public class TestJobService extends JobService { currentId++; jobParamsMap.put(currentId, params); final int currId = this.currentId; Log.d(TAG, "putting :" + currId + " for " + params.toString()); Log.d(TAG, " pulled: " + jobParamsMap.get(currId)); if (mActivity != null) { mActivity.onReceivedStartJob(params); } Toast.makeText( this, "On start job: '" + params.getJobId() + "' deadline exceeded: " + params.isOverrideDeadlineExpired(), Toast.LENGTH_LONG).show(); return true; } Loading @@ -100,7 +104,7 @@ public class TestJobService extends JobService { int ind = jobParamsMap.indexOfValue(params); jobParamsMap.remove(ind); mActivity.onReceivedStopJob(); return true; return false; // no reschedule } static int currentId = 0; Loading Loading @@ -129,6 +133,7 @@ public class TestJobService extends JobService { return false; } else { jobFinished(params, false); jobParamsMap.removeAt(0); return true; } } Loading