Revert "Unify logic to check if either Keygaurd or AOD are showing."
This reverts commit b9f3d7ce35fd3107afd682949bba08c975413790.
Reason for revert: MultiDisplayActivityLaunchTests#testLaunchExternalDisplayActivityWhilePrimaryOff() when running the test on devices with AOD (locally reproducible on Walleye & C2).
Change-Id: Ic48edbb45ebc20d1d6109308c3867dab16094827
diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java
index 85ba95f..422b6e5 100644
--- a/services/core/java/com/android/server/wm/KeyguardController.java
+++ b/services/core/java/com/android/server/wm/KeyguardController.java
@@ -90,11 +90,24 @@
}
/**
- * @return true if either 1) AOD is showing, or 2) Keyguard is showing, not going away, and not
- * being occluded on the given display, false otherwise.
+ * @return true if either Keyguard or AOD are showing, not going away, and not being occluded
+ * on the given display, false otherwise.
*/
boolean isKeyguardOrAodShowing(int displayId) {
- return mAodShowing || isKeyguardShowing(displayId);
+ return (mKeyguardShowing || mAodShowing) && !mKeyguardGoingAway
+ && !isDisplayOccluded(displayId);
+ }
+
+ /**
+ * @return {@code true} for default display when AOD is showing. Otherwise, same as
+ * {@link #isKeyguardOrAodShowing(int)}
+ * TODO(b/125198167): Replace isKeyguardOrAodShowing() by this logic.
+ */
+ boolean isKeyguardUnoccludedOrAodShowing(int displayId) {
+ if (displayId == DEFAULT_DISPLAY && mAodShowing) {
+ return true;
+ }
+ return isKeyguardOrAodShowing(displayId);
}
/**
@@ -102,7 +115,7 @@
* display, false otherwise
*/
boolean isKeyguardShowing(int displayId) {
- return mKeyguardShowing && !mKeyguardGoingAway && !isKeyguardOccluded(displayId);
+ return mKeyguardShowing && !mKeyguardGoingAway && !isDisplayOccluded(displayId);
}
/**
@@ -315,7 +328,7 @@
return;
}
- mWindowManager.onKeyguardOccludedChanged(isKeyguardOccluded(DEFAULT_DISPLAY));
+ mWindowManager.onKeyguardOccludedChanged(isDisplayOccluded(DEFAULT_DISPLAY));
if (isKeyguardLocked()) {
mWindowManager.deferSurfaceLayout();
try {
@@ -360,7 +373,7 @@
}
}
- private boolean isKeyguardOccluded(int displayId) {
+ private boolean isDisplayOccluded(int displayId) {
return getDisplay(displayId).mOccluded;
}
@@ -378,13 +391,13 @@
if (mBeforeUnoccludeTransit != TRANSIT_UNSET
&& dc.mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE
// TODO(b/113840485): Handle app transition for individual display.
- && isKeyguardOccluded(DEFAULT_DISPLAY)) {
+ && isDisplayOccluded(DEFAULT_DISPLAY)) {
// Reuse old transit in case we are occluding Keyguard again, meaning that we never
// actually occclude/unocclude Keyguard, but just run a normal transition.
return mBeforeUnoccludeTransit;
// TODO(b/113840485): Handle app transition for individual display.
- } else if (!isKeyguardOccluded(DEFAULT_DISPLAY)) {
+ } else if (!isDisplayOccluded(DEFAULT_DISPLAY)) {
// Save transit in case we dismiss/occlude Keyguard shortly after.
mBeforeUnoccludeTransit = dc.mAppTransition.getAppTransition();
@@ -396,7 +409,7 @@
private void dismissDockedStackIfNeeded() {
// TODO(b/113840485): Handle docked stack for individual display.
- if (mKeyguardShowing && isKeyguardOccluded(DEFAULT_DISPLAY)) {
+ if (mKeyguardShowing && isDisplayOccluded(DEFAULT_DISPLAY)) {
// The lock screen is currently showing, but is occluded by a window that can
// show on top of the lock screen. In this can we want to dismiss the docked
// stack since it will be complicated/risky to try to put the activity on top
@@ -421,9 +434,9 @@
private void updateKeyguardSleepToken(int displayId) {
final KeyguardDisplayState state = getDisplay(displayId);
- if (isKeyguardOrAodShowing(displayId) && state.mSleepToken == null) {
+ if (isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken == null) {
state.acquiredSleepToken();
- } else if (!isKeyguardOrAodShowing(displayId) && state.mSleepToken != null) {
+ } else if (!isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken != null) {
state.releaseSleepToken();
}
}