Merge "Fix split dismissed after click pip to split button" into sc-v2-dev am: 6a2ce827e2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16235342

Change-Id: I8adcf7ea0f04b81975588e4535db6d0cf161948b
This commit is contained in:
Tony Huang
2021-11-19 08:42:09 +00:00
committed by Automerger Merge Worker
4 changed files with 66 additions and 7 deletions

View File

@@ -87,6 +87,12 @@ public interface SplitScreen {
*/ */
void onKeyguardVisibilityChanged(boolean showing); void onKeyguardVisibilityChanged(boolean showing);
/** Called when device waking up finished. */
void onFinishedWakingUp();
/** Called when device going to sleep finished. */
void onFinishedGoingToSleep();
/** Get a string representation of a stage type */ /** Get a string representation of a stage type */
static String stageTypeToString(@StageType int stage) { static String stageTypeToString(@StageType int stage) {
switch (stage) { switch (stage) {

View File

@@ -232,6 +232,14 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
mStageCoordinator.onKeyguardVisibilityChanged(showing); mStageCoordinator.onKeyguardVisibilityChanged(showing);
} }
public void onFinishedWakingUp() {
mStageCoordinator.onFinishedWakingUp();
}
public void onFinishedGoingToSleep() {
mStageCoordinator.onFinishedGoingToSleep();
}
public void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) { public void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) {
mStageCoordinator.exitSplitScreenOnHide(exitSplitScreenOnHide); mStageCoordinator.exitSplitScreenOnHide(exitSplitScreenOnHide);
} }
@@ -491,6 +499,20 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
SplitScreenController.this.onKeyguardVisibilityChanged(showing); SplitScreenController.this.onKeyguardVisibilityChanged(showing);
}); });
} }
@Override
public void onFinishedWakingUp() {
mMainExecutor.execute(() -> {
SplitScreenController.this.onFinishedWakingUp();
});
}
@Override
public void onFinishedGoingToSleep() {
mMainExecutor.execute(() -> {
SplitScreenController.this.onFinishedGoingToSleep();
});
}
} }
/** /**

View File

@@ -155,6 +155,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
private boolean mShouldUpdateRecents; private boolean mShouldUpdateRecents;
private boolean mExitSplitScreenOnHide; private boolean mExitSplitScreenOnHide;
private boolean mKeyguardOccluded; private boolean mKeyguardOccluded;
private boolean mDeviceSleep;
@SplitScreen.StageType @SplitScreen.StageType
private int mDismissTop = NO_DISMISS; private int mDismissTop = NO_DISMISS;
@@ -547,6 +548,17 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
} }
} }
void onFinishedWakingUp() {
if (mMainStage.isActive()) {
exitSplitScreenIfKeyguardOccluded();
}
mDeviceSleep = false;
}
void onFinishedGoingToSleep() {
mDeviceSleep = true;
}
void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) { void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) {
mExitSplitScreenOnHide = exitSplitScreenOnHide; mExitSplitScreenOnHide = exitSplitScreenOnHide;
} }
@@ -575,6 +587,19 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
applyExitSplitScreen(childrenToTop, wct, exitReason); applyExitSplitScreen(childrenToTop, wct, exitReason);
} }
private void exitSplitScreenIfKeyguardOccluded() {
final boolean mainStageVisible = mMainStageListener.mVisible;
final boolean oneStageVisible = mainStageVisible ^ mSideStageListener.mVisible;
if (mDeviceSleep && mKeyguardOccluded && oneStageVisible) {
// Only the stages include show-when-locked activity is visible while keyguard occluded.
// Dismiss split because there's show-when-locked activity showing on top of keyguard.
// Also make sure the task contains show-when-locked activity remains on top after split
// dismissed.
final StageTaskListener toTop = mainStageVisible ? mMainStage : mSideStage;
exitSplitScreen(toTop, EXIT_REASON_SCREEN_LOCKED_SHOW_ON_TOP);
}
}
private void applyExitSplitScreen(StageTaskListener childrenToTop, private void applyExitSplitScreen(StageTaskListener childrenToTop,
WindowContainerTransaction wct, @ExitReason int exitReason) { WindowContainerTransaction wct, @ExitReason int exitReason) {
mRecentTasks.ifPresent(recentTasks -> { mRecentTasks.ifPresent(recentTasks -> {
@@ -790,14 +815,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
// like the cases keyguard showing or screen off. // like the cases keyguard showing or screen off.
exitSplitScreen(null /* childrenToTop */, EXIT_REASON_RETURN_HOME); exitSplitScreen(null /* childrenToTop */, EXIT_REASON_RETURN_HOME);
} }
} else if (mKeyguardOccluded) {
// At least one of the stages is visible while keyguard occluded. Dismiss split because
// there's show-when-locked activity showing on top of keyguard. Also make sure the
// task contains show-when-locked activity remains on top after split dismissed.
final StageTaskListener toTop =
mainStageVisible ? mMainStage : (sideStageVisible ? mSideStage : null);
exitSplitScreen(toTop, EXIT_REASON_SCREEN_LOCKED_SHOW_ON_TOP);
} }
exitSplitScreenIfKeyguardOccluded();
mSyncQueue.runInSync(t -> { mSyncQueue.runInSync(t -> {
// Same above, we only set root tasks and divider leash visibility when both stage // Same above, we only set root tasks and divider leash visibility when both stage

View File

@@ -260,6 +260,18 @@ public final class WMShell extends SystemUI
} }
}; };
mKeyguardUpdateMonitor.registerCallback(mSplitScreenKeyguardCallback); mKeyguardUpdateMonitor.registerCallback(mSplitScreenKeyguardCallback);
mWakefulnessLifecycle.addObserver(new WakefulnessLifecycle.Observer() {
@Override
public void onFinishedWakingUp() {
splitScreen.onFinishedWakingUp();
}
@Override
public void onFinishedGoingToSleep() {
splitScreen.onFinishedGoingToSleep();
}
});
} }
@VisibleForTesting @VisibleForTesting