Save interactive/screen-on state in KeyguardServiceDelegate
So when SystemUI/Keyguard crashes, we only call onStartedWakingUp and onScreenTurnedOn when the device is interactive and/or the screen is on. Bug: 23344236 Change-Id: I0d0be91ff15d6c552304659956770ab88bb26ba4
This commit is contained in:
@@ -6085,6 +6085,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
startedWakingUp();
|
||||
screenTurningOn(null);
|
||||
screenTurnedOn();
|
||||
}
|
||||
|
||||
ProgressDialog mBootMsgDialog = null;
|
||||
|
||||
@@ -32,6 +32,14 @@ public class KeyguardServiceDelegate {
|
||||
private static final String TAG = "KeyguardServiceDelegate";
|
||||
private static final boolean DEBUG = true;
|
||||
|
||||
private static final int SCREEN_STATE_OFF = 0;
|
||||
private static final int SCREEN_STATE_TURNING_ON = 1;
|
||||
private static final int SCREEN_STATE_ON = 2;
|
||||
|
||||
private static final int INTERACTIVE_STATE_SLEEP = 0;
|
||||
private static final int INTERACTIVE_STATE_AWAKE = 1;
|
||||
private static final int INTERACTIVE_STATE_GOING_TO_SLEEP = 2;
|
||||
|
||||
protected KeyguardServiceWrapper mKeyguardService;
|
||||
private final Context mContext;
|
||||
private final View mScrim; // shown if keyguard crashes
|
||||
@@ -61,6 +69,8 @@ public class KeyguardServiceDelegate {
|
||||
public int offReason;
|
||||
public int currentUser;
|
||||
public boolean bootCompleted;
|
||||
public int screenState;
|
||||
public int interactiveState;
|
||||
};
|
||||
|
||||
public interface DrawnListener {
|
||||
@@ -144,10 +154,17 @@ public class KeyguardServiceDelegate {
|
||||
// If the system is ready, it means keyguard crashed and restarted.
|
||||
mKeyguardService.onSystemReady();
|
||||
// This is used to hide the scrim once keyguard displays.
|
||||
mKeyguardService.onStartedWakingUp();
|
||||
mKeyguardService.onScreenTurningOn(
|
||||
new KeyguardShowDelegate(mDrawnListenerWhenConnect));
|
||||
mKeyguardService.onScreenTurnedOn();
|
||||
if (mKeyguardState.interactiveState == INTERACTIVE_STATE_AWAKE) {
|
||||
mKeyguardService.onStartedWakingUp();
|
||||
}
|
||||
if (mKeyguardState.screenState == SCREEN_STATE_ON
|
||||
|| mKeyguardState.screenState == SCREEN_STATE_TURNING_ON) {
|
||||
mKeyguardService.onScreenTurningOn(
|
||||
new KeyguardShowDelegate(mDrawnListenerWhenConnect));
|
||||
}
|
||||
if (mKeyguardState.screenState == SCREEN_STATE_ON) {
|
||||
mKeyguardService.onScreenTurnedOn();
|
||||
}
|
||||
mDrawnListenerWhenConnect = null;
|
||||
}
|
||||
if (mKeyguardState.bootCompleted) {
|
||||
@@ -231,6 +248,7 @@ public class KeyguardServiceDelegate {
|
||||
if (DEBUG) Log.v(TAG, "onStartedWakingUp()");
|
||||
mKeyguardService.onStartedWakingUp();
|
||||
}
|
||||
mKeyguardState.interactiveState = INTERACTIVE_STATE_AWAKE;
|
||||
}
|
||||
|
||||
public void onScreenTurnedOff() {
|
||||
@@ -238,6 +256,7 @@ public class KeyguardServiceDelegate {
|
||||
if (DEBUG) Log.v(TAG, "onScreenTurnedOff()");
|
||||
mKeyguardService.onScreenTurnedOff();
|
||||
}
|
||||
mKeyguardState.screenState = SCREEN_STATE_OFF;
|
||||
}
|
||||
|
||||
public void onScreenTurningOn(final DrawnListener drawnListener) {
|
||||
@@ -252,6 +271,7 @@ public class KeyguardServiceDelegate {
|
||||
mDrawnListenerWhenConnect = drawnListener;
|
||||
showScrim();
|
||||
}
|
||||
mKeyguardState.screenState = SCREEN_STATE_TURNING_ON;
|
||||
}
|
||||
|
||||
public void onScreenTurnedOn() {
|
||||
@@ -259,6 +279,7 @@ public class KeyguardServiceDelegate {
|
||||
if (DEBUG) Log.v(TAG, "onScreenTurnedOn()");
|
||||
mKeyguardService.onScreenTurnedOn();
|
||||
}
|
||||
mKeyguardState.screenState = SCREEN_STATE_ON;
|
||||
}
|
||||
|
||||
public void onStartedGoingToSleep(int why) {
|
||||
@@ -266,12 +287,14 @@ public class KeyguardServiceDelegate {
|
||||
mKeyguardService.onStartedGoingToSleep(why);
|
||||
}
|
||||
mKeyguardState.offReason = why;
|
||||
mKeyguardState.interactiveState = INTERACTIVE_STATE_GOING_TO_SLEEP;
|
||||
}
|
||||
|
||||
public void onFinishedGoingToSleep(int why) {
|
||||
if (mKeyguardService != null) {
|
||||
mKeyguardService.onFinishedGoingToSleep(why);
|
||||
}
|
||||
mKeyguardState.interactiveState = INTERACTIVE_STATE_SLEEP;
|
||||
}
|
||||
|
||||
public void setKeyguardEnabled(boolean enabled) {
|
||||
|
||||
Reference in New Issue
Block a user