Merge "Idle Job Start During SCREEN_ON or DREAMING_STOPPED"
This commit is contained in:
@@ -109,6 +109,7 @@ public class IdleController extends StateController {
|
|||||||
private AlarmManager mAlarm;
|
private AlarmManager mAlarm;
|
||||||
private PendingIntent mIdleTriggerIntent;
|
private PendingIntent mIdleTriggerIntent;
|
||||||
boolean mIdle;
|
boolean mIdle;
|
||||||
|
boolean mScreenOn;
|
||||||
|
|
||||||
public IdlenessTracker() {
|
public IdlenessTracker() {
|
||||||
mAlarm = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
mAlarm = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
||||||
@@ -121,6 +122,7 @@ public class IdleController extends StateController {
|
|||||||
// At boot we presume that the user has just "interacted" with the
|
// At boot we presume that the user has just "interacted" with the
|
||||||
// device in some meaningful way.
|
// device in some meaningful way.
|
||||||
mIdle = false;
|
mIdle = false;
|
||||||
|
mScreenOn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIdle() {
|
public boolean isIdle() {
|
||||||
@@ -150,12 +152,14 @@ public class IdleController extends StateController {
|
|||||||
|
|
||||||
if (action.equals(Intent.ACTION_SCREEN_ON)
|
if (action.equals(Intent.ACTION_SCREEN_ON)
|
||||||
|| action.equals(Intent.ACTION_DREAMING_STOPPED)) {
|
|| action.equals(Intent.ACTION_DREAMING_STOPPED)) {
|
||||||
// possible transition to not-idle
|
|
||||||
if (mIdle) {
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.v(TAG, "exiting idle : " + action);
|
Slog.v(TAG,"exiting idle : " + action);
|
||||||
}
|
}
|
||||||
|
mScreenOn = true;
|
||||||
|
//cancel the alarm
|
||||||
mAlarm.cancel(mIdleTriggerIntent);
|
mAlarm.cancel(mIdleTriggerIntent);
|
||||||
|
if (mIdle) {
|
||||||
|
// possible transition to not-idle
|
||||||
mIdle = false;
|
mIdle = false;
|
||||||
reportNewIdleState(mIdle);
|
reportNewIdleState(mIdle);
|
||||||
}
|
}
|
||||||
@@ -170,11 +174,12 @@ public class IdleController extends StateController {
|
|||||||
Slog.v(TAG, "Scheduling idle : " + action + " now:" + nowElapsed + " when="
|
Slog.v(TAG, "Scheduling idle : " + action + " now:" + nowElapsed + " when="
|
||||||
+ when);
|
+ when);
|
||||||
}
|
}
|
||||||
|
mScreenOn = false;
|
||||||
mAlarm.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
mAlarm.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
when, IDLE_WINDOW_SLOP, mIdleTriggerIntent);
|
when, IDLE_WINDOW_SLOP, mIdleTriggerIntent);
|
||||||
} else if (action.equals(ACTION_TRIGGER_IDLE)) {
|
} else if (action.equals(ACTION_TRIGGER_IDLE)) {
|
||||||
// idle time starts now
|
// idle time starts now. Do not set mIdle if screen is on.
|
||||||
if (!mIdle) {
|
if (!mIdle && !mScreenOn) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.v(TAG, "Idle trigger fired @ " + SystemClock.elapsedRealtime());
|
Slog.v(TAG, "Idle trigger fired @ " + SystemClock.elapsedRealtime());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user