diff options
author | Matthew Williams <mjwilliams@google.com> | 2014-08-06 18:14:16 -0700 |
---|---|---|
committer | Christopher Tate <ctate@android.com> | 2014-08-07 04:50:47 +0000 |
commit | be0c4175398ff5d7e13209e833b3037cdd0207d7 (patch) | |
tree | 85e65050586df213e774f78b0e2cd2e26ea97db4 | |
parent | 3f14df5c9df0028f78d930d03d512d969236f0bc (diff) | |
download | frameworks_base-be0c4175398ff5d7e13209e833b3037cdd0207d7.zip frameworks_base-be0c4175398ff5d7e13209e833b3037cdd0207d7.tar.gz frameworks_base-be0c4175398ff5d7e13209e833b3037cdd0207d7.tar.bz2 |
JobScheduler idle mode not being properly triggered
Issue with how the pending intent was being created -
the component name being explicitly set on the intent somehow
caused the intent to not be delivered.
Fix: no longer set the component name on the intent.
BUG: 16798118
Change-Id: I86b08b2a47067dc9b8da8b85450bc338e0826aca
-rw-r--r-- | services/core/java/com/android/server/job/JobSchedulerService.java | 32 | ||||
-rw-r--r-- | services/core/java/com/android/server/job/controllers/IdleController.java | 15 |
2 files changed, 37 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java index 9ac90dc..14457ec 100644 --- a/services/core/java/com/android/server/job/JobSchedulerService.java +++ b/services/core/java/com/android/server/job/JobSchedulerService.java @@ -74,7 +74,7 @@ public class JobSchedulerService extends com.android.server.SystemService static final boolean DEBUG = true; /** The number of concurrent jobs we run at one time. */ private static final int MAX_JOB_CONTEXTS_COUNT = 3; - static final String TAG = "JobManagerService"; + static final String TAG = "JobSchedulerService"; /** Master list of jobs. */ final JobStore mJobs; @@ -88,6 +88,11 @@ public class JobSchedulerService extends com.android.server.SystemService */ static final int MIN_IDLE_COUNT = 1; /** + * Minimum # of charging jobs that must be ready in order to force the JMS to schedule things + * early. + */ + static final int MIN_CHARGING_COUNT = 1; + /** * Minimum # of connectivity jobs that must be ready in order to force the JMS to schedule * things early. */ @@ -95,8 +100,9 @@ public class JobSchedulerService extends com.android.server.SystemService /** * Minimum # of jobs (with no particular constraints) for which the JMS will be happy running * some work early. + * This is correlated with the amount of batching we'll be able to do. */ - static final int MIN_READY_JOBS_COUNT = 4; + static final int MIN_READY_JOBS_COUNT = 2; /** * Track Services that have currently active or pending jobs. The index is provided by @@ -546,7 +552,8 @@ public class JobSchedulerService extends com.android.server.SystemService */ private void maybeQueueReadyJobsForExecutionH() { synchronized (mJobs) { - int idleCount = 0; + int chargingCount = 0; + int idleCount = 0; int backoffCount = 0; int connectivityCount = 0; List<JobStatus> runnableJobs = new ArrayList<JobStatus>(); @@ -563,17 +570,34 @@ public class JobSchedulerService extends com.android.server.SystemService if (job.hasConnectivityConstraint() || job.hasUnmeteredConstraint()) { connectivityCount++; } + if (job.hasChargingConstraint()) { + chargingCount++; + } runnableJobs.add(job); } else if (isReadyToBeCancelledLocked(job)) { stopJobOnServiceContextLocked(job); } } - if (backoffCount > 0 || idleCount >= MIN_IDLE_COUNT || + if (backoffCount > 0 || + idleCount >= MIN_IDLE_COUNT || connectivityCount >= MIN_CONNECTIVITY_COUNT || + chargingCount >= MIN_CHARGING_COUNT || runnableJobs.size() >= MIN_READY_JOBS_COUNT) { + if (DEBUG) { + Slog.d(TAG, "maybeQueueReadyJobsForExecutionH: Running jobs."); + } for (int i=0; i<runnableJobs.size(); i++) { mPendingJobs.add(runnableJobs.get(i)); } + } else { + if (DEBUG) { + Slog.d(TAG, "maybeQueueReadyJobsForExecutionH: Not running anything."); + } + } + if (DEBUG) { + Slog.d(TAG, "idle=" + idleCount + " connectivity=" + + connectivityCount + " charging=" + chargingCount + " tot=" + + runnableJobs.size()); } } } diff --git a/services/core/java/com/android/server/job/controllers/IdleController.java b/services/core/java/com/android/server/job/controllers/IdleController.java index 2213934..7b71027 100644 --- a/services/core/java/com/android/server/job/controllers/IdleController.java +++ b/services/core/java/com/android/server/job/controllers/IdleController.java @@ -113,12 +113,13 @@ public class IdleController extends StateController { public IdlenessTracker() { mAlarm = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); - Intent intent = new Intent(ACTION_TRIGGER_IDLE); - intent.setComponent(new ComponentName(mContext, this.getClass())); + Intent intent = new Intent(ACTION_TRIGGER_IDLE) + .setPackage("android") + .setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); mIdleTriggerIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); - // at boot we presume that the user has just "interacted" with the - // device in some meaningful way + // At boot we presume that the user has just "interacted" with the + // device in some meaningful way. mIdle = false; } @@ -163,9 +164,11 @@ public class IdleController extends StateController { // when the screen goes off or dreaming starts, we schedule the // alarm that will tell us when we have decided the device is // truly idle. - long when = SystemClock.elapsedRealtime() + INACTIVITY_IDLE_THRESHOLD; + final long nowElapsed = SystemClock.elapsedRealtime(); + final long when = nowElapsed + INACTIVITY_IDLE_THRESHOLD; if (DEBUG) { - Slog.v(TAG, "Scheduling idle : " + action + " when=" + when); + Slog.v(TAG, "Scheduling idle : " + action + " now:" + nowElapsed + " when=" + + when); } mAlarm.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, IDLE_WINDOW_SLOP, mIdleTriggerIntent); |