diff options
| author | 2023-02-24 23:06:35 +0000 | |
|---|---|---|
| committer | 2023-02-28 18:49:44 +0000 | |
| commit | 39095da3a8504022bca842d3cde8a8be76e0c288 (patch) | |
| tree | 2b926556ae64b42b71924d3099ad16924c17af1f /packages/SettingsLib/src | |
| parent | 51095e26de1c735c4ce11f8c2649bb131f17cb4e (diff) | |
Do not announce a11y move instructions in sensor area.
Test: manually test by enabling talkback
Bug: 270437012
Change-Id: I548e9e51fb564c5969cf9665c1af945688a4607f
Diffstat (limited to 'packages/SettingsLib/src')
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/udfps/UdfpsUtils.java | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/udfps/UdfpsUtils.java b/packages/SettingsLib/src/com/android/settingslib/udfps/UdfpsUtils.java index dc8a862d72c7..31f014c27a13 100644 --- a/packages/SettingsLib/src/com/android/settingslib/udfps/UdfpsUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/udfps/UdfpsUtils.java @@ -62,16 +62,7 @@ public class UdfpsUtils { */ public Point getTouchInNativeCoordinates(int idx, MotionEvent event, UdfpsOverlayParams udfpsOverlayParams) { - Point portraitTouch = new Point((int) event.getRawX(idx), (int) event.getRawY(idx)); - int rot = udfpsOverlayParams.getRotation(); - if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) { - RotationUtils.rotatePoint( - portraitTouch, - RotationUtils.deltaRotation(rot, Surface.ROTATION_0), - udfpsOverlayParams.getLogicalDisplayWidth(), - udfpsOverlayParams.getLogicalDisplayHeight() - ); - } + Point portraitTouch = getPortraitTouch(idx, event, udfpsOverlayParams); // Scale the coordinates to native resolution. float scale = udfpsOverlayParams.getScaleFactor(); @@ -81,13 +72,25 @@ public class UdfpsUtils { } /** + * @param idx The pointer identifier. + * @param event The MotionEvent object containing full information about the event. + * @param udfpsOverlayParams The [UdfpsOverlayParams] used. + * @return Whether the touch event is within sensor area. + */ + public boolean isWithinSensorArea(int idx, MotionEvent event, + UdfpsOverlayParams udfpsOverlayParams) { + Point portraitTouch = getPortraitTouch(idx, event, udfpsOverlayParams); + return udfpsOverlayParams.getSensorBounds().contains(portraitTouch.x, portraitTouch.y); + } + + /** * This function computes the angle of touch relative to the sensor and maps the angle to a list * of help messages which are announced if accessibility is enabled. * * @return Whether the announcing string is null */ - public String onTouchOutsideOfSensorArea(boolean touchExplorationEnabled, - Context context, int touchX, int touchY, UdfpsOverlayParams udfpsOverlayParams) { + public String onTouchOutsideOfSensorArea(boolean touchExplorationEnabled, Context context, + int scaledTouchX, int scaledTouchY, UdfpsOverlayParams udfpsOverlayParams) { if (!touchExplorationEnabled) { return null; } @@ -106,8 +109,8 @@ public class UdfpsUtils { String theStr = onTouchOutsideOfSensorAreaImpl( touchHints, - touchX, - touchY, + scaledTouchX, + scaledTouchY, scaledSensorX, scaledSensorY, udfpsOverlayParams.getRotation() @@ -156,4 +159,22 @@ public class UdfpsUtils { } return touchHints[index]; } + + /** + * Map the touch to portrait mode if the device is in landscape mode. + */ + private Point getPortraitTouch(int idx, MotionEvent event, + UdfpsOverlayParams udfpsOverlayParams) { + Point portraitTouch = new Point((int) event.getRawX(idx), (int) event.getRawY(idx)); + int rot = udfpsOverlayParams.getRotation(); + if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) { + RotationUtils.rotatePoint( + portraitTouch, + RotationUtils.deltaRotation(rot, Surface.ROTATION_0), + udfpsOverlayParams.getLogicalDisplayWidth(), + udfpsOverlayParams.getLogicalDisplayHeight() + ); + } + return portraitTouch; + } } |