Hook one-handed gesture to expand notification panel by default
Notify to expand notification panel through SystemUiProxy when
one-handed mode disabled and one-handed gesture detected.
Bug: 154080211
Test: make and install
Test: manual disable one handed mode and swipe down to trigger
Test: verified the gesture works even outside of home page
Change-Id: Iacc0e506ccd04dd81f6182759c8af7d686a7b77b
(cherry picked from commit dd3eb7d075021df869b009d5a78666d7d225aaf1)
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
index fced849..46249d9 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
@@ -106,18 +106,16 @@
} else {
float distance = (float) Math.hypot(mLastPos.x - mStartDragPos.x,
mLastPos.y - mStartDragPos.y);
- if (distance > mDragDistThreshold && mPassedSlop
- && mDeviceState.isOneHandedModeActive()) {
- SystemUiProxy.INSTANCE.get(mContext).stopOneHandedMode();
+ if (distance > mDragDistThreshold && mPassedSlop) {
+ onStopGestureDetected();
}
}
break;
}
case ACTION_UP:
case ACTION_CANCEL: {
- if (mLastPos.y >= mStartDragPos.y && mPassedSlop
- && !mDeviceState.isOneHandedModeActive()) {
- SystemUiProxy.INSTANCE.get(mContext).startOneHandedMode();
+ if (mLastPos.y >= mStartDragPos.y && mPassedSlop) {
+ onStartGestureDetected();
}
mPassedSlop = false;
@@ -131,6 +129,28 @@
}
}
+ private void onStartGestureDetected() {
+ if (mDeviceState.isOneHandedModeActive()) {
+ return;
+ }
+
+ if (mDeviceState.isOneHandedModeEnabled()) {
+ SystemUiProxy.INSTANCE.get(mContext).startOneHandedMode();
+ return;
+ }
+
+ // Hook one-handed gesture to expand notification panel by default
+ SystemUiProxy.INSTANCE.get(mContext).expandNotificationPanel();
+ }
+
+ private void onStopGestureDetected() {
+ if (!mDeviceState.isOneHandedModeEnabled() || !mDeviceState.isOneHandedModeActive()) {
+ return;
+ }
+
+ SystemUiProxy.INSTANCE.get(mContext).stopOneHandedMode();
+ }
+
private boolean isValidStartAngle(float deltaX, float deltaY) {
final float angle = (float) Math.toDegrees(Math.atan2(deltaY, deltaX));
return angle > -(ANGLE_MAX) && angle < -(ANGLE_MIN);
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 87522b8..15e6ca5 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -77,8 +77,6 @@
NavigationModeChangeListener,
DefaultDisplay.DisplayInfoChangeListener {
- private static boolean sIsOneHandedEnabled;
-
private final Context mContext;
private final SysUINavigationMode mSysUiNavMode;
private final DefaultDisplay mDefaultDisplay;
@@ -95,6 +93,7 @@
private final Region mDeferredGestureRegion = new Region();
private boolean mAssistantAvailable;
private float mAssistantVisibility;
+ private boolean mIsOneHandedModeEnabled;
private boolean mIsUserUnlocked;
private final ArrayList<Runnable> mUserUnlockedActions = new ArrayList<>();
@@ -495,10 +494,6 @@
* @return whether the given motion event can trigger the one handed mode.
*/
public boolean canTriggerOneHandedAction(MotionEvent ev) {
- if (!sIsOneHandedEnabled) {
- return false;
- }
-
final DefaultDisplay.Info displayInfo = mDefaultDisplay.getInfo();
return (mRotationTouchHelper.touchInOneHandedModeRegion(ev)
&& displayInfo.rotation != Surface.ROTATION_90
@@ -506,8 +501,12 @@
&& displayInfo.metrics.densityDpi < DisplayMetrics.DENSITY_600);
}
+ public boolean isOneHandedModeEnabled() {
+ return mIsOneHandedModeEnabled;
+ }
+
private void onOneHandedEnabledSettingsChanged(boolean isOneHandedEnabled) {
- sIsOneHandedEnabled = isOneHandedEnabled;
+ mIsOneHandedModeEnabled = isOneHandedEnabled;
}
public RotationTouchHelper getRotationTouchHelper() {
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 72510a9..e4b05ae 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -380,4 +380,15 @@
}
}
}
+
+ @Override
+ public void expandNotificationPanel() {
+ if (mSystemUiProxy != null) {
+ try {
+ mSystemUiProxy.expandNotificationPanel();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed call expandNotificationPanel", e);
+ }
+ }
+ }
}