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

Commit 1a2536af authored by Joe Bolinger's avatar Joe Bolinger
Browse files

Add communication channel for AoD state for all biometric operations.

This will be added to the client monitors with tests in a follow up change.

Bug: 204585936
Bug: 204584403
Test: atest AuthControllerTest
Change-Id: I3ac8049ca73cb8bf58b1c1d47945a528f26d02a3
parent 86f434a6
Loading
Loading
Loading
Loading
+27 −0
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 android.hardware.biometrics;

/**
 * A secondary communication channel from AuthController back to BiometricService for
 * events that are not associated with an autentication session. See
 * {@link IBiometricSysuiReceiver} for events associated with a session.
 *
 * @hide
 */
oneway interface IBiometricContextListener {
    void onDozeChanged(boolean isDozing);
}
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.ITransientNotificationCallback;
import android.content.ComponentName;
import android.graphics.drawable.Icon;
import android.graphics.Rect;
import android.hardware.biometrics.IBiometricContextListener;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.fingerprint.IUdfpsHbmListener;
@@ -166,6 +167,8 @@ oneway interface IStatusBar
    * Used to hide the authentication dialog, e.g. when the application cancels authentication.
    */
    void hideAuthenticationDialog();
    /* Used to notify the biometric service of events that occur outside of an operation. */
    void setBiometicContextListener(in IBiometricContextListener listener);

    /**
     * Sets an instance of IUdfpsHbmListener for UdfpsController.
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Notification;
import android.content.ComponentName;
import android.graphics.drawable.Icon;
import android.graphics.Rect;
import android.hardware.biometrics.IBiometricContextListener;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.fingerprint.IUdfpsHbmListener;
@@ -125,6 +126,8 @@ interface IStatusBarService
    void onBiometricError(int modality, int error, int vendorCode);
    // Used to hide the authentication dialog, e.g. when the application cancels authentication
    void hideAuthenticationDialog();
    // Used to notify the biometric service of events that occur outside of an operation.
    void setBiometicContextListener(in IBiometricContextListener listener);

    /**
     * Sets an instance of IUdfpsHbmListener for UdfpsController.
+31 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricManager.Authenticators;
import android.hardware.biometrics.BiometricManager.BiometricMultiSensorMode;
import android.hardware.biometrics.BiometricPrompt;
import android.hardware.biometrics.IBiometricContextListener;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.display.DisplayManager;
@@ -64,6 +65,7 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.util.concurrency.Execution;

@@ -96,6 +98,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
    private final Handler mHandler;
    private final Execution mExecution;
    private final CommandQueue mCommandQueue;
    private final StatusBarStateController mStatusBarStateController;
    private final ActivityTaskManager mActivityTaskManager;
    @Nullable
    private final FingerprintManager mFingerprintManager;
@@ -118,6 +121,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
    @Nullable private UdfpsController mUdfpsController;
    @Nullable private IUdfpsHbmListener mUdfpsHbmListener;
    @Nullable private SidefpsController mSidefpsController;
    @Nullable private IBiometricContextListener mBiometricContextListener;
    @VisibleForTesting
    TaskStackListener mTaskStackListener;
    @VisibleForTesting
@@ -130,7 +134,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
    @Nullable private List<FingerprintSensorPropertiesInternal> mSidefpsProps;

    @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;
    private SensorPrivacyManager mSensorPrivacyManager;
    @NonNull private final SensorPrivacyManager mSensorPrivacyManager;
    private final WakefulnessLifecycle mWakefulnessLifecycle;

    private class BiometricTaskStackListener extends TaskStackListener {
@@ -491,6 +495,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
            Provider<SidefpsController> sidefpsControllerFactory,
            @NonNull DisplayManager displayManager,
            WakefulnessLifecycle wakefulnessLifecycle,
            @NonNull StatusBarStateController statusBarStateController,
            @Main Handler handler) {
        super(context);
        mExecution = execution;
@@ -504,6 +509,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
        mSidefpsControllerFactory = sidefpsControllerFactory;
        mWindowManager = windowManager;
        mUdfpsEnrolledForUser = new SparseBooleanArray();

        mOrientationListener = new BiometricDisplayListener(
                context,
                displayManager,
@@ -514,6 +520,14 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
                    return Unit.INSTANCE;
                });

        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController.addCallback(new StatusBarStateController.StateListener() {
            @Override
            public void onDozingChanged(boolean isDozing) {
                notifyDozeChanged(isDozing);
            }
        });

        mFaceProps = mFaceManager != null ? mFaceManager.getSensorPropertiesInternal() : null;

        int[] faceAuthLocation = context.getResources().getIntArray(
@@ -564,6 +578,22 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
        mActivityTaskManager.registerTaskStackListener(mTaskStackListener);
    }

    @Override
    public void setBiometicContextListener(IBiometricContextListener listener) {
        mBiometricContextListener = listener;
        notifyDozeChanged(mStatusBarStateController.isDozing());
    }

    private void notifyDozeChanged(boolean isDozing) {
        if (mBiometricContextListener != null) {
            try {
                mBiometricContextListener.onDozeChanged(isDozing);
            } catch (RemoteException e) {
                Log.w(TAG, "failed to notify initial doze state");
            }
        }
    }

    /**
     * Stores the listener received from {@link com.android.server.display.DisplayModeDirector}.
     *
+21 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.content.Context;
import android.graphics.drawable.Icon;
import android.hardware.biometrics.BiometricAuthenticator.Modality;
import android.hardware.biometrics.BiometricManager.BiometricMultiSensorMode;
import android.hardware.biometrics.IBiometricContextListener;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.display.DisplayManager;
@@ -154,6 +155,7 @@ public class CommandQueue extends IStatusBar.Stub implements
    private static final int MSG_SET_UDFPS_HBM_LISTENER = 60 << MSG_SHIFT;
    private static final int MSG_TILE_SERVICE_REQUEST_ADD = 61 << MSG_SHIFT;
    private static final int MSG_TILE_SERVICE_REQUEST_CANCEL = 62 << MSG_SHIFT;
    private static final int MSG_SET_BIOMETRICS_LISTENER = 63 << MSG_SHIFT;

    public static final int FLAG_EXCLUDE_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -316,6 +318,12 @@ public class CommandQueue extends IStatusBar.Stub implements
        default void hideAuthenticationDialog() {
        }

        /**
         * @see IStatusBar#setBiometicContextListener(IBiometricContextListener)
         */
        default void setBiometicContextListener(IBiometricContextListener listener) {
        }

        /**
         * @see IStatusBar#setUdfpsHbmListener(IUdfpsHbmListener)
         */
@@ -957,6 +965,13 @@ public class CommandQueue extends IStatusBar.Stub implements
        }
    }

    @Override
    public void setBiometicContextListener(IBiometricContextListener listener) {
        synchronized (mLock) {
            mHandler.obtainMessage(MSG_SET_BIOMETRICS_LISTENER, listener).sendToTarget();
        }
    }

    @Override
    public void setUdfpsHbmListener(IUdfpsHbmListener listener) {
        synchronized (mLock) {
@@ -1411,6 +1426,12 @@ public class CommandQueue extends IStatusBar.Stub implements
                        mCallbacks.get(i).hideAuthenticationDialog();
                    }
                    break;
                case MSG_SET_BIOMETRICS_LISTENER:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).setBiometicContextListener(
                                (IBiometricContextListener) msg.obj);
                    }
                    break;
                case MSG_SET_UDFPS_HBM_LISTENER:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).setUdfpsHbmListener((IUdfpsHbmListener) msg.obj);
Loading