From 75b6e6c0463ab883d98cde8914b93934bce971a2 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Tue, 17 Sep 2019 10:07:56 -0700 Subject: [PATCH] Resets PiP snap fraction on AppWindowToken removal We previously rely on both windowing mode change and activity stopped signals to reset the PiP snap fraction. The windowing mode change signal is sent too early from WM to SysUI when we have default bounds calculation migrated to SysUI. Certain PinnedStackTests cases become flaky when we soly depend on activity stopped signal to reset the fraction. For instance, testEnterPictureInPictureDiscardSavedPositionOnFinish - Test-1 started PiP with shelf open - Snap fraction X is saved from Test-1 - Test-2 launches PiP above NO_RELAUNCH_ACTIVITY, with shelf closed Instead of using the default bounds, Test-2 uses fraction X saved from Test-1 which is shifted up by shelf height. The saved fraction does not get reset in this case since the test activities are force killed after each run and no activity stopped signal is sent. Bug: 139015463 Test: atest PinnedStackTests Change-Id: I5720dc3abcfc78a92bb118ae35fc25d922c6232a --- services/core/java/com/android/server/wm/AppWindowToken.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index ffd9021989b46..09278d1277dda 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -955,6 +955,9 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree updateReportedVisibilityLocked(); } + // Reset the last saved PiP snap fraction on removal. + mDisplayContent.mPinnedStackControllerLocked.resetReentrySnapFraction(mActivityComponent); + mRemovingFromDisplay = false; }