Move bounds calculation and snap fraction to SysUI
Major changes in this CL
- Added PipBoundsHandler in SysUI package handles the bounds calculation
and save/restore the snap fraction
- Added IPinnedStackListener.onSaveReentrySnapFraction and
IPinnedStackListener.onResetReentrySnapFration, both called from
PinnedStackController (WM) to SysUI
- Added IPinnedStackListener.onPrepareAnimation, called from WM to
SysUI to notify that an animation for pinned stack is about to happen
- Added IPinnedStackController.startAnimation, called from SysUI to WM
to actually start the pinned stack animation
- Updated tv/PipManager to use PipBoundsHandler as well
Known issues and what's next
- Shelf height is set after the animation is started, therefore one may
notice the PiP window is hovering over the shelf. This is tracked
separatedly by b/139016518
- Bounds calculations still exist in PinnedStackController since
onTaskStackChanged callback requires so. Once we addressed b/139016833
(move rotation bounds calculation to SysUI), they should be all gone.
- Move the pinned stack animation from WM to SysUI and we can furthre
remove IPinnedStackListener.onPrepareAnimation and
IPinnedStackController.startAnimation
More details: go/pip-sysui-migration
Bug: 139015463
Bug: 139015142
Test: atest PinnedStackTests
Test: atest PinnedStackControllerTest
Change-Id: Ib62d8152ecc7b18a671ec403af44cc517612169e
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index ffd9021..71f02e8 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -1021,7 +1021,7 @@
if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
mAppStopped = true;
// Reset the last saved PiP snap fraction on app stop.
- mDisplayContent.mPinnedStackControllerLocked.resetReentrySnapFraction(this);
+ mDisplayContent.mPinnedStackControllerLocked.resetReentrySnapFraction(mActivityComponent);
destroySurfaces();
// Remove any starting window that was added for this app if they are still around.
removeStartingWindow();
@@ -1705,10 +1705,7 @@
return;
}
- if (prevWinMode != WINDOWING_MODE_UNDEFINED && winMode == WINDOWING_MODE_PINNED) {
- // Entering PiP from fullscreen, reset the snap fraction
- mDisplayContent.mPinnedStackControllerLocked.resetReentrySnapFraction(this);
- } else if (prevWinMode == WINDOWING_MODE_PINNED && winMode != WINDOWING_MODE_UNDEFINED
+ if (prevWinMode == WINDOWING_MODE_PINNED && winMode != WINDOWING_MODE_UNDEFINED
&& !isHidden()) {
// Leaving PiP to fullscreen, save the snap fraction based on the pre-animation bounds
// for the next re-entry into PiP (assuming the activity is not hidden or destroyed)
@@ -1726,8 +1723,8 @@
stackBounds = mTmpRect;
pinnedStack.getBounds(stackBounds);
}
- mDisplayContent.mPinnedStackControllerLocked.saveReentrySnapFraction(this,
- stackBounds);
+ mDisplayContent.mPinnedStackControllerLocked.saveReentrySnapFraction(
+ mActivityComponent, stackBounds);
}
} else if (shouldStartChangeTransition(prevWinMode, winMode)) {
initializeChangeTransition(mTmpPrevBounds);