diff --git a/res/layout/udfps_enroll_view.xml b/res/layout/udfps_enroll_view.xml
index e1c21526cc2..6bf339b6b07 100644
--- a/res/layout/udfps_enroll_view.xml
+++ b/res/layout/udfps_enroll_view.xml
@@ -20,15 +20,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
-
{
+ // Map the touch to portrait mode if the device is in
+ // landscape mode.
+ final Point scaledTouch =
+ mUdfpsUtils.getTouchInNativeCoordinates(event.getPointerId(0),
+ event, udfpsEnrollView.getOverlayParams());
+
+ final String theStr = mUdfpsUtils.onTouchOutsideOfSensorArea(
+ mAccessibilityManager.isTouchExplorationEnabled(), context,
+ scaledTouch.x, scaledTouch.y, udfpsEnrollView.getOverlayParams());
+ if (theStr != null) {
+ v.announceForAccessibility(theStr);
+ }
+ return false;
+ };
+
+ enrollLayout.findManagedViewById(isLandscape ? R.id.sud_landscape_content_area
+ : R.id.sud_layout_content).setOnHoverListener(onHoverListener);
+ }
+
public static class IconTouchDialog extends InstrumentedDialogFragment {
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollView.java b/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollView.java
index 3d77f0e8b63..96b49aa0edf 100644
--- a/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollView.java
+++ b/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollView.java
@@ -25,7 +25,6 @@ import android.util.AttributeSet;
import android.util.RotationUtils;
import android.view.Gravity;
import android.view.Surface;
-import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -34,11 +33,13 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.settings.R;
+import com.android.settingslib.udfps.UdfpsOverlayParams;
/**
* View corresponding with udfps_enroll_view.xml
*/
public class UdfpsEnrollView extends FrameLayout implements UdfpsEnrollHelper.Listener {
+ private static final String TAG = "UdfpsEnrollView";
@NonNull
private final UdfpsEnrollDrawable mFingerprintDrawable;
@NonNull
@@ -98,12 +99,15 @@ public class UdfpsEnrollView extends FrameLayout implements UdfpsEnrollHelper.Li
onFingerDown();
}
-
@Override
public void onPointerUp(int sensorId) {
onFingerUp();
}
+ public UdfpsOverlayParams getOverlayParams() {
+ return mOverlayParams;
+ }
+
void setOverlayParams(UdfpsOverlayParams params) {
mOverlayParams = params;
@@ -124,7 +128,6 @@ public class UdfpsEnrollView extends FrameLayout implements UdfpsEnrollHelper.Li
private void onSensorRectUpdated() {
updateDimensions();
- updateAccessibilityViewLocation();
// Updates sensor rect in relation to the overlay view
mSensorRect.set(getPaddingX(), getPaddingY(),
@@ -135,7 +138,7 @@ public class UdfpsEnrollView extends FrameLayout implements UdfpsEnrollHelper.Li
private void updateDimensions() {
// Original sensorBounds assume portrait mode.
- final Rect rotatedBounds = mOverlayParams.getSensorBounds();
+ final Rect rotatedBounds = new Rect(mOverlayParams.getSensorBounds());
int rotation = mOverlayParams.getRotation();
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
RotationUtils.rotateBounds(
@@ -192,27 +195,14 @@ public class UdfpsEnrollView extends FrameLayout implements UdfpsEnrollHelper.Li
setLayoutParams(params);
}
- private void updateAccessibilityViewLocation() {
- View fingerprintAccessibilityView = findViewById(R.id.udfps_enroll_accessibility_view);
- ViewGroup.LayoutParams params = fingerprintAccessibilityView.getLayoutParams();
- params.width = mOverlayParams.getSensorBounds().width();
- params.height = mOverlayParams.getSensorBounds().height();
- fingerprintAccessibilityView.setLayoutParams(params);
- fingerprintAccessibilityView.requestLayout();
- }
-
private void onFingerDown() {
- if (mOverlayParams.isOptical()) {
- mFingerprintDrawable.setShouldSkipDraw(true);
- mFingerprintDrawable.invalidateSelf();
- }
+ mFingerprintDrawable.setShouldSkipDraw(true);
+ mFingerprintDrawable.invalidateSelf();
}
private void onFingerUp() {
- if (mOverlayParams.isOptical()) {
- mFingerprintDrawable.setShouldSkipDraw(false);
- mFingerprintDrawable.invalidateSelf();
- }
+ mFingerprintDrawable.setShouldSkipDraw(false);
+ mFingerprintDrawable.invalidateSelf();
}
private int getPaddingX() {
diff --git a/src/com/android/settings/biometrics/fingerprint/UdfpsOverlayParams.java b/src/com/android/settings/biometrics/fingerprint/UdfpsOverlayParams.java
deleted file mode 100644
index 9b52ad62302..00000000000
--- a/src/com/android/settings/biometrics/fingerprint/UdfpsOverlayParams.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.biometrics.fingerprint;
-
-import android.graphics.Rect;
-
-import androidx.annotation.NonNull;
-
-/**
- * Collection of parameters that define an under-display fingerprint sensor (UDFPS) overlay.
- *
- * [sensorBounds] coordinates of the bounding box around the sensor in natural orientation, in
- * pixels, for the current resolution.
- *
- * [overlayBounds] coordinates of the UI overlay in natural orientation, in pixels, for the current
- * resolution.
- *
- * [naturalDisplayWidth] width of the physical display in natural orientation, in pixels, for the
- * current resolution.
- *
- * [naturalDisplayHeight] height of the physical display in natural orientation, in pixels, for the
- * current resolution.
- *
- * [scaleFactor] ratio of a dimension in the current resolution to the corresponding dimension in
- * the native resolution.
- *
- * [rotation] current rotation of the display.
- */
-public final class UdfpsOverlayParams {
- @NonNull
- private final Rect mSensorBounds;
- @NonNull
- private final Rect mOverlayBounds;
- private final int mNaturalDisplayWidth;
- private final int mNaturalDisplayHeight;
- private final float mScaleFactor;
- private final int mRotation;
- private final boolean mIsOptical;
-
- public UdfpsOverlayParams(@NonNull Rect sensorBounds, @NonNull Rect overlayBounds,
- int naturalDisplayWidth, int naturalDisplayHeight, float scaleFactor, int rotation,
- boolean isOptical) {
- mSensorBounds = sensorBounds;
- mOverlayBounds = overlayBounds;
- mNaturalDisplayWidth = naturalDisplayWidth;
- mNaturalDisplayHeight = naturalDisplayHeight;
- mScaleFactor = scaleFactor;
- mRotation = rotation;
- mIsOptical = isOptical;
- }
-
- @NonNull
- public Rect getSensorBounds() {
- return mSensorBounds;
- }
-
- @NonNull
- public Rect getOverlayBounds() {
- return mOverlayBounds;
- }
-
- public int getNaturalDisplayWidth() {
- return mNaturalDisplayWidth;
- }
-
- public int getNaturalDisplayHeight() {
- return mNaturalDisplayHeight;
- }
-
- public float getScaleFactor() {
- return mScaleFactor;
- }
-
- public int getRotation() {
- return mRotation;
- }
-
- public boolean isOptical() {
- return mIsOptical;
- }
-}