blob: 3c50102157f12a9ee8aa19b0d444f5aaaff26c86 [file] [log] [blame]
Christopher Tate7060b042014-06-09 19:50:00 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.server.job;
18
19import java.io.FileDescriptor;
20import java.io.PrintWriter;
21import java.util.ArrayList;
22import java.util.Iterator;
23import java.util.List;
24
Dianne Hackborn8ad2af72015-03-17 17:00:24 -070025import android.app.ActivityManager;
Christopher Tate5568f542014-06-18 13:53:31 -070026import android.app.AppGlobals;
Christopher Tate7060b042014-06-09 19:50:00 -070027import android.app.job.JobInfo;
28import android.app.job.JobScheduler;
29import android.app.job.JobService;
30import android.app.job.IJobScheduler;
31import android.content.BroadcastReceiver;
32import android.content.ComponentName;
33import android.content.Context;
34import android.content.Intent;
35import android.content.IntentFilter;
Christopher Tate5568f542014-06-18 13:53:31 -070036import android.content.pm.IPackageManager;
Christopher Tate7060b042014-06-09 19:50:00 -070037import android.content.pm.PackageManager;
Christopher Tate7060b042014-06-09 19:50:00 -070038import android.content.pm.ServiceInfo;
Dianne Hackbornfdb19562014-07-11 16:03:36 -070039import android.os.BatteryStats;
Christopher Tate7060b042014-06-09 19:50:00 -070040import android.os.Binder;
41import android.os.Handler;
42import android.os.Looper;
43import android.os.Message;
Dianne Hackborn88e98df2015-03-23 13:29:14 -070044import android.os.PowerManager;
Christopher Tate7060b042014-06-09 19:50:00 -070045import android.os.RemoteException;
Dianne Hackbornfdb19562014-07-11 16:03:36 -070046import android.os.ServiceManager;
Christopher Tate7060b042014-06-09 19:50:00 -070047import android.os.SystemClock;
48import android.os.UserHandle;
Dianne Hackbornfdb19562014-07-11 16:03:36 -070049import android.util.ArraySet;
Christopher Tate7060b042014-06-09 19:50:00 -070050import android.util.Slog;
51import android.util.SparseArray;
52
Dianne Hackbornfdb19562014-07-11 16:03:36 -070053import com.android.internal.app.IBatteryStats;
Amith Yamasanib0ff3222015-03-04 09:56:14 -080054import com.android.server.job.controllers.AppIdleController;
Christopher Tate7060b042014-06-09 19:50:00 -070055import com.android.server.job.controllers.BatteryController;
56import com.android.server.job.controllers.ConnectivityController;
57import com.android.server.job.controllers.IdleController;
58import com.android.server.job.controllers.JobStatus;
59import com.android.server.job.controllers.StateController;
60import com.android.server.job.controllers.TimeController;
61
Christopher Tate7060b042014-06-09 19:50:00 -070062/**
63 * Responsible for taking jobs representing work to be performed by a client app, and determining
64 * based on the criteria specified when that job should be run against the client application's
65 * endpoint.
66 * Implements logic for scheduling, and rescheduling jobs. The JobSchedulerService knows nothing
67 * about constraints, or the state of active jobs. It receives callbacks from the various
68 * controllers and completed jobs and operates accordingly.
69 *
70 * Note on locking: Any operations that manipulate {@link #mJobs} need to lock on that object.
71 * Any function with the suffix 'Locked' also needs to lock on {@link #mJobs}.
72 * @hide
73 */
74public class JobSchedulerService extends com.android.server.SystemService
Matthew Williams01ac45b2014-07-22 20:44:12 -070075 implements StateChangedListener, JobCompletedListener {
Matthew Williamsaa984312015-10-15 16:08:05 -070076 public static final boolean DEBUG = false;
Christopher Tate7060b042014-06-09 19:50:00 -070077 /** The number of concurrent jobs we run at one time. */
Dianne Hackborn8ad2af72015-03-17 17:00:24 -070078 private static final int MAX_JOB_CONTEXTS_COUNT
79 = ActivityManager.isLowRamDeviceStatic() ? 1 : 3;
Matthew Williamsbe0c4172014-08-06 18:14:16 -070080 static final String TAG = "JobSchedulerService";
Christopher Tate7060b042014-06-09 19:50:00 -070081 /** Master list of jobs. */
Dianne Hackbornfdb19562014-07-11 16:03:36 -070082 final JobStore mJobs;
Christopher Tate7060b042014-06-09 19:50:00 -070083
84 static final int MSG_JOB_EXPIRED = 0;
85 static final int MSG_CHECK_JOB = 1;
86
87 // Policy constants
88 /**
89 * Minimum # of idle jobs that must be ready in order to force the JMS to schedule things
90 * early.
91 */
Dianne Hackbornfdb19562014-07-11 16:03:36 -070092 static final int MIN_IDLE_COUNT = 1;
Christopher Tate7060b042014-06-09 19:50:00 -070093 /**
Matthew Williamsbe0c4172014-08-06 18:14:16 -070094 * Minimum # of charging jobs that must be ready in order to force the JMS to schedule things
95 * early.
96 */
97 static final int MIN_CHARGING_COUNT = 1;
98 /**
Christopher Tate7060b042014-06-09 19:50:00 -070099 * Minimum # of connectivity jobs that must be ready in order to force the JMS to schedule
100 * things early.
101 */
Matthew Williamsaa984312015-10-15 16:08:05 -0700102 static final int MIN_CONNECTIVITY_COUNT = 1; // Run connectivity jobs as soon as ready.
Christopher Tate7060b042014-06-09 19:50:00 -0700103 /**
104 * Minimum # of jobs (with no particular constraints) for which the JMS will be happy running
105 * some work early.
Matthew Williamsbe0c4172014-08-06 18:14:16 -0700106 * This is correlated with the amount of batching we'll be able to do.
Christopher Tate7060b042014-06-09 19:50:00 -0700107 */
Matthew Williamsbe0c4172014-08-06 18:14:16 -0700108 static final int MIN_READY_JOBS_COUNT = 2;
Christopher Tate7060b042014-06-09 19:50:00 -0700109
110 /**
111 * Track Services that have currently active or pending jobs. The index is provided by
112 * {@link JobStatus#getServiceToken()}
113 */
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700114 final List<JobServiceContext> mActiveServices = new ArrayList<>();
Christopher Tate7060b042014-06-09 19:50:00 -0700115 /** List of controllers that will notify this service of updates to jobs. */
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700116 List<StateController> mControllers;
Christopher Tate7060b042014-06-09 19:50:00 -0700117 /**
118 * Queue of pending jobs. The JobServiceContext class will receive jobs from this list
119 * when ready to execute them.
120 */
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700121 final ArrayList<JobStatus> mPendingJobs = new ArrayList<>();
Christopher Tate7060b042014-06-09 19:50:00 -0700122
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700123 final ArrayList<Integer> mStartedUsers = new ArrayList<>();
Matthew Williams9ae3dbe2014-08-21 13:47:47 -0700124
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700125 final JobHandler mHandler;
126 final JobSchedulerStub mJobSchedulerStub;
127
128 IBatteryStats mBatteryStats;
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700129 PowerManager mPowerManager;
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700130
131 /**
132 * Set to true once we are allowed to run third party apps.
133 */
134 boolean mReadyToRock;
135
Christopher Tate7060b042014-06-09 19:50:00 -0700136 /**
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700137 * True when in device idle mode, so we don't want to schedule any jobs.
138 */
139 boolean mDeviceIdleMode;
140
141 /**
Christopher Tate7060b042014-06-09 19:50:00 -0700142 * Cleans up outstanding jobs when a package is removed. Even if it's being replaced later we
143 * still clean up. On reinstall the package will have a new uid.
144 */
145 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
146 @Override
147 public void onReceive(Context context, Intent intent) {
148 Slog.d(TAG, "Receieved: " + intent.getAction());
149 if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
Christopher Tateaad67a32014-10-20 16:29:20 -0700150 // If this is an outright uninstall rather than the first half of an
151 // app update sequence, cancel the jobs associated with the app.
152 if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
153 int uidRemoved = intent.getIntExtra(Intent.EXTRA_UID, -1);
154 if (DEBUG) {
155 Slog.d(TAG, "Removing jobs for uid: " + uidRemoved);
156 }
157 cancelJobsForUid(uidRemoved);
Christopher Tate7060b042014-06-09 19:50:00 -0700158 }
Christopher Tate7060b042014-06-09 19:50:00 -0700159 } else if (Intent.ACTION_USER_REMOVED.equals(intent.getAction())) {
160 final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
161 if (DEBUG) {
162 Slog.d(TAG, "Removing jobs for user: " + userId);
163 }
164 cancelJobsForUser(userId);
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700165 } else if (PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED.equals(intent.getAction())) {
166 updateIdleMode(mPowerManager != null ? mPowerManager.isDeviceIdleMode() : false);
Christopher Tate7060b042014-06-09 19:50:00 -0700167 }
168 }
169 };
170
Matthew Williams9ae3dbe2014-08-21 13:47:47 -0700171 @Override
172 public void onStartUser(int userHandle) {
173 mStartedUsers.add(userHandle);
174 // Let's kick any outstanding jobs for this user.
175 mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
176 }
177
178 @Override
179 public void onStopUser(int userHandle) {
180 mStartedUsers.remove(Integer.valueOf(userHandle));
181 }
182
Christopher Tate7060b042014-06-09 19:50:00 -0700183 /**
184 * Entry point from client to schedule the provided job.
185 * This cancels the job if it's already been scheduled, and replaces it with the one provided.
186 * @param job JobInfo object containing execution parameters
187 * @param uId The package identifier of the application this job is for.
Christopher Tate7060b042014-06-09 19:50:00 -0700188 * @return Result of this operation. See <code>JobScheduler#RESULT_*</code> return codes.
189 */
Matthew Williams900c67f2014-07-09 12:46:53 -0700190 public int schedule(JobInfo job, int uId) {
191 JobStatus jobStatus = new JobStatus(job, uId);
Christopher Tate7060b042014-06-09 19:50:00 -0700192 cancelJob(uId, job.getId());
193 startTrackingJob(jobStatus);
Matthew Williamsbafeeb92014-08-08 11:51:06 -0700194 mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
Christopher Tate7060b042014-06-09 19:50:00 -0700195 return JobScheduler.RESULT_SUCCESS;
196 }
197
198 public List<JobInfo> getPendingJobs(int uid) {
199 ArrayList<JobInfo> outList = new ArrayList<JobInfo>();
200 synchronized (mJobs) {
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700201 ArraySet<JobStatus> jobs = mJobs.getJobs();
202 for (int i=0; i<jobs.size(); i++) {
203 JobStatus job = jobs.valueAt(i);
Christopher Tate7060b042014-06-09 19:50:00 -0700204 if (job.getUid() == uid) {
205 outList.add(job.getJob());
206 }
207 }
208 }
209 return outList;
210 }
211
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700212 void cancelJobsForUser(int userHandle) {
Matthew Williams48a30db2014-09-23 13:39:36 -0700213 List<JobStatus> jobsForUser;
Christopher Tate7060b042014-06-09 19:50:00 -0700214 synchronized (mJobs) {
Matthew Williams48a30db2014-09-23 13:39:36 -0700215 jobsForUser = mJobs.getJobsByUser(userHandle);
216 }
217 for (int i=0; i<jobsForUser.size(); i++) {
218 JobStatus toRemove = jobsForUser.get(i);
219 cancelJobImpl(toRemove);
Christopher Tate7060b042014-06-09 19:50:00 -0700220 }
221 }
222
223 /**
224 * Entry point from client to cancel all jobs originating from their uid.
225 * This will remove the job from the master list, and cancel the job if it was staged for
226 * execution or being executed.
Matthew Williams48a30db2014-09-23 13:39:36 -0700227 * @param uid Uid to check against for removal of a job.
Christopher Tate7060b042014-06-09 19:50:00 -0700228 */
229 public void cancelJobsForUid(int uid) {
Matthew Williams48a30db2014-09-23 13:39:36 -0700230 List<JobStatus> jobsForUid;
Christopher Tate7060b042014-06-09 19:50:00 -0700231 synchronized (mJobs) {
Matthew Williams48a30db2014-09-23 13:39:36 -0700232 jobsForUid = mJobs.getJobsByUid(uid);
233 }
234 for (int i=0; i<jobsForUid.size(); i++) {
235 JobStatus toRemove = jobsForUid.get(i);
236 cancelJobImpl(toRemove);
Christopher Tate7060b042014-06-09 19:50:00 -0700237 }
238 }
239
240 /**
241 * Entry point from client to cancel the job corresponding to the jobId provided.
242 * This will remove the job from the master list, and cancel the job if it was staged for
243 * execution or being executed.
244 * @param uid Uid of the calling client.
245 * @param jobId Id of the job, provided at schedule-time.
246 */
247 public void cancelJob(int uid, int jobId) {
248 JobStatus toCancel;
249 synchronized (mJobs) {
250 toCancel = mJobs.getJobByUidAndJobId(uid, jobId);
Matthew Williams48a30db2014-09-23 13:39:36 -0700251 }
252 if (toCancel != null) {
253 cancelJobImpl(toCancel);
Christopher Tate7060b042014-06-09 19:50:00 -0700254 }
255 }
256
Matthew Williams48a30db2014-09-23 13:39:36 -0700257 private void cancelJobImpl(JobStatus cancelled) {
Matthew Williamsee410da2014-07-25 11:30:40 -0700258 if (DEBUG) {
259 Slog.d(TAG, "Cancelling: " + cancelled);
260 }
Christopher Tate7060b042014-06-09 19:50:00 -0700261 stopTrackingJob(cancelled);
Matthew Williams48a30db2014-09-23 13:39:36 -0700262 synchronized (mJobs) {
263 // Remove from pending queue.
264 mPendingJobs.remove(cancelled);
265 // Cancel if running.
266 stopJobOnServiceContextLocked(cancelled);
267 }
Christopher Tate7060b042014-06-09 19:50:00 -0700268 }
269
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700270 void updateIdleMode(boolean enabled) {
271 boolean changed = false;
272 boolean rocking;
273 synchronized (mJobs) {
274 if (mDeviceIdleMode != enabled) {
275 changed = true;
276 }
277 rocking = mReadyToRock;
278 }
279 if (changed) {
280 if (rocking) {
281 for (int i=0; i<mControllers.size(); i++) {
282 mControllers.get(i).deviceIdleModeChanged(enabled);
283 }
284 }
285 synchronized (mJobs) {
286 mDeviceIdleMode = enabled;
287 if (enabled) {
288 // When becoming idle, make sure no jobs are actively running.
289 for (int i=0; i<mActiveServices.size(); i++) {
290 JobServiceContext jsc = mActiveServices.get(i);
291 final JobStatus executing = jsc.getRunningJob();
292 if (executing != null) {
293 jsc.cancelExecutingJob();
294 }
295 }
296 } else {
297 // When coming out of idle, allow thing to start back up.
298 mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
299 }
300 }
301 }
302 }
303
Christopher Tate7060b042014-06-09 19:50:00 -0700304 /**
305 * Initializes the system service.
306 * <p>
307 * Subclasses must define a single argument constructor that accepts the context
308 * and passes it to super.
309 * </p>
310 *
311 * @param context The system server context.
312 */
313 public JobSchedulerService(Context context) {
314 super(context);
315 // Create the controllers.
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700316 mControllers = new ArrayList<StateController>();
Christopher Tate7060b042014-06-09 19:50:00 -0700317 mControllers.add(ConnectivityController.get(this));
318 mControllers.add(TimeController.get(this));
319 mControllers.add(IdleController.get(this));
320 mControllers.add(BatteryController.get(this));
Amith Yamasanib0ff3222015-03-04 09:56:14 -0800321 mControllers.add(AppIdleController.get(this));
Christopher Tate7060b042014-06-09 19:50:00 -0700322
323 mHandler = new JobHandler(context.getMainLooper());
324 mJobSchedulerStub = new JobSchedulerStub();
Christopher Tate7060b042014-06-09 19:50:00 -0700325 mJobs = JobStore.initAndGet(this);
326 }
327
328 @Override
329 public void onStart() {
330 publishBinderService(Context.JOB_SCHEDULER_SERVICE, mJobSchedulerStub);
331 }
332
333 @Override
334 public void onBootPhase(int phase) {
335 if (PHASE_SYSTEM_SERVICES_READY == phase) {
336 // Register br for package removals and user removals.
337 final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_REMOVED);
338 filter.addDataScheme("package");
339 getContext().registerReceiverAsUser(
340 mBroadcastReceiver, UserHandle.ALL, filter, null, null);
341 final IntentFilter userFilter = new IntentFilter(Intent.ACTION_USER_REMOVED);
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700342 userFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
Christopher Tate7060b042014-06-09 19:50:00 -0700343 getContext().registerReceiverAsUser(
344 mBroadcastReceiver, UserHandle.ALL, userFilter, null, null);
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700345 mPowerManager = (PowerManager)getContext().getSystemService(Context.POWER_SERVICE);
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700346 } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
347 synchronized (mJobs) {
348 // Let's go!
349 mReadyToRock = true;
350 mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(
351 BatteryStats.SERVICE_NAME));
352 // Create the "runners".
353 for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) {
354 mActiveServices.add(
355 new JobServiceContext(this, mBatteryStats,
356 getContext().getMainLooper()));
357 }
358 // Attach jobs to their controllers.
359 ArraySet<JobStatus> jobs = mJobs.getJobs();
360 for (int i=0; i<jobs.size(); i++) {
361 JobStatus job = jobs.valueAt(i);
Christopher Tate4a79dae2014-07-18 17:01:40 -0700362 for (int controller=0; controller<mControllers.size(); controller++) {
Dianne Hackborn2bf51f42015-03-24 14:17:12 -0700363 mControllers.get(controller).deviceIdleModeChanged(mDeviceIdleMode);
Christopher Tate4a79dae2014-07-18 17:01:40 -0700364 mControllers.get(controller).maybeStartTrackingJob(job);
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700365 }
366 }
367 // GO GO GO!
368 mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
369 }
Christopher Tate7060b042014-06-09 19:50:00 -0700370 }
371 }
372
373 /**
374 * Called when we have a job status object that we need to insert in our
375 * {@link com.android.server.job.JobStore}, and make sure all the relevant controllers know
376 * about.
377 */
378 private void startTrackingJob(JobStatus jobStatus) {
379 boolean update;
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700380 boolean rocking;
Christopher Tate7060b042014-06-09 19:50:00 -0700381 synchronized (mJobs) {
382 update = mJobs.add(jobStatus);
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700383 rocking = mReadyToRock;
Christopher Tate7060b042014-06-09 19:50:00 -0700384 }
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700385 if (rocking) {
386 for (int i=0; i<mControllers.size(); i++) {
387 StateController controller = mControllers.get(i);
388 if (update) {
389 controller.maybeStopTrackingJob(jobStatus);
390 }
391 controller.maybeStartTrackingJob(jobStatus);
Christopher Tate7060b042014-06-09 19:50:00 -0700392 }
Christopher Tate7060b042014-06-09 19:50:00 -0700393 }
394 }
395
396 /**
397 * Called when we want to remove a JobStatus object that we've finished executing. Returns the
398 * object removed.
399 */
400 private boolean stopTrackingJob(JobStatus jobStatus) {
401 boolean removed;
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700402 boolean rocking;
Christopher Tate7060b042014-06-09 19:50:00 -0700403 synchronized (mJobs) {
404 // Remove from store as well as controllers.
405 removed = mJobs.remove(jobStatus);
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700406 rocking = mReadyToRock;
Christopher Tate7060b042014-06-09 19:50:00 -0700407 }
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700408 if (removed && rocking) {
409 for (int i=0; i<mControllers.size(); i++) {
410 StateController controller = mControllers.get(i);
Christopher Tate7060b042014-06-09 19:50:00 -0700411 controller.maybeStopTrackingJob(jobStatus);
412 }
413 }
414 return removed;
415 }
416
417 private boolean stopJobOnServiceContextLocked(JobStatus job) {
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700418 for (int i=0; i<mActiveServices.size(); i++) {
419 JobServiceContext jsc = mActiveServices.get(i);
Christopher Tate7060b042014-06-09 19:50:00 -0700420 final JobStatus executing = jsc.getRunningJob();
421 if (executing != null && executing.matches(job.getUid(), job.getJobId())) {
422 jsc.cancelExecutingJob();
423 return true;
424 }
425 }
426 return false;
427 }
428
429 /**
430 * @param job JobStatus we are querying against.
431 * @return Whether or not the job represented by the status object is currently being run or
432 * is pending.
433 */
434 private boolean isCurrentlyActiveLocked(JobStatus job) {
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700435 for (int i=0; i<mActiveServices.size(); i++) {
436 JobServiceContext serviceContext = mActiveServices.get(i);
Christopher Tate7060b042014-06-09 19:50:00 -0700437 final JobStatus running = serviceContext.getRunningJob();
438 if (running != null && running.matches(job.getUid(), job.getJobId())) {
439 return true;
440 }
441 }
442 return false;
443 }
444
445 /**
Matthew Williams1bde39a2015-10-07 14:29:30 -0700446 * Reschedules the given job based on the job's backoff policy. It doesn't make sense to
447 * specify an override deadline on a failed job (the failed job will run even though it's not
448 * ready), so we reschedule it with {@link JobStatus#NO_LATEST_RUNTIME}, but specify that any
449 * ready job with {@link JobStatus#numFailures} > 0 will be executed.
450 *
Christopher Tate7060b042014-06-09 19:50:00 -0700451 * @param failureToReschedule Provided job status that we will reschedule.
452 * @return A newly instantiated JobStatus with the same constraints as the last job except
453 * with adjusted timing constraints.
Matthew Williams1bde39a2015-10-07 14:29:30 -0700454 *
455 * @see JobHandler#maybeQueueReadyJobsForExecutionLockedH
Christopher Tate7060b042014-06-09 19:50:00 -0700456 */
457 private JobStatus getRescheduleJobForFailure(JobStatus failureToReschedule) {
458 final long elapsedNowMillis = SystemClock.elapsedRealtime();
459 final JobInfo job = failureToReschedule.getJob();
460
461 final long initialBackoffMillis = job.getInitialBackoffMillis();
Matthew Williamsd1c06752014-08-22 14:15:28 -0700462 final int backoffAttempts = failureToReschedule.getNumFailures() + 1;
463 long delayMillis;
Christopher Tate7060b042014-06-09 19:50:00 -0700464
465 switch (job.getBackoffPolicy()) {
Matthew Williamsd1c06752014-08-22 14:15:28 -0700466 case JobInfo.BACKOFF_POLICY_LINEAR:
467 delayMillis = initialBackoffMillis * backoffAttempts;
Christopher Tate7060b042014-06-09 19:50:00 -0700468 break;
469 default:
470 if (DEBUG) {
471 Slog.v(TAG, "Unrecognised back-off policy, defaulting to exponential.");
472 }
Matthew Williamsd1c06752014-08-22 14:15:28 -0700473 case JobInfo.BACKOFF_POLICY_EXPONENTIAL:
474 delayMillis =
475 (long) Math.scalb(initialBackoffMillis, backoffAttempts - 1);
Christopher Tate7060b042014-06-09 19:50:00 -0700476 break;
477 }
Matthew Williamsd1c06752014-08-22 14:15:28 -0700478 delayMillis =
479 Math.min(delayMillis, JobInfo.MAX_BACKOFF_DELAY_MILLIS);
480 return new JobStatus(failureToReschedule, elapsedNowMillis + delayMillis,
481 JobStatus.NO_LATEST_RUNTIME, backoffAttempts);
Christopher Tate7060b042014-06-09 19:50:00 -0700482 }
483
484 /**
Matthew Williams1bde39a2015-10-07 14:29:30 -0700485 * Called after a periodic has executed so we can reschedule it. We take the last execution
486 * time of the job to be the time of completion (i.e. the time at which this function is
487 * called).
Christopher Tate7060b042014-06-09 19:50:00 -0700488 * This could be inaccurate b/c the job can run for as long as
489 * {@link com.android.server.job.JobServiceContext#EXECUTING_TIMESLICE_MILLIS}, but will lead
490 * to underscheduling at least, rather than if we had taken the last execution time to be the
491 * start of the execution.
492 * @return A new job representing the execution criteria for this instantiation of the
493 * recurring job.
494 */
495 private JobStatus getRescheduleJobForPeriodic(JobStatus periodicToReschedule) {
496 final long elapsedNow = SystemClock.elapsedRealtime();
497 // Compute how much of the period is remaining.
Matthew Williams1bde39a2015-10-07 14:29:30 -0700498 long runEarly = 0L;
499
500 // If this periodic was rescheduled it won't have a deadline.
501 if (periodicToReschedule.hasDeadlineConstraint()) {
502 runEarly = Math.max(periodicToReschedule.getLatestRunTimeElapsed() - elapsedNow, 0L);
503 }
Christopher Tate7060b042014-06-09 19:50:00 -0700504 long newEarliestRunTimeElapsed = elapsedNow + runEarly;
505 long period = periodicToReschedule.getJob().getIntervalMillis();
506 long newLatestRuntimeElapsed = newEarliestRunTimeElapsed + period;
507
508 if (DEBUG) {
509 Slog.v(TAG, "Rescheduling executed periodic. New execution window [" +
510 newEarliestRunTimeElapsed/1000 + ", " + newLatestRuntimeElapsed/1000 + "]s");
511 }
512 return new JobStatus(periodicToReschedule, newEarliestRunTimeElapsed,
513 newLatestRuntimeElapsed, 0 /* backoffAttempt */);
514 }
515
516 // JobCompletedListener implementations.
517
518 /**
519 * A job just finished executing. We fetch the
520 * {@link com.android.server.job.controllers.JobStatus} from the store and depending on
521 * whether we want to reschedule we readd it to the controllers.
522 * @param jobStatus Completed job.
523 * @param needsReschedule Whether the implementing class should reschedule this job.
524 */
525 @Override
526 public void onJobCompleted(JobStatus jobStatus, boolean needsReschedule) {
527 if (DEBUG) {
528 Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule);
529 }
530 if (!stopTrackingJob(jobStatus)) {
531 if (DEBUG) {
Matthew Williamsee410da2014-07-25 11:30:40 -0700532 Slog.d(TAG, "Could not find job to remove. Was job removed while executing?");
Christopher Tate7060b042014-06-09 19:50:00 -0700533 }
534 return;
535 }
536 if (needsReschedule) {
537 JobStatus rescheduled = getRescheduleJobForFailure(jobStatus);
538 startTrackingJob(rescheduled);
539 } else if (jobStatus.getJob().isPeriodic()) {
540 JobStatus rescheduledPeriodic = getRescheduleJobForPeriodic(jobStatus);
541 startTrackingJob(rescheduledPeriodic);
542 }
543 mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
544 }
545
546 // StateChangedListener implementations.
547
548 /**
Matthew Williams48a30db2014-09-23 13:39:36 -0700549 * Posts a message to the {@link com.android.server.job.JobSchedulerService.JobHandler} that
550 * some controller's state has changed, so as to run through the list of jobs and start/stop
551 * any that are eligible.
Christopher Tate7060b042014-06-09 19:50:00 -0700552 */
553 @Override
554 public void onControllerStateChanged() {
Matthew Williams48a30db2014-09-23 13:39:36 -0700555 mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
Christopher Tate7060b042014-06-09 19:50:00 -0700556 }
557
558 @Override
559 public void onRunJobNow(JobStatus jobStatus) {
560 mHandler.obtainMessage(MSG_JOB_EXPIRED, jobStatus).sendToTarget();
561 }
562
Christopher Tate7060b042014-06-09 19:50:00 -0700563 private class JobHandler extends Handler {
564
565 public JobHandler(Looper looper) {
566 super(looper);
567 }
568
569 @Override
570 public void handleMessage(Message message) {
Matthew Williams48a30db2014-09-23 13:39:36 -0700571 synchronized (mJobs) {
572 if (!mReadyToRock) {
573 return;
574 }
575 }
Christopher Tate7060b042014-06-09 19:50:00 -0700576 switch (message.what) {
577 case MSG_JOB_EXPIRED:
578 synchronized (mJobs) {
579 JobStatus runNow = (JobStatus) message.obj;
Matthew Williamsbafeeb92014-08-08 11:51:06 -0700580 // runNow can be null, which is a controller's way of indicating that its
581 // state is such that all ready jobs should be run immediately.
Matthew Williams48a30db2014-09-23 13:39:36 -0700582 if (runNow != null && !mPendingJobs.contains(runNow)
583 && mJobs.containsJob(runNow)) {
Christopher Tate7060b042014-06-09 19:50:00 -0700584 mPendingJobs.add(runNow);
585 }
Matthew Williams48a30db2014-09-23 13:39:36 -0700586 queueReadyJobsForExecutionLockedH();
Christopher Tate7060b042014-06-09 19:50:00 -0700587 }
Christopher Tate7060b042014-06-09 19:50:00 -0700588 break;
589 case MSG_CHECK_JOB:
Matthew Williams48a30db2014-09-23 13:39:36 -0700590 synchronized (mJobs) {
591 // Check the list of jobs and run some of them if we feel inclined.
592 maybeQueueReadyJobsForExecutionLockedH();
593 }
Christopher Tate7060b042014-06-09 19:50:00 -0700594 break;
595 }
596 maybeRunPendingJobsH();
597 // Don't remove JOB_EXPIRED in case one came along while processing the queue.
598 removeMessages(MSG_CHECK_JOB);
599 }
600
601 /**
602 * Run through list of jobs and execute all possible - at least one is expired so we do
603 * as many as we can.
604 */
Matthew Williams48a30db2014-09-23 13:39:36 -0700605 private void queueReadyJobsForExecutionLockedH() {
606 ArraySet<JobStatus> jobs = mJobs.getJobs();
607 if (DEBUG) {
608 Slog.d(TAG, "queuing all ready jobs for execution:");
609 }
610 for (int i=0; i<jobs.size(); i++) {
611 JobStatus job = jobs.valueAt(i);
612 if (isReadyToBeExecutedLocked(job)) {
613 if (DEBUG) {
614 Slog.d(TAG, " queued " + job.toShortString());
Christopher Tate7060b042014-06-09 19:50:00 -0700615 }
Matthew Williams48a30db2014-09-23 13:39:36 -0700616 mPendingJobs.add(job);
617 } else if (isReadyToBeCancelledLocked(job)) {
618 stopJobOnServiceContextLocked(job);
Christopher Tate7060b042014-06-09 19:50:00 -0700619 }
Matthew Williams48a30db2014-09-23 13:39:36 -0700620 }
621 if (DEBUG) {
622 final int queuedJobs = mPendingJobs.size();
623 if (queuedJobs == 0) {
624 Slog.d(TAG, "No jobs pending.");
625 } else {
626 Slog.d(TAG, queuedJobs + " jobs queued.");
Matthew Williams75fc5252014-09-02 16:17:53 -0700627 }
Christopher Tate7060b042014-06-09 19:50:00 -0700628 }
629 }
630
631 /**
632 * The state of at least one job has changed. Here is where we could enforce various
633 * policies on when we want to execute jobs.
634 * Right now the policy is such:
635 * If >1 of the ready jobs is idle mode we send all of them off
636 * if more than 2 network connectivity jobs are ready we send them all off.
637 * If more than 4 jobs total are ready we send them all off.
638 * TODO: It would be nice to consolidate these sort of high-level policies somewhere.
639 */
Matthew Williams48a30db2014-09-23 13:39:36 -0700640 private void maybeQueueReadyJobsForExecutionLockedH() {
641 int chargingCount = 0;
642 int idleCount = 0;
643 int backoffCount = 0;
644 int connectivityCount = 0;
645 List<JobStatus> runnableJobs = new ArrayList<JobStatus>();
646 ArraySet<JobStatus> jobs = mJobs.getJobs();
647 for (int i=0; i<jobs.size(); i++) {
648 JobStatus job = jobs.valueAt(i);
649 if (isReadyToBeExecutedLocked(job)) {
650 if (job.getNumFailures() > 0) {
651 backoffCount++;
Christopher Tate7060b042014-06-09 19:50:00 -0700652 }
Matthew Williams48a30db2014-09-23 13:39:36 -0700653 if (job.hasIdleConstraint()) {
654 idleCount++;
655 }
656 if (job.hasConnectivityConstraint() || job.hasUnmeteredConstraint()) {
657 connectivityCount++;
658 }
659 if (job.hasChargingConstraint()) {
660 chargingCount++;
661 }
662 runnableJobs.add(job);
663 } else if (isReadyToBeCancelledLocked(job)) {
664 stopJobOnServiceContextLocked(job);
Christopher Tate7060b042014-06-09 19:50:00 -0700665 }
Matthew Williams48a30db2014-09-23 13:39:36 -0700666 }
667 if (backoffCount > 0 ||
668 idleCount >= MIN_IDLE_COUNT ||
669 connectivityCount >= MIN_CONNECTIVITY_COUNT ||
670 chargingCount >= MIN_CHARGING_COUNT ||
671 runnableJobs.size() >= MIN_READY_JOBS_COUNT) {
Matthew Williamsbe0c4172014-08-06 18:14:16 -0700672 if (DEBUG) {
Matthew Williams48a30db2014-09-23 13:39:36 -0700673 Slog.d(TAG, "maybeQueueReadyJobsForExecutionLockedH: Running jobs.");
Christopher Tate7060b042014-06-09 19:50:00 -0700674 }
Matthew Williams48a30db2014-09-23 13:39:36 -0700675 for (int i=0; i<runnableJobs.size(); i++) {
676 mPendingJobs.add(runnableJobs.get(i));
677 }
678 } else {
679 if (DEBUG) {
680 Slog.d(TAG, "maybeQueueReadyJobsForExecutionLockedH: Not running anything.");
681 }
682 }
683 if (DEBUG) {
684 Slog.d(TAG, "idle=" + idleCount + " connectivity=" +
685 connectivityCount + " charging=" + chargingCount + " tot=" +
686 runnableJobs.size());
Christopher Tate7060b042014-06-09 19:50:00 -0700687 }
688 }
689
690 /**
691 * Criteria for moving a job into the pending queue:
692 * - It's ready.
693 * - It's not pending.
694 * - It's not already running on a JSC.
Matthew Williams9ae3dbe2014-08-21 13:47:47 -0700695 * - The user that requested the job is running.
Christopher Tate7060b042014-06-09 19:50:00 -0700696 */
697 private boolean isReadyToBeExecutedLocked(JobStatus job) {
Matthew Williams9ae3dbe2014-08-21 13:47:47 -0700698 final boolean jobReady = job.isReady();
699 final boolean jobPending = mPendingJobs.contains(job);
700 final boolean jobActive = isCurrentlyActiveLocked(job);
701 final boolean userRunning = mStartedUsers.contains(job.getUserId());
Matthew Williams9ae3dbe2014-08-21 13:47:47 -0700702 if (DEBUG) {
703 Slog.v(TAG, "isReadyToBeExecutedLocked: " + job.toShortString()
704 + " ready=" + jobReady + " pending=" + jobPending
705 + " active=" + jobActive + " userRunning=" + userRunning);
706 }
707 return userRunning && jobReady && !jobPending && !jobActive;
Christopher Tate7060b042014-06-09 19:50:00 -0700708 }
709
710 /**
711 * Criteria for cancelling an active job:
712 * - It's not ready
713 * - It's running on a JSC.
714 */
715 private boolean isReadyToBeCancelledLocked(JobStatus job) {
716 return !job.isReady() && isCurrentlyActiveLocked(job);
717 }
718
719 /**
720 * Reconcile jobs in the pending queue against available execution contexts.
721 * A controller can force a job into the pending queue even if it's already running, but
722 * here is where we decide whether to actually execute it.
723 */
724 private void maybeRunPendingJobsH() {
725 synchronized (mJobs) {
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700726 if (mDeviceIdleMode) {
727 // If device is idle, we will not schedule jobs to run.
728 return;
729 }
Christopher Tate7060b042014-06-09 19:50:00 -0700730 Iterator<JobStatus> it = mPendingJobs.iterator();
Matthew Williams75fc5252014-09-02 16:17:53 -0700731 if (DEBUG) {
732 Slog.d(TAG, "pending queue: " + mPendingJobs.size() + " jobs.");
733 }
Christopher Tate7060b042014-06-09 19:50:00 -0700734 while (it.hasNext()) {
735 JobStatus nextPending = it.next();
736 JobServiceContext availableContext = null;
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700737 for (int i=0; i<mActiveServices.size(); i++) {
738 JobServiceContext jsc = mActiveServices.get(i);
Christopher Tate7060b042014-06-09 19:50:00 -0700739 final JobStatus running = jsc.getRunningJob();
740 if (running != null && running.matches(nextPending.getUid(),
741 nextPending.getJobId())) {
Matthew Williamsee410da2014-07-25 11:30:40 -0700742 // Already running this job for this uId, skip.
Christopher Tate7060b042014-06-09 19:50:00 -0700743 availableContext = null;
744 break;
745 }
746 if (jsc.isAvailable()) {
747 availableContext = jsc;
748 }
749 }
750 if (availableContext != null) {
Amith Yamasanib0ff3222015-03-04 09:56:14 -0800751 if (DEBUG) {
752 Slog.d(TAG, "About to run job "
753 + nextPending.getJob().getService().toString());
754 }
Christopher Tate7060b042014-06-09 19:50:00 -0700755 if (!availableContext.executeRunnableJob(nextPending)) {
756 if (DEBUG) {
757 Slog.d(TAG, "Error executing " + nextPending);
758 }
759 mJobs.remove(nextPending);
760 }
761 it.remove();
762 }
763 }
764 }
765 }
766 }
767
768 /**
769 * Binder stub trampoline implementation
770 */
771 final class JobSchedulerStub extends IJobScheduler.Stub {
772 /** Cache determination of whether a given app can persist jobs
773 * key is uid of the calling app; value is undetermined/true/false
774 */
775 private final SparseArray<Boolean> mPersistCache = new SparseArray<Boolean>();
776
777 // Enforce that only the app itself (or shared uid participant) can schedule a
778 // job that runs one of the app's services, as well as verifying that the
779 // named service properly requires the BIND_JOB_SERVICE permission
780 private void enforceValidJobRequest(int uid, JobInfo job) {
Christopher Tate5568f542014-06-18 13:53:31 -0700781 final IPackageManager pm = AppGlobals.getPackageManager();
Christopher Tate7060b042014-06-09 19:50:00 -0700782 final ComponentName service = job.getService();
783 try {
Christopher Tate5568f542014-06-18 13:53:31 -0700784 ServiceInfo si = pm.getServiceInfo(service, 0, UserHandle.getUserId(uid));
785 if (si == null) {
786 throw new IllegalArgumentException("No such service " + service);
787 }
Christopher Tate7060b042014-06-09 19:50:00 -0700788 if (si.applicationInfo.uid != uid) {
789 throw new IllegalArgumentException("uid " + uid +
790 " cannot schedule job in " + service.getPackageName());
791 }
792 if (!JobService.PERMISSION_BIND.equals(si.permission)) {
793 throw new IllegalArgumentException("Scheduled service " + service
794 + " does not require android.permission.BIND_JOB_SERVICE permission");
795 }
Christopher Tate5568f542014-06-18 13:53:31 -0700796 } catch (RemoteException e) {
797 // Can't happen; the Package Manager is in this same process
Christopher Tate7060b042014-06-09 19:50:00 -0700798 }
799 }
800
801 private boolean canPersistJobs(int pid, int uid) {
802 // If we get this far we're good to go; all we need to do now is check
803 // whether the app is allowed to persist its scheduled work.
804 final boolean canPersist;
805 synchronized (mPersistCache) {
806 Boolean cached = mPersistCache.get(uid);
807 if (cached != null) {
808 canPersist = cached.booleanValue();
809 } else {
810 // Persisting jobs is tantamount to running at boot, so we permit
811 // it when the app has declared that it uses the RECEIVE_BOOT_COMPLETED
812 // permission
813 int result = getContext().checkPermission(
814 android.Manifest.permission.RECEIVE_BOOT_COMPLETED, pid, uid);
815 canPersist = (result == PackageManager.PERMISSION_GRANTED);
816 mPersistCache.put(uid, canPersist);
817 }
818 }
819 return canPersist;
820 }
821
822 // IJobScheduler implementation
823 @Override
824 public int schedule(JobInfo job) throws RemoteException {
825 if (DEBUG) {
Matthew Williamsee410da2014-07-25 11:30:40 -0700826 Slog.d(TAG, "Scheduling job: " + job.toString());
Christopher Tate7060b042014-06-09 19:50:00 -0700827 }
828 final int pid = Binder.getCallingPid();
829 final int uid = Binder.getCallingUid();
830
831 enforceValidJobRequest(uid, job);
Matthew Williams900c67f2014-07-09 12:46:53 -0700832 if (job.isPersisted()) {
833 if (!canPersistJobs(pid, uid)) {
834 throw new IllegalArgumentException("Error: requested job be persisted without"
835 + " holding RECEIVE_BOOT_COMPLETED permission.");
836 }
837 }
Christopher Tate7060b042014-06-09 19:50:00 -0700838
839 long ident = Binder.clearCallingIdentity();
840 try {
Matthew Williams900c67f2014-07-09 12:46:53 -0700841 return JobSchedulerService.this.schedule(job, uid);
Christopher Tate7060b042014-06-09 19:50:00 -0700842 } finally {
843 Binder.restoreCallingIdentity(ident);
844 }
845 }
846
847 @Override
848 public List<JobInfo> getAllPendingJobs() throws RemoteException {
849 final int uid = Binder.getCallingUid();
850
851 long ident = Binder.clearCallingIdentity();
852 try {
853 return JobSchedulerService.this.getPendingJobs(uid);
854 } finally {
855 Binder.restoreCallingIdentity(ident);
856 }
857 }
858
859 @Override
860 public void cancelAll() throws RemoteException {
861 final int uid = Binder.getCallingUid();
862
863 long ident = Binder.clearCallingIdentity();
864 try {
865 JobSchedulerService.this.cancelJobsForUid(uid);
866 } finally {
867 Binder.restoreCallingIdentity(ident);
868 }
869 }
870
871 @Override
872 public void cancel(int jobId) throws RemoteException {
873 final int uid = Binder.getCallingUid();
874
875 long ident = Binder.clearCallingIdentity();
876 try {
877 JobSchedulerService.this.cancelJob(uid, jobId);
878 } finally {
879 Binder.restoreCallingIdentity(ident);
880 }
881 }
882
883 /**
884 * "dumpsys" infrastructure
885 */
886 @Override
887 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
888 getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
889
890 long identityToken = Binder.clearCallingIdentity();
891 try {
892 JobSchedulerService.this.dumpInternal(pw);
893 } finally {
894 Binder.restoreCallingIdentity(identityToken);
895 }
896 }
897 };
898
899 void dumpInternal(PrintWriter pw) {
Christopher Tatef973a7b2014-08-29 12:54:08 -0700900 final long now = SystemClock.elapsedRealtime();
Christopher Tate7060b042014-06-09 19:50:00 -0700901 synchronized (mJobs) {
Matthew Williams9ae3dbe2014-08-21 13:47:47 -0700902 pw.print("Started users: ");
903 for (int i=0; i<mStartedUsers.size(); i++) {
904 pw.print("u" + mStartedUsers.get(i) + " ");
905 }
906 pw.println();
Christopher Tate7060b042014-06-09 19:50:00 -0700907 pw.println("Registered jobs:");
908 if (mJobs.size() > 0) {
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700909 ArraySet<JobStatus> jobs = mJobs.getJobs();
910 for (int i=0; i<jobs.size(); i++) {
911 JobStatus job = jobs.valueAt(i);
Christopher Tate7060b042014-06-09 19:50:00 -0700912 job.dump(pw, " ");
913 }
914 } else {
Christopher Tatef973a7b2014-08-29 12:54:08 -0700915 pw.println(" None.");
Christopher Tate7060b042014-06-09 19:50:00 -0700916 }
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700917 for (int i=0; i<mControllers.size(); i++) {
Christopher Tate7060b042014-06-09 19:50:00 -0700918 pw.println();
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700919 mControllers.get(i).dumpControllerState(pw);
Christopher Tate7060b042014-06-09 19:50:00 -0700920 }
921 pw.println();
Christopher Tatef973a7b2014-08-29 12:54:08 -0700922 pw.println("Pending:");
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700923 for (int i=0; i<mPendingJobs.size(); i++) {
924 pw.println(mPendingJobs.get(i).hashCode());
Christopher Tate7060b042014-06-09 19:50:00 -0700925 }
926 pw.println();
927 pw.println("Active jobs:");
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700928 for (int i=0; i<mActiveServices.size(); i++) {
929 JobServiceContext jsc = mActiveServices.get(i);
Christopher Tate7060b042014-06-09 19:50:00 -0700930 if (jsc.isAvailable()) {
931 continue;
932 } else {
Christopher Tatef973a7b2014-08-29 12:54:08 -0700933 final long timeout = jsc.getTimeoutElapsed();
934 pw.print("Running for: ");
935 pw.print((now - jsc.getExecutionStartTimeElapsed())/1000);
936 pw.print("s timeout=");
937 pw.print(timeout);
938 pw.print(" fromnow=");
939 pw.println(timeout-now);
940 jsc.getRunningJob().dump(pw, " ");
Christopher Tate7060b042014-06-09 19:50:00 -0700941 }
942 }
Dianne Hackbornfdb19562014-07-11 16:03:36 -0700943 pw.println();
944 pw.print("mReadyToRock="); pw.println(mReadyToRock);
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700945 pw.print("mDeviceIdleMode="); pw.println(mDeviceIdleMode);
Christopher Tate7060b042014-06-09 19:50:00 -0700946 }
947 pw.println();
948 }
949}