diff options
| -rw-r--r-- | core/java/android/app/Activity.java | 6 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/KeyguardController.java | 39 |
2 files changed, 37 insertions, 8 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 2ac345d2560a..29e407bc533a 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -77,6 +77,7 @@ import android.os.IBinder; import android.os.Looper; import android.os.Parcelable; import android.os.PersistableBundle; +import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager.ServiceNotFoundException; @@ -8722,13 +8723,16 @@ public class Activity extends ContextThemeWrapper * the activity is visible after the screen is turned on when the lockscreen is up. In addition, * if this flag is set and the activity calls {@link * KeyguardManager#requestDismissKeyguard(Activity, KeyguardManager.KeyguardDismissCallback)} - * the screen will turn on. + * the screen will turn on. If the screen is off and device is not secured, this flag can turn + * screen on and dismiss keyguard to make this activity visible and resume, which can be used to + * replace {@link PowerManager#ACQUIRE_CAUSES_WAKEUP} * * @param turnScreenOn {@code true} to turn on the screen; {@code false} otherwise. * * @see #setShowWhenLocked(boolean) * @see android.R.attr#turnScreenOn * @see android.R.attr#showWhenLocked + * @see KeyguardManager#isDeviceSecure() */ public void setTurnScreenOn(boolean turnScreenOn) { try { diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index 79b88d87f268..de2164d7493f 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -167,7 +167,8 @@ class KeyguardController { if (keyguardChanged) { // Irrelevant to AOD. - dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */); + dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */, + false /* turningScreenOn */); setKeyguardGoingAway(false); if (keyguardShowing) { mDismissalRequested = false; @@ -369,7 +370,6 @@ class KeyguardController { mService.continueWindowLayout(); } } - dismissMultiWindowModeForTaskIfNeeded(currentTaskControllingOcclusion); } /** @@ -398,6 +398,21 @@ class KeyguardController { } } + /** + * Called when somebody wants to turn screen on. + */ + private void handleTurnScreenOn(int displayId) { + if (displayId != DEFAULT_DISPLAY) { + return; + } + + mStackSupervisor.wakeUp("handleTurnScreenOn"); + if (mKeyguardShowing && canDismissKeyguard()) { + mWindowManager.dismissKeyguard(null /* callback */, null /* message */); + mDismissalRequested = true; + } + } + boolean isDisplayOccluded(int displayId) { return getDisplayState(displayId).mOccluded; } @@ -433,14 +448,15 @@ class KeyguardController { } private void dismissMultiWindowModeForTaskIfNeeded( - @Nullable Task currentTaskControllingOcclusion) { + @Nullable Task currentTaskControllingOcclusion, boolean turningScreenOn) { + // If turningScreenOn is true, it means that the visibility state has changed from + // currentTaskControllingOcclusion and we should update windowing mode. // TODO(b/113840485): Handle docked stack for individual display. - if (!mKeyguardShowing || !isDisplayOccluded(DEFAULT_DISPLAY)) { + if (!turningScreenOn && (!mKeyguardShowing || !isDisplayOccluded(DEFAULT_DISPLAY))) { return; } // Dismiss split screen - // 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 @@ -579,17 +595,26 @@ class KeyguardController { && controller.mWindowManager.isKeyguardSecure( controller.mService.getCurrentUserId()); + boolean occludingChange = false; + boolean turningScreenOn = false; if (mTopTurnScreenOnActivity != lastTurnScreenOnActivity && mTopTurnScreenOnActivity != null && !mService.mWindowManager.mPowerManager.isInteractive() - && (mRequestDismissKeyguard || occludedByActivity)) { - controller.mStackSupervisor.wakeUp("handleTurnScreenOn"); + && (mRequestDismissKeyguard || occludedByActivity + || controller.canDismissKeyguard())) { + turningScreenOn = true; + controller.handleTurnScreenOn(mDisplayId); mTopTurnScreenOnActivity.setCurrentLaunchCanTurnScreenOn(false); } if (lastOccluded != mOccluded) { + occludingChange = true; controller.handleOccludedChanged(mDisplayId, task); } + + if (occludingChange || turningScreenOn) { + controller.dismissMultiWindowModeForTaskIfNeeded(task, turningScreenOn); + } } /** |