Fix touch goes to the window behide PiP
When an Acitivty enter PictureInPicture mode, the pip input consumer
would be created and show the PipMenuActivity at first entry
(MENU_STATE_CLOSE) or show full menu (MENU_STATE_FULL) if user clicks
the pip window.
So in order to control the pip wndow dragging and menu, the pip input
consumer would be destoryed when menu window has shown, and it would be
created when the pip window starts to drag or the menu has hidden.
And the menu window should also has the flag FLAG_SLIPPERY to make sure
touch can through to the pip input consumer, but it could not guarantee
which window can receive the touch.
This patch would make sure all touch events except ACTION_OUTSIDE can
go through pip input consumer because it's above the pip window and it
can integrate all behaviors like window dragging or show menu in
PipTouchHandler without doing same thing and adding FLAG_SLIPPERY in
PipMenuActivity.
Test: atest PinnedStackTests
Test: atest SystemUITests
Bug: 139805619
Change-Id: I35f9eba867561168384d0a0d6c0608a6dbdf6a09
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index 1740290..3be3422 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -16,6 +16,9 @@
package com.android.systemui.pip.phone;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
+import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
+
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.IActivityManager;
@@ -182,7 +185,6 @@
ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
mInputConsumerController = InputConsumerController.getPipInputConsumer();
- mInputConsumerController.registerInputConsumer();
mMediaController = new PipMediaController(context, mActivityManager);
mMenuController = new PipMenuActivityController(context, mActivityManager, mMediaController,
mInputConsumerController);
@@ -190,6 +192,18 @@
mMenuController, mInputConsumerController);
mAppOpsListener = new PipAppOpsListener(context, mActivityManager,
mTouchHandler.getMotionHelper());
+
+ // If SystemUI restart, and it already existed a pinned stack,
+ // register the pip input consumer to ensure touch can send to it.
+ try {
+ ActivityManager.StackInfo stackInfo = mActivityTaskManager.getStackInfo(
+ WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
+ if (stackInfo != null) {
+ mInputConsumerController.registerInputConsumer();
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
/**