summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java50
1 files changed, 33 insertions, 17 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index f586ec6c552e..9c7e3986f877 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -225,7 +225,7 @@ public class PipTouchHandler implements TunerService.Tunable {
if (mIsMinimized) {
setMinimizedStateInternal(false);
}
- mDismissViewController.destroyDismissTarget();
+ cleanUpDismissTarget();
mShowPipMenuOnAnimationEnd = true;
}
@@ -334,6 +334,12 @@ public class PipTouchHandler implements TunerService.Tunable {
mAccessibilityManager.setPictureInPictureActionReplacingConnection(isRegistered
? new PipAccessibilityInteractionConnection(mMotionHelper,
this::onAccessibilityShowMenu, mHandler) : null);
+
+ if (!isRegistered && mTouchState.isUserInteracting()) {
+ // If the input consumer is unregistered while the user is interacting, then we may not
+ // get the final TOUCH_UP event, so clean up the dismiss target as well
+ cleanUpDismissTarget();
+ }
}
private void onAccessibilityShowMenu() {
@@ -578,11 +584,11 @@ public class PipTouchHandler implements TunerService.Tunable {
if (touchState.startedDragging()) {
mSavedSnapFraction = -1f;
- }
- if (touchState.startedDragging() && ENABLE_DISMISS_DRAG_TO_EDGE) {
- mHandler.removeCallbacks(mShowDismissAffordance);
- mDismissViewController.showDismissTarget();
+ if (ENABLE_DISMISS_DRAG_TO_EDGE) {
+ mHandler.removeCallbacks(mShowDismissAffordance);
+ mDismissViewController.showDismissTarget();
+ }
}
if (touchState.isDragging()) {
@@ -625,6 +631,12 @@ public class PipTouchHandler implements TunerService.Tunable {
@Override
public boolean onUp(PipTouchState touchState) {
+ if (ENABLE_DISMISS_DRAG_TO_EDGE) {
+ // Clean up the dismiss target regardless of the touch state in case the touch
+ // enabled state changes while the user is interacting
+ cleanUpDismissTarget();
+ }
+
if (!touchState.isUserInteracting()) {
return false;
}
@@ -640,18 +652,14 @@ public class PipTouchHandler implements TunerService.Tunable {
final boolean isFlingToBot = isFling && vel.y > 0 && !isHorizontal
&& (mMovementWithinDismiss || isUpWithinDimiss);
if (ENABLE_DISMISS_DRAG_TO_EDGE) {
- try {
- mHandler.removeCallbacks(mShowDismissAffordance);
- if (mMotionHelper.shouldDismissPip() || isFlingToBot) {
- mMotionHelper.animateDismiss(mMotionHelper.getBounds(), vel.x,
- vel.y, mUpdateScrimListener);
- MetricsLogger.action(mContext,
- MetricsEvent.ACTION_PICTURE_IN_PICTURE_DISMISSED,
- METRIC_VALUE_DISMISSED_BY_DRAG);
- return true;
- }
- } finally {
- mDismissViewController.destroyDismissTarget();
+ // Check if the user dragged or flung the PiP offscreen to dismiss it
+ if (mMotionHelper.shouldDismissPip() || isFlingToBot) {
+ mMotionHelper.animateDismiss(mMotionHelper.getBounds(), vel.x,
+ vel.y, mUpdateScrimListener);
+ MetricsLogger.action(mContext,
+ MetricsEvent.ACTION_PICTURE_IN_PICTURE_DISMISSED,
+ METRIC_VALUE_DISMISSED_BY_DRAG);
+ return true;
}
}
@@ -728,6 +736,14 @@ public class PipTouchHandler implements TunerService.Tunable {
: mNormalMovementBounds;
}
+ /**
+ * Removes the dismiss target and cancels any pending callbacks to show it.
+ */
+ private void cleanUpDismissTarget() {
+ mHandler.removeCallbacks(mShowDismissAffordance);
+ mDismissViewController.destroyDismissTarget();
+ }
+
public void dump(PrintWriter pw, String prefix) {
final String innerPrefix = prefix + " ";
pw.println(prefix + TAG);