summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKevin Zhu <kzh@amazon.com>2015-06-29 16:06:49 -0700
committerMatthew Williams <mjwilliams@google.com>2015-08-10 15:03:34 -0700
commite910be0b7e1034f1adb813ad8a13dbd9a9180749 (patch)
tree339ca16ac83ea4b29a42cfc4d1e8b0b9ca6b2cb9 /services
parentc52839277b8714d150a9fe276b6ba3fa8a0cbf38 (diff)
downloadframeworks_base-e910be0b7e1034f1adb813ad8a13dbd9a9180749.zip
frameworks_base-e910be0b7e1034f1adb813ad8a13dbd9a9180749.tar.gz
frameworks_base-e910be0b7e1034f1adb813ad8a13dbd9a9180749.tar.bz2
DO NOT MERGE: Idle Job Start During SCREEN_ON or DREAMING_STOPPED
BUG: 23086704 Cherry-picked from https://android-review.googlesource.com/#/c/162280/ When the screen goes off or dreaming start, an alarm will be scheduled and idle state will be true when the alarm expired. If the screen goes on or dreaming stop happens before the alarm expired, the alarm isn't cancelled and idle state is set to be true when the device is in SCREEN_ON or DREADING_STOPPED state. There is also a case that Idle alarm triggered when the screen on or dreaming stop just start to be processed. ACTION_TRIGGER_IDLE will set mIdle to true during screen on or dreaming stop. In this patch, the alarm will be cancelled when the screen goes on or dreaming stop and screen-on flag will be set. So the idle state can only be set when screen is off or dreaming started. Change-Id: Ic21a2394418ca55513ab932b3bfad1126b8769c1
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/job/controllers/IdleController.java19
1 files changed, 12 insertions, 7 deletions
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 8e2ca18..92df851 100644
--- a/services/core/java/com/android/server/job/controllers/IdleController.java
+++ b/services/core/java/com/android/server/job/controllers/IdleController.java
@@ -108,6 +108,7 @@ public class IdleController extends StateController {
private AlarmManager mAlarm;
private PendingIntent mIdleTriggerIntent;
boolean mIdle;
+ boolean mScreenOn;
public IdlenessTracker() {
mAlarm = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
@@ -120,6 +121,7 @@ public class IdleController extends StateController {
// At boot we presume that the user has just "interacted" with the
// device in some meaningful way.
mIdle = false;
+ mScreenOn = true;
}
public boolean isIdle() {
@@ -149,12 +151,14 @@ public class IdleController extends StateController {
if (action.equals(Intent.ACTION_SCREEN_ON)
|| action.equals(Intent.ACTION_DREAMING_STOPPED)) {
- // possible transition to not-idle
+ if (DEBUG) {
+ Slog.v(TAG,"exiting idle : " + action);
+ }
+ mScreenOn = true;
+ //cancel the alarm
+ mAlarm.cancel(mIdleTriggerIntent);
if (mIdle) {
- if (DEBUG) {
- Slog.v(TAG, "exiting idle : " + action);
- }
- mAlarm.cancel(mIdleTriggerIntent);
+ // possible transition to not-idle
mIdle = false;
reportNewIdleState(mIdle);
}
@@ -169,11 +173,12 @@ public class IdleController extends StateController {
Slog.v(TAG, "Scheduling idle : " + action + " now:" + nowElapsed + " when="
+ when);
}
+ mScreenOn = false;
mAlarm.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP,
when, IDLE_WINDOW_SLOP, mIdleTriggerIntent);
} else if (action.equals(ACTION_TRIGGER_IDLE)) {
- // idle time starts now
- if (!mIdle) {
+ // idle time starts now. Do not set mIdle if screen is on.
+ if (!mIdle && !mScreenOn) {
if (DEBUG) {
Slog.v(TAG, "Idle trigger fired @ " + SystemClock.elapsedRealtime());
}