Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b901daf1 authored by Austin Delgado's avatar Austin Delgado Committed by Android (Google) Code Review
Browse files

Merge changes from topic "UdfpsCleanUp" into main

* changes:
  Fix tests related to UDFPS_NEW_TOUCH_DETECTION removal
  Remove AlternateUdfpsTouchProvider
  Remove unused code related to old Udfps on touch
  Remove UDFPS_NEW_TOUCH_DETECTION flag
parents 8f23adcc ac766ac2
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -692,10 +692,10 @@ public class LockIconViewController implements Dumpable {
                mVelocityTracker.addMovement(event);
                // Compute pointer velocity in pixels per second.
                mVelocityTracker.computeCurrentVelocity(1000);
                float velocity = UdfpsController.computePointerSpeed(mVelocityTracker,
                float velocity = computePointerSpeed(mVelocityTracker,
                        mActivePointerId);
                if (event.getClassification() != MotionEvent.CLASSIFICATION_DEEP_PRESS
                        && UdfpsController.exceedsVelocityThreshold(velocity)) {
                        && exceedsVelocityThreshold(velocity)) {
                    Log.v(TAG, "lock icon long-press rescheduled due to "
                            + "high pointer velocity=" + velocity);
                    mLongPressCancelRunnable.run();
@@ -713,6 +713,23 @@ public class LockIconViewController implements Dumpable {
        return true;
    }

    /**
     * Calculate the pointer speed given a velocity tracker and the pointer id.
     * This assumes that the velocity tracker has already been passed all relevant motion events.
     */
    private static float computePointerSpeed(@NonNull VelocityTracker tracker, int pointerId) {
        final float vx = tracker.getXVelocity(pointerId);
        final float vy = tracker.getYVelocity(pointerId);
        return (float) Math.sqrt(Math.pow(vx, 2.0) + Math.pow(vy, 2.0));
    }

    /**
     * Whether the velocity exceeds the acceptable UDFPS debouncing threshold.
     */
    private static boolean exceedsVelocityThreshold(float velocity) {
        return velocity > 750f;
    }

    private boolean actionableDownEventStartedOnView(MotionEvent event) {
        if (!isActionable()) {
            return false;
+0 −54
Original line number Diff line number Diff line
/*
 * 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.systemui.biometrics

/**
 * Interface for controlling the on finger down & on finger up events.
 */
interface AlternateUdfpsTouchProvider {

    /**
     * onPointerDown:
     *
     * This operation is used to notify the Fingerprint HAL that
     * a fingerprint has been detected on the device's screen.
     *
     * See fingerprint/ISession#onPointerDown for more details.
     */
    fun onPointerDown(pointerId: Long, x: Int, y: Int, minor: Float, major: Float)

    /**
     * onPointerUp:
     *
     * This operation can be invoked when the HAL is performing any one of: ISession#authenticate,
     * ISession#enroll, ISession#detectInteraction. This operation is used to indicate
     * that a fingerprint that was previously down, is now up.
     *
     * See fingerprint/ISession#onPointerUp for more details.
     */
    fun onPointerUp(pointerId: Long)

    /**
     * onUiReady:
     *
     * This operation is used by the callee to notify the Fingerprint HAL that SystemUI is
     * correctly configured for the fingerprint capture.
     *
     * See fingerprint/ISession#onUiReady for more details.
     */
    fun onUiReady()
}
+0 −3
Original line number Diff line number Diff line
@@ -37,9 +37,6 @@ public abstract class UdfpsAnimationView extends FrameLayout {
    private float mDialogSuggestedAlpha = 1f;
    private float mNotificationShadeExpansion = 0f;

    // Used for Udfps ellipse detection when flag is true, set by AnimationViewController
    boolean mUseExpandedOverlay = false;

    // mAlpha takes into consideration the status bar expansion amount and dialog suggested alpha
    private int mAlpha;
    boolean mPauseAuth;
+15 −283

File changed.

Preview size limit exceeded, changes collapsed.

+18 −58
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.SuppressLint
import android.annotation.UiThread
import android.content.Context
import android.graphics.PixelFormat
import android.graphics.Point
import android.graphics.Rect
import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_BP
import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_KEYGUARD
@@ -29,7 +28,6 @@ import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_SETTING
import android.hardware.biometrics.BiometricOverlayConstants.REASON_ENROLL_ENROLLING
import android.hardware.biometrics.BiometricOverlayConstants.REASON_ENROLL_FIND_SENSOR
import android.hardware.biometrics.BiometricOverlayConstants.ShowReason
import android.hardware.fingerprint.FingerprintManager
import android.hardware.fingerprint.IUdfpsOverlayControllerCallback
import android.os.Build
import android.os.RemoteException
@@ -54,7 +52,6 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.flags.Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS
import com.android.systemui.keyguard.ui.adapter.UdfpsKeyguardViewControllerAdapter
import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardViewModels
@@ -65,7 +62,6 @@ import com.android.systemui.statusbar.phone.SystemUIDialogManager
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.settings.SecureSettings
import kotlinx.coroutines.ExperimentalCoroutinesApi
import javax.inject.Provider

@@ -83,7 +79,6 @@ const val SETTING_REMOVE_ENROLLMENT_UI = "udfps_overlay_remove_enrollment_ui"
@UiThread
class UdfpsControllerOverlay @JvmOverloads constructor(
        private val context: Context,
        fingerprintManager: FingerprintManager,
        private val inflater: LayoutInflater,
        private val windowManager: WindowManager,
        private val accessibilityManager: AccessibilityManager,
@@ -97,7 +92,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
        private val keyguardStateController: KeyguardStateController,
        private val unlockedScreenOffAnimationController: UnlockedScreenOffAnimationController,
        private var udfpsDisplayModeProvider: UdfpsDisplayModeProvider,
        private val secureSettings: SecureSettings,
        val requestId: Long,
        @ShowReason val requestReason: Int,
        private val controllerCallback: IUdfpsOverlayControllerCallback,
@@ -107,7 +101,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
        private val primaryBouncerInteractor: PrimaryBouncerInteractor,
        private val alternateBouncerInteractor: AlternateBouncerInteractor,
        private val isDebuggable: Boolean = Build.IS_DEBUGGABLE,
        private val udfpsUtils: UdfpsUtils,
        private val udfpsKeyguardAccessibilityDelegate: UdfpsKeyguardAccessibilityDelegate,
        private val udfpsKeyguardViewModels: Provider<UdfpsKeyguardViewModels>,
) {
@@ -134,11 +127,8 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
        privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY
        // Avoid announcing window title.
        accessibilityTitle = " "

        if (featureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)) {
        inputFeatures = WindowManager.LayoutParams.INPUT_FEATURE_SPY
    }
    }

    /** If the overlay is currently showing. */
    val isShowing: Boolean
@@ -206,7 +196,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
                        overlayTouchListener!!
                    )
                    overlayTouchListener?.onTouchExplorationStateChanged(true)
                    useExpandedOverlay = featureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)
                }
            } catch (e: RuntimeException) {
                Log.e(TAG, "showUdfpsOverlay | failed to add window", e)
@@ -331,25 +320,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
        return wasShowing
    }

    /**
     * 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.
     *
     */
    fun onTouchOutsideOfSensorArea(scaledTouch: Point) {
        val theStr =
            udfpsUtils.onTouchOutsideOfSensorArea(
                touchExplorationEnabled,
                context,
                scaledTouch.x,
                scaledTouch.y,
                overlayParams
            )
        if (theStr != null) {
            animationViewController?.doAnnounceForAccessibility(theStr)
        }
    }

    /** Cancel this request. */
    fun cancel() {
        try {
@@ -367,10 +337,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
    ): WindowManager.LayoutParams {
        val paddingX = animation?.paddingX ?: 0
        val paddingY = animation?.paddingY ?: 0
        if (!featureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION) && animation != null &&
                animation.listenForTouchesOutsideView()) {
            flags = flags or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
        }

        val isEnrollment = when (requestReason) {
            REASON_ENROLL_FIND_SENSOR, REASON_ENROLL_ENROLLING -> true
@@ -379,7 +345,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(

        // Use expanded overlay unless touchExploration enabled
        var rotatedBounds =
            if (featureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)) {
            if (accessibilityManager.isTouchExplorationEnabled && isEnrollment) {
                Rect(overlayParams.sensorBounds)
            } else {
@@ -390,9 +355,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
                    overlayParams.naturalDisplayHeight
                )
            }
            } else {
                Rect(overlayParams.sensorBounds)
            }

        val rot = overlayParams.rotation
        if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) {
@@ -412,7 +374,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
                    rot
                )

                if (featureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)) {
                RotationUtils.rotateBounds(
                    sensorBounds,
                    overlayParams.naturalDisplayWidth,
@@ -421,7 +382,6 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
                )
            }
        }
        }

        x = rotatedBounds.left - paddingX
        y = rotatedBounds.top - paddingY
Loading