Reset leash and content overlay if auto-enter-pip is aborted

This is to fix the edge case that Launcher has finished the
auto-enter-pip transition but app for some reason requests
setAutoEnterEnabled(false).

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/dpmhNEgztWewX4kWNsk3n0
Bug: 191930787
Test: swipe up at the end of YT playback, see video
Change-Id: Ib95a1c046e0243f705b901c9bfabcf96e37cb0e6
This commit is contained in:
Hongwei Wang
2021-07-20 15:11:42 -07:00
parent 11badea7d3
commit 3bbf0ab17e
3 changed files with 11 additions and 2 deletions

View File

@@ -5033,6 +5033,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
void notifyAppStopped() {
ProtoLog.v(WM_DEBUG_ADD_REMOVE, "notifyAppStopped: %s", this);
mAppStopped = true;
// This is to fix the edge case that auto-enter-pip is finished in Launcher but app calls
// setAutoEnterEnabled(false) and transitions to STOPPED state, see b/191930787.
// Clear any surface transactions and content overlay in this case.
if (task != null && task.mLastRecentsAnimationTransaction != null) {
task.clearLastRecentsAnimationTransaction(true /* forceRemoveOverlay */);
}
// Reset the last saved PiP snap fraction on app stop.
mDisplayContent.mPinnedTaskController.onActivityHidden(mActivityComponent);
mDisplayContent.mUnknownAppVisibilityController.appRemovedOrHidden(this);

View File

@@ -2151,7 +2151,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
rootTask.setLastRecentsAnimationTransaction(
task.mLastRecentsAnimationTransaction,
task.mLastRecentsAnimationOverlay);
task.clearLastRecentsAnimationTransaction();
task.clearLastRecentsAnimationTransaction(false /* forceRemoveOverlay */);
}
// There are multiple activities in the task and moving the top activity should

View File

@@ -7625,7 +7625,10 @@ class Task extends WindowContainer<WindowContainer> {
mLastRecentsAnimationOverlay = overlay;
}
void clearLastRecentsAnimationTransaction() {
void clearLastRecentsAnimationTransaction(boolean forceRemoveOverlay) {
if (forceRemoveOverlay && mLastRecentsAnimationOverlay != null) {
getPendingTransaction().remove(mLastRecentsAnimationOverlay);
}
mLastRecentsAnimationTransaction = null;
mLastRecentsAnimationOverlay = null;
// reset also the crop and transform introduced by mLastRecentsAnimationTransaction