Fields Summary |
---|
public static final long | NO_LATEST_RUNTIME |
public static final long | NO_EARLIEST_RUNTIME |
final android.app.job.JobInfo | job |
final int | uIdUid of the package requesting this job. |
final String | name |
final String | tag |
final AtomicBoolean | chargingConstraintSatisfied |
final AtomicBoolean | timeDelayConstraintSatisfied |
final AtomicBoolean | deadlineConstraintSatisfied |
final AtomicBoolean | idleConstraintSatisfied |
final AtomicBoolean | unmeteredConstraintSatisfied |
final AtomicBoolean | connectivityConstraintSatisfied |
private long | earliestRunTimeElapsedMillisEarliest point in the future at which this job will be eligible to run. A value of 0
indicates there is no delay constraint. See {@link #hasTimingDelayConstraint()}. |
private long | latestRunTimeElapsedMillisLatest point in the future at which this job must be run. A value of {@link Long#MAX_VALUE}
indicates there is no deadline constraint. See {@link #hasDeadlineConstraint()}. |
private final int | numFailuresHow many times this job has failed, used to compute back-off. |
Constructors Summary |
---|
private JobStatus(android.app.job.JobInfo job, int uId, int numFailures)
this.job = job;
this.uId = uId;
this.name = job.getService().flattenToShortString();
this.tag = "*job*/" + this.name;
this.numFailures = numFailures;
|
public JobStatus(android.app.job.JobInfo job, int uId)Create a newly scheduled job.
this(job, uId, 0);
final long elapsedNow = SystemClock.elapsedRealtime();
if (job.isPeriodic()) {
earliestRunTimeElapsedMillis = elapsedNow;
latestRunTimeElapsedMillis = elapsedNow + job.getIntervalMillis();
} else {
earliestRunTimeElapsedMillis = job.hasEarlyConstraint() ?
elapsedNow + job.getMinLatencyMillis() : NO_EARLIEST_RUNTIME;
latestRunTimeElapsedMillis = job.hasLateConstraint() ?
elapsedNow + job.getMaxExecutionDelayMillis() : NO_LATEST_RUNTIME;
}
|
public JobStatus(android.app.job.JobInfo job, int uId, long earliestRunTimeElapsedMillis, long latestRunTimeElapsedMillis)Create a new JobStatus that was loaded from disk. We ignore the provided
{@link android.app.job.JobInfo} time criteria because we can load a persisted periodic job
from the {@link com.android.server.job.JobStore} and still want to respect its
wallclock runtime rather than resetting it on every boot.
We consider a freshly loaded job to no longer be in back-off.
this(job, uId, 0);
this.earliestRunTimeElapsedMillis = earliestRunTimeElapsedMillis;
this.latestRunTimeElapsedMillis = latestRunTimeElapsedMillis;
|
public JobStatus(JobStatus rescheduling, long newEarliestRuntimeElapsedMillis, long newLatestRuntimeElapsedMillis, int backoffAttempt)Create a new job to be rescheduled with the provided parameters.
this(rescheduling.job, rescheduling.getUid(), backoffAttempt);
earliestRunTimeElapsedMillis = newEarliestRuntimeElapsedMillis;
latestRunTimeElapsedMillis = newLatestRuntimeElapsedMillis;
|
Methods Summary |
---|
public void | dump(java.io.PrintWriter pw, java.lang.String prefix)
pw.print(prefix);
pw.println(this.toString());
|
private java.lang.String | formatRunTime(long runtime, long defaultValue)
if (runtime == defaultValue) {
return "none";
} else {
long elapsedNow = SystemClock.elapsedRealtime();
long nextRuntime = runtime - elapsedNow;
if (nextRuntime > 0) {
return DateUtils.formatElapsedTime(nextRuntime / 1000);
} else {
return "-" + DateUtils.formatElapsedTime(nextRuntime / -1000);
}
}
|
public long | getEarliestRunTime()
return earliestRunTimeElapsedMillis;
|
public android.os.PersistableBundle | getExtras()
return job.getExtras();
|
public android.app.job.JobInfo | getJob()
return job;
|
public int | getJobId()
return job.getId();
|
public long | getLatestRunTimeElapsed()
return latestRunTimeElapsedMillis;
|
public java.lang.String | getName()
return name;
|
public int | getNumFailures()
return numFailures;
|
public android.content.ComponentName | getServiceComponent()
return job.getService();
|
public int | getServiceToken()Provide a handle to the service that this job will be run on.
return uId;
|
public java.lang.String | getTag()
return tag;
|
public int | getUid()
return uId;
|
public int | getUserId()
return UserHandle.getUserId(uId);
|
public boolean | hasChargingConstraint()
return job.isRequireCharging();
|
public boolean | hasConnectivityConstraint()
return job.getNetworkType() == JobInfo.NETWORK_TYPE_ANY;
|
public boolean | hasDeadlineConstraint()
return latestRunTimeElapsedMillis != NO_LATEST_RUNTIME;
|
public boolean | hasIdleConstraint()
return job.isRequireDeviceIdle();
|
public boolean | hasTimingDelayConstraint()
return earliestRunTimeElapsedMillis != NO_EARLIEST_RUNTIME;
|
public boolean | hasUnmeteredConstraint()
return job.getNetworkType() == JobInfo.NETWORK_TYPE_UNMETERED;
|
public synchronized boolean | isConstraintsSatisfied()
return (!hasChargingConstraint() || chargingConstraintSatisfied.get())
&& (!hasTimingDelayConstraint() || timeDelayConstraintSatisfied.get())
&& (!hasConnectivityConstraint() || connectivityConstraintSatisfied.get())
&& (!hasUnmeteredConstraint() || unmeteredConstraintSatisfied.get())
&& (!hasIdleConstraint() || idleConstraintSatisfied.get());
|
public boolean | isPersisted()
return job.isPersisted();
|
public synchronized boolean | isReady()
return isConstraintsSatisfied()
|| (hasDeadlineConstraint() && deadlineConstraintSatisfied.get());
|
public boolean | matches(int uid, int jobId)
return this.job.getId() == jobId && this.uId == uid;
|
public java.lang.String | toShortString()Convenience function to identify a job uniquely without pulling all the data that
{@link #toString()} returns.
return job.getService().flattenToShortString() + " jId=" + job.getId() +
", u" + getUserId();
|
public java.lang.String | toString()
return String.valueOf(hashCode()).substring(0, 3) + ".."
+ ":[" + job.getService()
+ ",jId=" + job.getId()
+ ",u" + getUserId()
+ ",R=(" + formatRunTime(earliestRunTimeElapsedMillis, NO_EARLIEST_RUNTIME)
+ "," + formatRunTime(latestRunTimeElapsedMillis, NO_LATEST_RUNTIME) + ")"
+ ",N=" + job.getNetworkType() + ",C=" + job.isRequireCharging()
+ ",I=" + job.isRequireDeviceIdle() + ",F=" + numFailures
+ ",P=" + job.isPersisted()
+ (isReady() ? "(READY)" : "")
+ "]";
|