From f848e9d439646b31f0d445b5a781c9ec88557910 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 24 Mar 2020 16:04:09 -0700 Subject: [PATCH] Disabled back gesture when quickswitching if needed We allow quickswitching apps in different orientations by touchiing in the same region on the device. To avoid conflicting touches between the swipe gesture and the back gesture, we disable the back if the rotation of the swipe location and rotation of current device do not match. Fixes: 150250451 Test: Tested quickswitch manually with test apps fixed to different rotations. Ensured back only showed when rotation of touch and display matched. Change-Id: If3b4d15eb4b66ce688b91d44a2ec16b3610ecf0a --- .../shared/recents/ISystemUiProxy.aidl | 8 +- .../recents/OverviewProxyService.java | 21 +++++ .../phone/EdgeBackGestureHandler.java | 89 ++++++++++++++++++- 3 files changed, 116 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl index 80fd826f28c62..35ad422c56b89 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl @@ -26,7 +26,7 @@ import com.android.systemui.shared.recents.IPinnedStackAnimationListener; /** * Temporary callbacks into SystemUI. - * Next id = 25 + * Next id = 26 */ interface ISystemUiProxy { @@ -140,4 +140,10 @@ interface ISystemUiProxy { * Sets listener to get pinned stack animation callbacks. */ void setPinnedStackAnimationListener(IPinnedStackAnimationListener listener) = 24; + + /** + * Notifies that quickstep will switch to a new task + * @param rotation indicates which Surface.Rotation the gesture was started in + */ + void onQuickSwitchToNewTask(int rotation) = 25; } diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index df85ed524536b..66bc177da81dc 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -55,6 +55,7 @@ import android.os.UserHandle; import android.util.Log; import android.view.InputMonitor; import android.view.MotionEvent; +import android.view.Surface; import android.view.accessibility.AccessibilityManager; import com.android.internal.policy.ScreenDecorationsUtils; @@ -416,6 +417,19 @@ public class OverviewProxyService implements CallbackController notifyQuickSwitchToNewTask(rotation)); + } finally { + Binder.restoreCallingIdentity(token); + } + } + private boolean verifyCaller(String reason) { final int callerId = Binder.getCallingUserHandle().getIdentifier(); if (callerId != mCurrentBoundedUserId) { @@ -785,6 +799,12 @@ public class OverviewProxyService implements CallbackController= 0; --i) { + mConnectionCallbacks.get(i).onQuickSwitchToNewTask(rotation); + } + } + public void notifyQuickScrubStarted() { for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) { mConnectionCallbacks.get(i).onQuickScrubStarted(); @@ -850,6 +870,7 @@ public class OverviewProxyService implements CallbackController -1) { + updateDisabledForQuickstep(); + } + if (displayId == mDisplayId) { updateDisplaySize(); } @@ -502,6 +577,17 @@ public class EdgeBackGestureHandler implements DisplayListener, InputManager.getInstance().injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); } + private void updatedFixedRotation() { + boolean oldFlag = mFixedRotationFlagEnabled; + mFixedRotationFlagEnabled = Settings.Global.getInt(mContext.getContentResolver(), + FIXED_ROTATION_TRANSFORM_SETTING_NAME, 0) != 0; + if (oldFlag == mFixedRotationFlagEnabled) { + return; + } + + setRotationCallbacks(mFixedRotationFlagEnabled); + } + public void setInsets(int leftInset, int rightInset) { mLeftInset = leftInset; mRightInset = rightInset; @@ -514,6 +600,7 @@ public class EdgeBackGestureHandler implements DisplayListener, pw.println("EdgeBackGestureHandler:"); pw.println(" mIsEnabled=" + mIsEnabled); pw.println(" mAllowGesture=" + mAllowGesture); + pw.println(" mDisabledForQuickstep=" + mDisabledForQuickstep); pw.println(" mInRejectedExclusion" + mInRejectedExclusion); pw.println(" mExcludeRegion=" + mExcludeRegion); pw.println(" mUnrestrictedExcludeRegion=" + mUnrestrictedExcludeRegion);