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

Commit 96037a46 authored by Robert Snoeberger's avatar Robert Snoeberger
Browse files

UDFPS on AOD

This change establishes a connection between the AOD interrupt and the fingerprint sensor.

Bug: 165267247
Test: manual - enter device from AOD with fingerprint
Test: manual - On AOD, fail fingerprint auth, check that HBM turns off
Change-Id: Ia8ca9a145590d8b5629a584807e110ca3600b813
parent 0e3e197c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -137,6 +137,11 @@ public class AmbientDisplayConfiguration {
        return mContext.getResources().getString(R.string.config_dozeLongPressSensorType);
    }

    /** {@hide} */
    public String udfpsLongPressSensorType() {
        return mContext.getResources().getString(R.string.config_dozeUdfpsLongPressSensorType);
    }

    /** {@hide} */
    public boolean pulseOnLongPressEnabled(int user) {
        return pulseOnLongPressAvailable() && boolSettingDefaultOff(
+4 −1
Original line number Diff line number Diff line
@@ -2127,6 +2127,9 @@
    <!-- Type of the long press sensor. Empty if long press is not supported. -->
    <string name="config_dozeLongPressSensorType" translatable="false"></string>

    <!-- Type of the udfps long press sensor. Empty if long press is not supported. -->
    <string name="config_dozeUdfpsLongPressSensorType" translatable="false"></string>

    <!-- If the sensor that wakes up the lock screen is available or not. -->
    <bool name="config_dozeWakeLockScreenSensorAvailable">false</bool>
    <integer name="config_dozeWakeLockScreenDebounce">300</integer>
+1 −0
Original line number Diff line number Diff line
@@ -3484,6 +3484,7 @@
  <java-symbol type="array" name="config_hideWhenDisabled_packageNames" />

  <java-symbol type="string" name="config_dozeLongPressSensorType" />
  <java-symbol type="string" name="config_dozeUdfpsLongPressSensorType" />
  <java-symbol type="bool" name="config_dozeWakeLockScreenSensorAvailable" />
  <java-symbol type="integer" name="config_dozeWakeLockScreenDebounce" />

+40 −4
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import com.android.systemui.statusbar.CommandQueue;
import java.util.List;

import javax.inject.Inject;
import javax.inject.Provider;

/**
 * Receives messages sent from {@link com.android.server.biometrics.BiometricService} and shows the
@@ -72,6 +73,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    private final CommandQueue mCommandQueue;
    private final StatusBarStateController mStatusBarStateController;
    private final Injector mInjector;
    private final Provider<UdfpsController> mUdfpsControllerFactory;

    // TODO: These should just be saved from onSaveState
    private SomeArgs mCurrentDialogArgs;
@@ -237,6 +239,34 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        }
    }

    /**
     * Requests fingerprint scan.
     *
     * @param screenX X position of long press
     * @param screenY Y position of long press
     */
    public void onAodInterrupt(int screenX, int screenY) {
        if (mUdfpsController == null) {
            return;
        }
        mUdfpsController.onAodInterrupt(screenX, screenY);
    }

    /**
     * Cancel a fingerprint scan.
     *
     * The sensor that triggers an AOD interrupt for fingerprint doesn't give
     * ACTION_UP/ACTION_CANCEL events, so the scan needs to be cancelled manually. This should be
     * called when authentication either succeeds or fails. Failing to cancel the scan will leave
     * the screen in high brightness mode.
     */
    private void onCancelAodInterrupt() {
        if (mUdfpsController == null) {
            return;
        }
        mUdfpsController.onCancelAodInterrupt();
    }

    private void sendResultAndCleanUp(@DismissedReason int reason,
            @Nullable byte[] credentialAttestation) {
        if (mReceiver == null) {
@@ -263,17 +293,21 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,

    @Inject
    public AuthController(Context context, CommandQueue commandQueue,
            StatusBarStateController statusBarStateController) {
        this(context, commandQueue, statusBarStateController, new Injector());
            StatusBarStateController statusBarStateController,
            Provider<UdfpsController> udfpsControllerFactory) {
        this(context, commandQueue, statusBarStateController, new Injector(),
                udfpsControllerFactory);
    }

    @VisibleForTesting
    AuthController(Context context, CommandQueue commandQueue,
            StatusBarStateController statusBarStateController, Injector injector) {
            StatusBarStateController statusBarStateController, Injector injector,
            Provider<UdfpsController> udfpsControllerFactory) {
        super(context);
        mCommandQueue = commandQueue;
        mStatusBarStateController = statusBarStateController;
        mInjector = injector;
        mUdfpsControllerFactory = udfpsControllerFactory;

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
@@ -294,7 +328,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                    fpm.getSensorProperties();
            for (FingerprintSensorProperties props : fingerprintSensorProperties) {
                if (props.sensorType == FingerprintSensorProperties.TYPE_UDFPS) {
                    mUdfpsController = new UdfpsController(mContext, mStatusBarStateController);
                    mUdfpsController = mUdfpsControllerFactory.get();
                    break;
                }
            }
@@ -341,6 +375,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    @Override
    public void onBiometricAuthenticated() {
        mCurrentDialog.onAuthenticationSucceeded();
        onCancelAodInterrupt();
    }

    @Override
@@ -390,6 +425,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
            if (DEBUG) Log.d(TAG, "onBiometricError, hard error: " + errorMessage);
            mCurrentDialog.onError(errorMessage);
        }
        onCancelAodInterrupt();
    }

    @Override
+45 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import java.io.FileWriter;
import java.io.IOException;

import javax.inject.Inject;

/**
 * Shows and hides the under-display fingerprint sensor (UDFPS) overlay, handles UDFPS touch events,
 * and coordinates triggering of the high-brightness mode (HBM).
@@ -54,6 +56,7 @@ class UdfpsController implements DozeReceiver {
    private static final String TAG = "UdfpsController";
    // Gamma approximation for the sRGB color space.
    private static final float DISPLAY_GAMMA = 2.2f;
    private static final long AOD_INTERRUPT_TIMEOUT_MILLIS = 1000;

    private final FingerprintManager mFingerprintManager;
    private final WindowManager mWindowManager;
@@ -80,6 +83,13 @@ class UdfpsController implements DozeReceiver {
    private final float mDefaultBrightness;
    private boolean mIsOverlayShowing;

    // The fingerprint AOD trigger doesn't provide an ACTION_UP/ACTION_CANCEL event to tell us when
    // to turn off high brightness mode. To get around this limitation, the state of the AOD
    // interrupt is being tracked and a timeout is used as a last resort to turn off high brightness
    // mode.
    private boolean mIsAodInterruptActive;
    private final Runnable mAodInterruptTimeoutAction = this::onCancelAodInterrupt;

    public class UdfpsOverlayController extends IUdfpsOverlayController.Stub {
        @Override
        public void showUdfpsOverlay() {
@@ -126,6 +136,7 @@ class UdfpsController implements DozeReceiver {
        }
    };

    @Inject
    UdfpsController(@NonNull Context context,
            @NonNull StatusBarStateController statusBarStateController) {
        mFingerprintManager = context.getSystemService(FingerprintManager.class);
@@ -240,6 +251,40 @@ class UdfpsController implements DozeReceiver {
        return BrightnessSynchronizer.brightnessFloatToInt(scrimOpacity);
    }

    /**
     * Request fingerprint scan.
     *
     * This is intented to be called in response to a sensor that triggers an AOD interrupt for the
     * fingerprint sensor.
     */
    void onAodInterrupt(int screenX, int screenY) {
        if (mIsAodInterruptActive) {
            return;
        }
        mIsAodInterruptActive = true;
        // Since the sensor that triggers the AOD interrupt doesn't provide ACTION_UP/ACTION_CANCEL,
        // we need to be careful about not letting the screen accidentally remain in high brightness
        // mode. As a mitigation, queue a call to cancel the fingerprint scan.
        mHandler.postDelayed(mAodInterruptTimeoutAction, AOD_INTERRUPT_TIMEOUT_MILLIS);
        // using a hard-coded value for major and minor until it is available from the sensor
        onFingerDown(screenX, screenY, 13.0f, 13.0f);
    }

    /**
     * Cancel fingerprint scan.
     *
     * This is intented to be called after the fingerprint scan triggered by the AOD interrupt
     * either succeeds or fails.
     */
    void onCancelAodInterrupt() {
        if (!mIsAodInterruptActive) {
            return;
        }
        mHandler.removeCallbacks(mAodInterruptTimeoutAction);
        mIsAodInterruptActive = false;
        onFingerUp();
    }

    private void onFingerDown(int x, int y, float minor, float major) {
        mView.setScrimAlpha(computeScrimOpacity());
        mView.showScrimAndDot();
Loading