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

Commit bf5ad906 authored by Joe Bolinger's avatar Joe Bolinger Committed by Android (Google) Code Review
Browse files

Merge "Consolidate fingerprint overlay controllers." into sc-v2-dev

parents e9abf656 dce40910
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 android.hardware.biometrics;

import android.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Common constants for biometric overlays.
 * @hide
 */
public interface BiometricOverlayConstants {
    /** Unknown usage. */
    int REASON_UNKNOWN = 0;
    /** User is about to enroll. */
    int REASON_ENROLL_FIND_SENSOR = 1;
    /** User is enrolling. */
    int REASON_ENROLL_ENROLLING = 2;
    /** Usage from BiometricPrompt. */
    int REASON_AUTH_BP = 3;
    /** Usage from Keyguard. */
    int REASON_AUTH_KEYGUARD = 4;
    /** Non-specific usage (from FingerprintManager). */
    int REASON_AUTH_OTHER = 5;

    @IntDef({REASON_UNKNOWN,
            REASON_ENROLL_FIND_SENSOR,
            REASON_ENROLL_ENROLLING,
            REASON_AUTH_BP,
            REASON_AUTH_KEYGUARD,
            REASON_AUTH_OTHER})
    @Retention(RetentionPolicy.SOURCE)
    @interface ShowReason {}
}
+0 −7
Original line number Diff line number Diff line
@@ -22,13 +22,6 @@ import android.hardware.fingerprint.IUdfpsOverlayControllerCallback;
 * @hide
 */
