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

Commit 82990e4f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only enable UDFPS display mode for optical sensors" into tm-qpr-dev-plus-aosp

parents 2e770854 21a710db
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -777,13 +777,16 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
    private void updateUdfpsLocation() {
        if (mUdfpsController != null) {
            final FingerprintSensorPropertiesInternal udfpsProp = mUdfpsProps.get(0);

            final Rect previousUdfpsBounds = mUdfpsBounds;
            mUdfpsBounds = udfpsProp.getLocation().getRect();
            mUdfpsBounds.scale(mScaleFactor);
            mUdfpsController.updateOverlayParams(udfpsProp.sensorId,
                    new UdfpsOverlayParams(mUdfpsBounds, mCachedDisplayInfo.getNaturalWidth(),
                            mCachedDisplayInfo.getNaturalHeight(), mScaleFactor,
                            mCachedDisplayInfo.rotation));

            final UdfpsOverlayParams overlayParams = new UdfpsOverlayParams(mUdfpsBounds,
                    mCachedDisplayInfo.getNaturalWidth(), mCachedDisplayInfo.getNaturalHeight(),
                    mScaleFactor, mCachedDisplayInfo.rotation);

            mUdfpsController.updateOverlayParams(udfpsProp, overlayParams);
            if (!Objects.equals(previousUdfpsBounds, mUdfpsBounds)) {
                for (Callback cb : mCallbacks) {
                    cb.onUdfpsLocationChanged();
+50 −22
Original line number Diff line number Diff line
@@ -23,16 +23,17 @@ import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.systemui.classifier.Classifier.LOCK_ICON;
import static com.android.systemui.classifier.Classifier.UDFPS_AUTHENTICATION;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Point;
import android.hardware.biometrics.BiometricFingerprintConstants;
import android.hardware.biometrics.SensorProperties;
import android.hardware.display.DisplayManager;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorProperties;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.IUdfpsOverlayController;
import android.hardware.fingerprint.IUdfpsOverlayControllerCallback;
import android.os.Handler;
@@ -50,10 +51,14 @@ import android.view.VelocityTracker;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.LatencyTracker;
import com.android.keyguard.FaceAuthApiRequestReason;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Dumpable;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.biometrics.dagger.BiometricsBackground;
import com.android.systemui.dagger.SysUISingleton;
@@ -77,6 +82,8 @@ import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.Execution;
import com.android.systemui.util.time.SystemClock;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
@@ -99,7 +106,7 @@ import kotlin.Unit;
 */
@SuppressWarnings("deprecation")
@SysUISingleton
public class UdfpsController implements DozeReceiver {
public class UdfpsController implements DozeReceiver, Dumpable {
    private static final String TAG = "UdfpsController";
    private static final long AOD_INTERRUPT_TIMEOUT_MILLIS = 1000;

@@ -137,7 +144,7 @@ public class UdfpsController implements DozeReceiver {

    // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple
    // sensors, this, in addition to a lot of the code here, will be updated.
    @VisibleForTesting int mSensorId;
    @VisibleForTesting @NonNull FingerprintSensorPropertiesInternal mSensorProps;
    @VisibleForTesting @NonNull UdfpsOverlayParams mOverlayParams = new UdfpsOverlayParams();
    // TODO(b/229290039): UDFPS controller should manage its dimensions on its own. Remove this.
    @Nullable private Runnable mAuthControllerUpdateUdfpsLocation;
@@ -202,6 +209,11 @@ public class UdfpsController implements DozeReceiver {
        }
    };

    @Override
    public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
        pw.println("mSensorProps=(" + mSensorProps + ")");
    }

    public class UdfpsOverlayController extends IUdfpsOverlayController.Stub {
        @Override
        public void showUdfpsOverlay(long requestId, int sensorId, int reason,
@@ -249,7 +261,7 @@ public class UdfpsController implements DozeReceiver {
                    }
                    mAcquiredReceived = true;
                    final UdfpsView view = mOverlay.getOverlayView();
                    if (view != null) {
                    if (view != null && isOptical()) {
                        unconfigureDisplay(view);
                    }
                    if (acquiredGood) {
@@ -295,12 +307,13 @@ public class UdfpsController implements DozeReceiver {
    /**
     * Updates the overlay parameters and reconstructs or redraws the overlay, if necessary.
     *
     * @param sensorId      sensor for which the overlay is getting updated.
     * @param sensorProps   sensor for which the overlay is getting updated.
     * @param overlayParams See {@link UdfpsOverlayParams}.
     */
    public void updateOverlayParams(int sensorId, @NonNull UdfpsOverlayParams overlayParams) {
        if (sensorId != mSensorId) {
            mSensorId = sensorId;
    public void updateOverlayParams(@NonNull FingerprintSensorPropertiesInternal sensorProps,
            @NonNull UdfpsOverlayParams overlayParams) {
        if (mSensorProps.sensorId != sensorProps.sensorId) {
            mSensorProps = sensorProps;
            Log.w(TAG, "updateUdfpsParams | sensorId has changed");
        }

@@ -324,7 +337,7 @@ public class UdfpsController implements DozeReceiver {
        mAuthControllerUpdateUdfpsLocation = r;
    }

    public void setUdfpsDisplayMode(UdfpsDisplayMode udfpsDisplayMode) {
    public void setUdfpsDisplayMode(@Nullable UdfpsDisplayMode udfpsDisplayMode) {
        mUdfpsDisplayMode = udfpsDisplayMode;
    }

@@ -428,7 +441,6 @@ public class UdfpsController implements DozeReceiver {
        }

        final UdfpsView udfpsView = mOverlay.getOverlayView();
        final boolean isDisplayConfigured = udfpsView.isDisplayConfigured();
        boolean handled = false;
        switch (event.getActionMasked()) {
            case MotionEvent.ACTION_OUTSIDE:
@@ -512,15 +524,14 @@ public class UdfpsController implements DozeReceiver {
                                "minor: %.1f, major: %.1f, v: %.1f, exceedsVelocityThreshold: %b",
                                minor, major, v, exceedsVelocityThreshold);
                        final long sinceLastLog = mSystemClock.elapsedRealtime() - mTouchLogTime;
                        if (!isDisplayConfigured && !mAcquiredReceived
                                && !exceedsVelocityThreshold) {

                        if (!mOnFingerDown && !mAcquiredReceived && !exceedsVelocityThreshold) {
                            final float scale = mOverlayParams.getScaleFactor();
                            float scaledMinor = minor / scale;
                            float scaledMajor = major / scale;

                            onFingerDown(requestId, scaledTouch.x, scaledTouch.y, scaledMinor,
                                    scaledMajor);

                            Log.v(TAG, "onTouch | finger down: " + touchInfo);
                            mTouchLogTime = mSystemClock.elapsedRealtime();
                            handled = true;
@@ -614,7 +625,7 @@ public class UdfpsController implements DozeReceiver {
            @NonNull LatencyTracker latencyTracker,
            @NonNull ActivityLaunchAnimator activityLaunchAnimator,
            @NonNull Optional<AlternateUdfpsTouchProvider> alternateTouchProvider,
            @BiometricsBackground Executor biometricsExecutor,
            @NonNull @BiometricsBackground Executor biometricsExecutor,
            @NonNull BouncerInteractor bouncerInteractor) {
        mContext = context;
        mExecution = execution;
@@ -644,10 +655,20 @@ public class UdfpsController implements DozeReceiver {
        mLatencyTracker = latencyTracker;
        mActivityLaunchAnimator = activityLaunchAnimator;
        mAlternateTouchProvider = alternateTouchProvider.orElse(null);
        mSensorProps = new FingerprintSensorPropertiesInternal(
                -1 /* sensorId */,
                SensorProperties.STRENGTH_CONVENIENCE,
                0 /* maxEnrollmentsPerUser */,
                new ArrayList<>() /* componentInfo */,
                FingerprintSensorProperties.TYPE_UNKNOWN,
                false /* resetLockoutRequiresHardwareAuthToken */);

        mBiometricExecutor = biometricsExecutor;
        mFeatureFlags = featureFlags;
        mBouncerInteractor = bouncerInteractor;

        mDumpManager.registerDumpable(TAG, this);

        mOrientationListener = new BiometricDisplayListener(
                context,
                displayManager,
@@ -843,6 +864,10 @@ public class UdfpsController implements DozeReceiver {
        mIsAodInterruptActive = false;
    }

    private boolean isOptical() {
        return mSensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
    }

    public boolean isFingerDown() {
        return mOnFingerDown;
    }
@@ -859,7 +884,9 @@ public class UdfpsController implements DozeReceiver {
                    + " current: " + mOverlay.getRequestId());
            return;
        }
        if (isOptical()) {
            mLatencyTracker.onActionStart(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
        }
        // Refresh screen timeout and boost process priority if possible.
        mPowerManager.userActivity(mSystemClock.uptimeMillis(),
                PowerManager.USER_ACTIVITY_EVENT_TOUCH, 0);
@@ -882,11 +909,11 @@ public class UdfpsController implements DozeReceiver {
                }
            });
        } else {
            mFingerprintManager.onPointerDown(requestId, mSensorId, x, y, minor, major);
            mFingerprintManager.onPointerDown(requestId, mSensorProps.sensorId, x, y, minor, major);
        }
        Trace.endAsyncSection("UdfpsController.e2e.onPointerDown", 0);
        final UdfpsView view = mOverlay.getOverlayView();
        if (view != null) {
        if (view != null && isOptical()) {
            view.configureDisplay(() -> {
                if (mAlternateTouchProvider != null) {
                    mBiometricExecutor.execute(() -> {
@@ -894,7 +921,7 @@ public class UdfpsController implements DozeReceiver {
                        mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
                    });
                } else {
                    mFingerprintManager.onUiReady(requestId, mSensorId);
                    mFingerprintManager.onUiReady(requestId, mSensorProps.sensorId);
                    mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
                }
            });
@@ -920,15 +947,16 @@ public class UdfpsController implements DozeReceiver {
                    }
                });
            } else {
                mFingerprintManager.onPointerUp(requestId, mSensorId);
                mFingerprintManager.onPointerUp(requestId, mSensorProps.sensorId);
            }
            for (Callback cb : mCallbacks) {
                cb.onFingerUp();
            }
        }
        mOnFingerDown = false;
        if (isOptical()) {
            unconfigureDisplay(view);

        }
    }

    /**
+236 −102

File changed.

Preview size limit exceeded, changes collapsed.