Search in sources :

Example 91 with JobStatus

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);
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus)

Example 92 with JobStatus

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;
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) RemoteException(android.os.RemoteException)

Example 93 with JobStatus

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);
        }
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus)

Example 94 with JobStatus

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;
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) RemoteException(android.os.RemoteException)

Example 95 with JobStatus

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;
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) JobInfo(android.app.job.JobInfo) ArrayList(java.util.ArrayList)

Aggregations

JobStatus (com.android.server.job.controllers.JobStatus)122 JobInfo (android.app.job.JobInfo)42 Builder (android.app.job.JobInfo.Builder)32 JobSet (com.android.server.job.JobStore.JobSet)32 RemoteException (android.os.RemoteException)25 StateController (com.android.server.job.controllers.StateController)10 IntentFilter (android.content.IntentFilter)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 PowerManager (android.os.PowerManager)5 WorkSource (android.os.WorkSource)5 DeviceIdleController (com.android.server.DeviceIdleController)5 JobStatusFunctor (com.android.server.job.JobStore.JobStatusFunctor)5 ArrayList (java.util.ArrayList)5 PersistableBundle (android.os.PersistableBundle)4