use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by AOSPA.
the class JobSchedulerService method noteJobsPending.
void noteJobsPending(List<JobStatus> jobs) {
for (int i = jobs.size() - 1; i >= 0; i--) {
JobStatus job = jobs.get(i);
mJobPackageTracker.notePending(job);
}
}
use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by AOSPA.
the class JobSchedulerService method scheduleAsPackage.
public int scheduleAsPackage(JobInfo job, int uId, String packageName, int userId, String tag) {
JobStatus jobStatus = JobStatus.createFromJobInfo(job, uId, packageName, userId, tag);
try {
if (ActivityManagerNative.getDefault().getAppStartMode(uId, job.getService().getPackageName()) == ActivityManager.APP_START_MODE_DISABLED) {
Slog.w(TAG, "Not scheduling job " + uId + ":" + job.toString() + " -- package not allowed to start");
return JobScheduler.RESULT_FAILURE;
}
} catch (RemoteException e) {
}
if (DEBUG)
Slog.d(TAG, "SCHEDULE: " + jobStatus.toShortString());
JobStatus toCancel;
synchronized (mLock) {
// Jobs on behalf of others don't apply to the per-app job cap
if (ENFORCE_MAX_JOBS && packageName == null) {
if (mJobs.countJobsForUid(uId) > MAX_JOBS_PER_APP) {
Slog.w(TAG, "Too many jobs for uid " + uId);
throw new IllegalStateException("Apps may not schedule more than " + MAX_JOBS_PER_APP + " distinct jobs");
}
}
toCancel = mJobs.getJobByUidAndJobId(uId, job.getId());
if (toCancel != null) {
cancelJobImpl(toCancel, jobStatus);
}
startTrackingJob(jobStatus, toCancel);
}
mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
return JobScheduler.RESULT_SUCCESS;
}
use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by AOSPA.
the class JobSchedulerService method reportActive.
void reportActive() {
// active is true if pending queue contains jobs OR some job is running.
boolean active = mPendingJobs.size() > 0;
if (mPendingJobs.size() <= 0) {
for (int i = 0; i < mActiveServices.size(); i++) {
final JobServiceContext jsc = mActiveServices.get(i);
final JobStatus job = jsc.getRunningJob();
if (job != null && (job.getJob().getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0 && !job.dozeWhitelisted) {
// We will report active if we have a job running and it is not an exception
// due to being in the foreground or whitelisted.
active = true;
break;
}
}
}
if (mReportedActive != active) {
mReportedActive = active;
if (mLocalDeviceIdleController != null) {
mLocalDeviceIdleController.setJobsActive(active);
}
}
}
use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by AOSPA.
the class JobSchedulerService method executeRunCommand.
// Shell command infrastructure: run the given job immediately
int executeRunCommand(String pkgName, int userId, int jobId, boolean force) {
if (DEBUG) {
Slog.v(TAG, "executeRunCommand(): " + pkgName + "/" + userId + " " + jobId + " f=" + force);
}
try {
final int uid = AppGlobals.getPackageManager().getPackageUid(pkgName, 0, userId);
if (uid < 0) {
return JobSchedulerShellCommand.CMD_ERR_NO_PACKAGE;
}
synchronized (mLock) {
final JobStatus js = mJobs.getJobByUidAndJobId(uid, jobId);
if (js == null) {
return JobSchedulerShellCommand.CMD_ERR_NO_JOB;
}
js.overrideState = (force) ? JobStatus.OVERRIDE_FULL : JobStatus.OVERRIDE_SOFT;
if (!js.isConstraintsSatisfied()) {
js.overrideState = 0;
return JobSchedulerShellCommand.CMD_ERR_CONSTRAINTS;
}
mHandler.obtainMessage(MSG_CHECK_JOB_GREEDY).sendToTarget();
}
} catch (RemoteException e) {
// can't happen
}
return 0;
}
use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by AOSPA.
the class JobSchedulerService method getPendingJobs.
public List<JobInfo> getPendingJobs(int uid) {
synchronized (mLock) {
List<JobStatus> jobs = mJobs.getJobsByUid(uid);
ArrayList<JobInfo> outList = new ArrayList<JobInfo>(jobs.size());
for (int i = jobs.size() - 1; i >= 0; i--) {
JobStatus job = jobs.get(i);
outList.add(job.getJob());
}
return outList;
}
}
Aggregations