Fields Summary |
---|
private static final String | TAG |
private static final boolean | DEBUG |
private static final int | MAX_OPS_BEFORE_WRITEThreshold to adjust how often we want to write to the db. |
final android.util.ArraySet | mJobSet |
final android.content.Context | mContext |
private int | mDirtyOperations |
private static final Object | sSingletonLock |
private final android.util.AtomicFile | mJobsFile |
private final android.os.Handler | mIoHandlerHandler backed by IoThread for writing to disk. |
private static JobStore | sSingleton |
private static final int | JOBS_FILE_VERSIONVersion of the db schema. |
private static final String | XML_TAG_PARAMS_CONSTRAINTSTag corresponds to constraints this job needs. |
private static final String | XML_TAG_PERIODICTag corresponds to execution parameters. |
private static final String | XML_TAG_ONEOFF |
private static final String | XML_TAG_EXTRAS |
Methods Summary |
---|
public boolean | add(com.android.server.job.controllers.JobStatus jobStatus)Add a job to the master list, persisting it if necessary. If the JobStatus already exists,
it will be replaced.
boolean replaced = mJobSet.remove(jobStatus);
mJobSet.add(jobStatus);
if (jobStatus.isPersisted()) {
maybeWriteStatusToDiskAsync();
}
if (DEBUG) {
Slog.d(TAG, "Added job status to store: " + jobStatus);
}
return replaced;
|
public void | clear()
mJobSet.clear();
maybeWriteStatusToDiskAsync();
|
boolean | containsJob(com.android.server.job.controllers.JobStatus jobStatus)
return mJobSet.contains(jobStatus);
|
public boolean | containsJobIdForUid(int jobId, int uId)Whether this jobStatus object already exists in the JobStore.
for (int i=mJobSet.size()-1; i>=0; i--) {
JobStatus ts = mJobSet.valueAt(i);
if (ts.getUid() == uId && ts.getJobId() == jobId) {
return true;
}
}
return false;
|
public com.android.server.job.controllers.JobStatus | getJobByUidAndJobId(int uid, int jobId)
Iterator<JobStatus> it = mJobSet.iterator();
while (it.hasNext()) {
JobStatus ts = it.next();
if (ts.getUid() == uid && ts.getJobId() == jobId) {
return ts;
}
}
return null;
|
public android.util.ArraySet | getJobs()
return mJobSet;
|
public java.util.List | getJobsByUid(int uid)
List<JobStatus> matchingJobs = new ArrayList<JobStatus>();
Iterator<JobStatus> it = mJobSet.iterator();
while (it.hasNext()) {
JobStatus ts = it.next();
if (ts.getUid() == uid) {
matchingJobs.add(ts);
}
}
return matchingJobs;
|
public java.util.List | getJobsByUser(int userHandle)
List<JobStatus> matchingJobs = new ArrayList<JobStatus>();
Iterator<JobStatus> it = mJobSet.iterator();
while (it.hasNext()) {
JobStatus ts = it.next();
if (UserHandle.getUserId(ts.getUid()) == userHandle) {
matchingJobs.add(ts);
}
}
return matchingJobs;
|
static com.android.server.job.JobStore | initAndGet(JobSchedulerService jobManagerService)Used by the {@link JobSchedulerService} to instantiate the JobStore.
synchronized (sSingletonLock) {
if (sSingleton == null) {
sSingleton = new JobStore(jobManagerService.getContext(),
Environment.getDataDirectory());
}
return sSingleton;
}
|
public static com.android.server.job.JobStore | initAndGetForTesting(android.content.Context context, java.io.File dataDir)
JobStore jobStoreUnderTest = new JobStore(context, dataDir);
jobStoreUnderTest.clear();
return jobStoreUnderTest;
|
private void | maybeWriteStatusToDiskAsync()Every time the state changes we write all the jobs in one swath, instead of trying to
track incremental changes.
mDirtyOperations++;
if (mDirtyOperations >= MAX_OPS_BEFORE_WRITE) {
if (DEBUG) {
Slog.v(TAG, "Writing jobs to disk.");
}
mIoHandler.post(new WriteJobsMapToDiskRunnable());
}
|
public void | readJobMapFromDisk(android.util.ArraySet jobSet)
new ReadJobMapFromDiskRunnable(jobSet).run();
|
public boolean | remove(com.android.server.job.controllers.JobStatus jobStatus)Remove the provided job. Will also delete the job if it was persisted.
boolean removed = mJobSet.remove(jobStatus);
if (!removed) {
if (DEBUG) {
Slog.d(TAG, "Couldn't remove job: didn't exist: " + jobStatus);
}
return false;
}
if (jobStatus.isPersisted()) {
maybeWriteStatusToDiskAsync();
}
return removed;
|
public int | size()
return mJobSet.size();
|