From 96155ff2c682f8ba067946a7e3fd627c9de91634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ciche=C5=84ski?= Date: Tue, 14 Mar 2023 01:36:56 +0000 Subject: [PATCH] Persist the launcher keep clear area. This prevents the area from being lost due to other regions reporting their respective keep clear areas. With shell transitions enabled there is a possibility that the keep clear areas change between onTaskAppearead and PipTransition#startAnimation callbacks, which would cause the PiP to enter in the bottom right corner and then move above Hotseat, instead of going directly to the correct position. Test: e.g. atest ExpandPipOnDoubleClickTest Test: the above test would fail otherwise, as the tapping happens at the old position of PiP, not the one adjusted due to keep clear areas Bug: 260779127 Bug: 271493738 Change-Id: I5537ce8c9b2395017eeb9e112f44994433733fe9 --- .../com/android/wm/shell/pip/phone/PipController.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index a592e79b9581f..f8ecd2e995e60 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -103,7 +103,6 @@ import com.android.wm.shell.sysui.UserChangeListener; import com.android.wm.shell.transition.Transitions; import java.io.PrintWriter; -import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -118,6 +117,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb UserChangeListener { private static final String TAG = "PipController"; + private static final String LAUNCHER_KEEP_CLEAR_AREA_TAG = "hotseat"; + private static final long PIP_KEEP_CLEAR_AREAS_DELAY = SystemProperties.getLong("persist.wm.debug.pip_keep_clear_areas_delay", 200); @@ -929,12 +930,10 @@ public class PipController implements PipTransitionController.PipTransitionCallb 0, mPipBoundsState.getDisplayBounds().bottom - height, mPipBoundsState.getDisplayBounds().right, mPipBoundsState.getDisplayBounds().bottom); - Set restrictedKeepClearAreas = new HashSet<>( - mPipBoundsState.getRestrictedKeepClearAreas()); - restrictedKeepClearAreas.add(rect); - mPipBoundsState.setKeepClearAreas(restrictedKeepClearAreas, - mPipBoundsState.getUnrestrictedKeepClearAreas()); + mPipBoundsState.addNamedUnrestrictedKeepClearArea(LAUNCHER_KEEP_CLEAR_AREA_TAG, rect); updatePipPositionForKeepClearAreas(); + } else { + mPipBoundsState.removeNamedUnrestrictedKeepClearArea(LAUNCHER_KEEP_CLEAR_AREA_TAG); } }