FileDocCategorySizeDatePackage
IdleController.javaAPI DocAndroid 5.1 API7250Thu Mar 12 22:22:42 GMT 2015com.android.server.job.controllers

IdleController

public class IdleController extends StateController

Fields Summary
private static final String
TAG
private static final long
INACTIVITY_IDLE_THRESHOLD
private static final long
IDLE_WINDOW_SLOP
private static final String
ACTION_TRIGGER_IDLE
final ArrayList
mTrackedTasks
IdlenessTracker
mIdleTracker
private static Object
sCreationLock
private static volatile IdleController
sController
Constructors Summary
private IdleController(com.android.server.job.StateChangedListener stateChangedListener, android.content.Context context)

        super(stateChangedListener, context);
        initIdleStateTracking();
    
Methods Summary
public voiddumpControllerState(java.io.PrintWriter pw)

        synchronized (mTrackedTasks) {
            pw.print("Idle: ");
            pw.println(mIdleTracker.isIdle() ? "true" : "false");
            pw.println(mTrackedTasks.size());
            for (int i = 0; i < mTrackedTasks.size(); i++) {
                final JobStatus js = mTrackedTasks.get(i);
                pw.print("  ");
                pw.print(String.valueOf(js.hashCode()).substring(0, 3));
                pw.println("..");
            }
        }
    
public static com.android.server.job.controllers.IdleControllerget(com.android.server.job.JobSchedulerService service)


         
        synchronized (sCreationLock) {
            if (sController == null) {
                sController = new IdleController(service, service.getContext());
            }
            return sController;
        }
    
private voidinitIdleStateTracking()
Idle state tracking, and messaging with the task manager when significant state changes occur

        mIdleTracker = new IdlenessTracker();
        mIdleTracker.startTracking();
    
public voidmaybeStartTrackingJob(JobStatus taskStatus)
StateController interface

        if (taskStatus.hasIdleConstraint()) {
            synchronized (mTrackedTasks) {
                mTrackedTasks.add(taskStatus);
                taskStatus.idleConstraintSatisfied.set(mIdleTracker.isIdle());
            }
        }
    
public voidmaybeStopTrackingJob(JobStatus taskStatus)

        synchronized (mTrackedTasks) {
            mTrackedTasks.remove(taskStatus);
        }
    
voidreportNewIdleState(boolean isIdle)
Interaction with the task manager service

        synchronized (mTrackedTasks) {
            for (JobStatus task : mTrackedTasks) {
                task.idleConstraintSatisfied.set(isIdle);
            }
        }
        mStateChangedListener.onControllerStateChanged();