Allow Activity#setTurnScreenOn to wakeup device
Add a condition that Activity#setTurnScreenOn can wakup device, also
make that activity become visible and dismiss keyguard automatically
when
- keyguard is insecure and
- device is non-interactive
Follow 7caf48e, if the above conditions are met, turnScreenOn can also
dismiss multiwindow mode.
Bug: 155922711
Test: atest ActivityVisibilityTests KeyguardTests KeyguardLockedTests
KeyguardTransitionTests AppConfigurationTests ReplaceWindowTests
ActivityLifecycleKeyguardTests
Change-Id: I7b18c391819d8e69b51d6f5b5e99a023d5ea1a0f
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user