From ea4f7e5b2ab1cc36e71aae9c7d61e350bc833154 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Mon, 17 May 2021 16:06:31 -0700 Subject: [PATCH] PiP: Move resetting mAllowTouches into scope of MenuView Previously we used to reset mAllowTouches backed on callbacks from TaskOrg's animation finish, but there is a race where it's possible the callback from the animation finish happens before the menu state updates, which causes the callback to no-op. Instead, since we only disable allow touches during #showMenu, just keep it in the scope and re-enable it when the same animation has ended (or cancelled). Bug: 188464003 Test: Move PIP to smaller, tap (to cause it to grow larger), and tap on an icon, and expect icon to work and launch Settings, etc. Change-Id: Iea3fff3c279dcdfa7eb922cb59302ea53ac618fd --- .../wm/shell/pip/phone/PhonePipMenuController.java | 7 ------- .../com/android/wm/shell/pip/phone/PipController.java | 2 -- .../com/android/wm/shell/pip/phone/PipMenuView.java | 11 ++++++----- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java index 052653e0cc818..140f32f9eb7f8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java @@ -173,13 +173,6 @@ public class PhonePipMenuController implements PipMenuController { detachPipMenuView(); } - - void onPinnedStackAnimationEnded() { - if (isMenuVisible()) { - mPipMenuView.onPipAnimationEnded(); - } - } - private void attachPipMenuView() { // In case detach was not called (e.g. PIP unexpectedly closed) if (mPipMenuView != null) { 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 f80b161be42ac..7ac06538efa68 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 @@ -36,7 +36,6 @@ import android.content.res.Configuration; import android.graphics.Rect; import android.os.IBinder; import android.os.RemoteException; -import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.util.Log; @@ -606,7 +605,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb // Re-enable touches after the animation completes mTouchHandler.setTouchEnabled(true); mTouchHandler.onPinnedStackAnimationEnded(direction); - mMenuController.onPinnedStackAnimationEnded(); } private void updateMovementBounds(@Nullable Rect toBounds, boolean fromRotation, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java index 7b17fe45a9a3d..e21083569c41b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java @@ -40,7 +40,6 @@ import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.graphics.Rect; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -279,11 +278,17 @@ public class PipMenuView extends FrameLayout { mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { + mAllowTouches = true; notifyMenuStateChangeFinish(menuState); if (allowMenuTimeout) { repostDelayedHide(INITIAL_DISMISS_DELAY); } } + + @Override + public void onAnimationCancel(Animator animation) { + mAllowTouches = true; + } }); if (withDelay) { // starts the menu container animation after window expansion is completed @@ -326,10 +331,6 @@ public class PipMenuView extends FrameLayout { cancelDelayedHide(); } - void onPipAnimationEnded() { - mAllowTouches = true; - } - void updateMenuLayout(Rect bounds) { mPipMenuIconsAlgorithm.onBoundsChanged(bounds); }