Merge "Improve system gesture listener to handle display cutout"
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index feecd02..c646fef 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -47,6 +47,9 @@
<dimen name="navigation_bar_height_landscape">48dp</dimen>
<!-- Width of the navigation bar when it is placed vertically on the screen -->
<dimen name="navigation_bar_width">48dp</dimen>
+ <!-- How much we expand the touchable region of the status bar below the notch to catch touches
+ that just start below the notch. -->
+ <dimen name="display_cutout_touchable_region_size">12dp</dimen>
<!-- EXPERIMENT BEGIN -->
<!-- Height of the bottom navigation bar frame; this is different than navigation_bar_height
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 4188bd4..874bde1 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1750,6 +1750,7 @@
<java-symbol type="dimen" name="navigation_bar_height_landscape_car_mode" />
<java-symbol type="dimen" name="navigation_bar_width_car_mode" />
<java-symbol type="dimen" name="status_bar_height" />
+ <java-symbol type="dimen" name="display_cutout_touchable_region_size" />
<java-symbol type="dimen" name="quick_qs_offset_height" />
<java-symbol type="dimen" name="quick_qs_total_height" />
<java-symbol type="drawable" name="ic_jog_dial_sound_off" />
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 1a865ee..116ccd2 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -985,10 +985,6 @@
<!-- How much into a DisplayCutout's bounds we can go, on each side -->
<dimen name="display_cutout_margin_consumption">0px</dimen>
- <!-- How much we expand the touchable region of the status bar below the notch to catch touches
- that just start below the notch. -->
- <dimen name="display_cutout_touchable_region_size">12dp</dimen>
-
<!-- Padding below Ongoing App Ops dialog title -->
<dimen name="ongoing_appops_dialog_sep">16dp</dimen>
<!--Padding around text items in Ongoing App Ops dialog -->
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
index 9844d8e..b7a154d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
@@ -140,7 +140,7 @@
mHeadsUpInset = mStatusBarHeight + resources.getDimensionPixelSize(
R.dimen.heads_up_status_bar_padding);
mDisplayCutoutTouchableRegionSize = resources.getDimensionPixelSize(
- R.dimen.display_cutout_touchable_region_size);
+ com.android.internal.R.dimen.display_cutout_touchable_region_size);
}
@Override
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 1888e94..cb069fa 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -2544,6 +2544,7 @@
*/
public void onOverlayChangedLw() {
onConfigurationChanged();
+ mSystemGestures.onConfigurationChanged();
}
/**
diff --git a/services/core/java/com/android/server/wm/SystemGesturesPointerEventListener.java b/services/core/java/com/android/server/wm/SystemGesturesPointerEventListener.java
index bd4e542..35afaed 100644
--- a/services/core/java/com/android/server/wm/SystemGesturesPointerEventListener.java
+++ b/services/core/java/com/android/server/wm/SystemGesturesPointerEventListener.java
@@ -17,9 +17,13 @@
package com.android.server.wm;
import android.content.Context;
+import android.graphics.Rect;
+import android.hardware.display.DisplayManagerGlobal;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Slog;
+import android.view.Display;
+import android.view.DisplayCutout;
import android.view.GestureDetector;
import android.view.InputDevice;
import android.view.MotionEvent;
@@ -46,8 +50,9 @@
private final Context mContext;
private final Handler mHandler;
- private final int mSwipeStartThreshold;
- private final int mSwipeDistanceThreshold;
+ private int mDisplayCutoutTouchableRegionSize;
+ private int mSwipeStartThreshold;
+ private int mSwipeDistanceThreshold;
private final Callbacks mCallbacks;
private final int[] mDownPointerId = new int[MAX_TRACKED_POINTERS];
private final float[] mDownX = new float[MAX_TRACKED_POINTERS];
@@ -65,14 +70,33 @@
private long mLastFlingTime;
SystemGesturesPointerEventListener(Context context, Handler handler, Callbacks callbacks) {
- mContext = context;
+ mContext = checkNull("context", context);
mHandler = handler;
mCallbacks = checkNull("callbacks", callbacks);
- mSwipeStartThreshold = checkNull("context", context).getResources()
+
+ onConfigurationChanged();
+ }
+
+ void onConfigurationChanged() {
+ mSwipeStartThreshold = mContext.getResources()
.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+
+ final Display display = DisplayManagerGlobal.getInstance()
+ .getRealDisplay(Display.DEFAULT_DISPLAY);
+ final DisplayCutout displayCutout = display.getCutout();
+ if (displayCutout != null) {
+ final Rect bounds = displayCutout.getBoundingRectTop();
+ if (!bounds.isEmpty()) {
+ // Expand swipe start threshold such that we can catch touches that just start below
+ // the notch area
+ mDisplayCutoutTouchableRegionSize = mContext.getResources().getDimensionPixelSize(
+ com.android.internal.R.dimen.display_cutout_touchable_region_size);
+ mSwipeStartThreshold += mDisplayCutoutTouchableRegionSize;
+ }
+ }
mSwipeDistanceThreshold = mSwipeStartThreshold;
if (DEBUG) Slog.d(TAG, "mSwipeStartThreshold=" + mSwipeStartThreshold
- + " mSwipeDistanceThreshold=" + mSwipeDistanceThreshold);
+ + " mSwipeDistanceThreshold=" + mSwipeDistanceThreshold);
}
private static <T> T checkNull(String name, T arg) {