oneway interface IUdfpsOverlayController {
    const int REASON_UNKNOWN = 0;
    const int REASON_ENROLL_FIND_SENSOR = 1;
    const int REASON_ENROLL_ENROLLING = 2;
    const int REASON_AUTH_BP = 3; // BiometricPrompt
    const int REASON_AUTH_FPM_KEYGUARD = 4; // FingerprintManager usage from Keyguard
    const int REASON_AUTH_FPM_OTHER = 5; // Other FingerprintManager usage

    // Shows the overlay.
    void showUdfpsOverlay(int sensorId, int reason, IUdfpsOverlayControllerCallback callback);

+13 −12
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.systemui.biometrics;

import static android.hardware.fingerprint.IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD;
import static android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_KEYGUARD;

import static com.android.internal.util.Preconditions.checkArgument;
import static com.android.internal.util.Preconditions.checkNotNull;
@@ -32,6 +32,7 @@ import android.content.IntentFilter;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.RectF;
import android.hardware.biometrics.BiometricOverlayConstants;
import android.hardware.display.DisplayManager;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
@@ -241,8 +242,8 @@ public class UdfpsController implements DozeReceiver {
                @NonNull IUdfpsOverlayControllerCallback callback) {
            mFgExecutor.execute(() -> {
                final UdfpsEnrollHelper enrollHelper;
                if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR
                        || reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING) {
                if (reason == BiometricOverlayConstants.REASON_ENROLL_FIND_SENSOR
                        || reason == BiometricOverlayConstants.REASON_ENROLL_ENROLLING) {
                    enrollHelper = new UdfpsEnrollHelper(mContext, reason);
                } else {
                    enrollHelper = null;
@@ -320,7 +321,7 @@ public class UdfpsController implements DozeReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (mServerRequest != null
                    && mServerRequest.mRequestReason != REASON_AUTH_FPM_KEYGUARD
                    && mServerRequest.mRequestReason != REASON_AUTH_KEYGUARD
                    && Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
                Log.d(TAG, "ACTION_CLOSE_SYSTEM_DIALOGS received, mRequestReason: "
                        + mServerRequest.mRequestReason);
@@ -747,9 +748,9 @@ public class UdfpsController implements DozeReceiver {

                // This view overlaps the sensor area, so prevent it from being selectable
                // during a11y.
                if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR
                        || reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING
                        || reason == IUdfpsOverlayController.REASON_AUTH_BP) {
                if (reason == BiometricOverlayConstants.REASON_ENROLL_FIND_SENSOR
                        || reason == BiometricOverlayConstants.REASON_ENROLL_ENROLLING
                        || reason == BiometricOverlayConstants.REASON_AUTH_BP) {
                    mView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
                }

@@ -767,8 +768,8 @@ public class UdfpsController implements DozeReceiver {

    private UdfpsAnimationViewController inflateUdfpsAnimation(int reason) {
        switch (reason) {
            case IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR:
            case IUdfpsOverlayController.REASON_ENROLL_ENROLLING:
            case BiometricOverlayConstants.REASON_ENROLL_FIND_SENSOR:
            case BiometricOverlayConstants.REASON_ENROLL_ENROLLING:
                UdfpsEnrollView enrollView = (UdfpsEnrollView) mInflater.inflate(
                        R.layout.udfps_enroll_view, null);
                mView.addView(enrollView);
@@ -780,7 +781,7 @@ public class UdfpsController implements DozeReceiver {
                        mStatusBarOptional,
                        mDumpManager
                );
            case IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD:
            case BiometricOverlayConstants.REASON_AUTH_KEYGUARD:
                UdfpsKeyguardView keyguardView = (UdfpsKeyguardView)
                        mInflater.inflate(R.layout.udfps_keyguard_view, null);
                mView.addView(keyguardView);
@@ -799,7 +800,7 @@ public class UdfpsController implements DozeReceiver {
                        mKeyguardStateController,
                        this
                );
            case IUdfpsOverlayController.REASON_AUTH_BP:
            case BiometricOverlayConstants.REASON_AUTH_BP:
                // note: empty controller, currently shows no visual affordance
                UdfpsBpView bpView = (UdfpsBpView) mInflater.inflate(R.layout.udfps_bp_view, null);
                mView.addView(bpView);
@@ -809,7 +810,7 @@ public class UdfpsController implements DozeReceiver {
                        mStatusBarOptional,
                        mDumpManager
                );
            case IUdfpsOverlayController.REASON_AUTH_FPM_OTHER:
            case BiometricOverlayConstants.REASON_AUTH_OTHER:
                UdfpsFpmOtherView authOtherView = (UdfpsFpmOtherView)
                        mInflater.inflate(R.layout.udfps_fpm_other_view, null);
                mView.addView(authOtherView);
+2 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.graphics.PointF;
import android.hardware.fingerprint.IUdfpsOverlayController;
import android.hardware.biometrics.BiometricOverlayConstants;
import android.os.Build;
import android.os.UserHandle;
import android.provider.Settings;
@@ -119,7 +119,7 @@ public class UdfpsEnrollHelper {
    }

    boolean shouldShowProgressBar() {
        return mEnrollReason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING;
        return mEnrollReason == BiometricOverlayConstants.REASON_ENROLL_ENROLLING;
    }

    void onEnrollmentProgress(int remaining) {
+18 −17
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.res.TypedArray;
import android.hardware.biometrics.BiometricOverlayConstants;
import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.SensorProperties;
import android.hardware.display.DisplayManager;
@@ -256,7 +257,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    @Test
    public void dozeTimeTick() throws RemoteException {
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();
        mUdfpsController.dozeTimeTick();
        verify(mUdfpsView).dozeTimeTick();
@@ -271,7 +272,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        // WHEN ACTION_DOWN is received
@@ -294,7 +295,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        // WHEN ACTION_DOWN is received
@@ -317,7 +318,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        // WHEN ACTION_DOWN is received
@@ -340,7 +341,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_ENROLL_ENROLLING, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_ENROLL_ENROLLING, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        // WHEN ACTION_DOWN is received
@@ -362,7 +363,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        // WHEN ACTION_MOVE is received
@@ -384,7 +385,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        // WHEN multiple touches are received
@@ -404,7 +405,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    @Test
    public void showUdfpsOverlay_addsViewToWindow() throws RemoteException {
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();
        verify(mWindowManager).addView(eq(mUdfpsView), any());
    }
@@ -412,7 +413,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    @Test
    public void hideUdfpsOverlay_removesViewFromWindow() throws RemoteException {
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mOverlayController.hideUdfpsOverlay(TEST_UDFPS_SENSOR_ID);
        mFgExecutor.runAllReady();
        verify(mWindowManager).removeView(eq(mUdfpsView));
@@ -422,7 +423,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    public void hideUdfpsOverlay_resetsAltAuthBouncerWhenShowing() throws RemoteException {
        // GIVEN overlay was showing and the udfps bouncer is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        when(mStatusBarKeyguardViewManager.isShowingAlternateAuth()).thenReturn(true);

        // WHEN the overlay is hidden
@@ -436,7 +437,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    @Test
    public void testSubscribesToOrientationChangesWhenShowingOverlay() throws Exception {
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        verify(mDisplayManager).registerDisplayListener(any(), eq(mHandler));
@@ -455,7 +456,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();
        // WHEN ACTION_DOWN is received
        verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
@@ -479,7 +480,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    public void aodInterrupt() throws RemoteException {
        // GIVEN that the overlay is showing and screen is on
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mScreenObserver.onScreenTurnedOn();
        mFgExecutor.runAllReady();
        // WHEN fingerprint is requested because of AOD interrupt
@@ -496,7 +497,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    public void cancelAodInterrupt() throws RemoteException {
        // GIVEN AOD interrupt
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mScreenObserver.onScreenTurnedOn();
        mFgExecutor.runAllReady();
        mUdfpsController.onAodInterrupt(0, 0, 0f, 0f);
@@ -511,7 +512,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    public void aodInterruptTimeout() throws RemoteException {
        // GIVEN AOD interrupt
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mScreenObserver.onScreenTurnedOn();
        mFgExecutor.runAllReady();
        mUdfpsController.onAodInterrupt(0, 0, 0f, 0f);
@@ -527,7 +528,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    public void aodInterruptScreenOff() throws RemoteException {
        // GIVEN screen off
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mScreenObserver.onScreenTurnedOff();
        mFgExecutor.runAllReady();

@@ -546,7 +547,7 @@ public class UdfpsControllerTest extends SysuiTestCase {

        // GIVEN that the overlay is showing
        mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
                IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        // WHEN ACTION_DOWN is received
Loading