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

Commit 0f75ed39 authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

Introduce IUdfpsHbmListener

Bug: 181682258
Test: atest CommandQueueTest
Change-Id: Ia03b845ff036d7267a5dfb5691da33562fda2aab
parent 0aedb5a5
Loading
Loading
Loading
Loading
+47 −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.fingerprint;

/**
 * A listener for the high-brightness mode (HBM) transitions. This allows other components to
 * perform certain actions when the HBM is toggled on or off. For example, a display manager
 * implementation can subscribe to these events from UdfpsController and adjust the display's
 * refresh rate when the HBM is enabled.
 *
 * @hide
 */
oneway interface IUdfpsHbmListener {
    /**
     * UdfpsController will call this method when the HBM is enabled.
     *
     * @param hbmType The type of HBM that was enabled. See
     *        {@link com.android.systemui.biometrics.HbmTypes}.
     * @param displayId The displayId for which the HBM is enabled. See
     *        {@link android.view.Display#getDisplayId()}.
     */
    void onHbmEnabled(int hbmType, int displayId);

    /**
     * UdfpsController will call this method when the HBM is disabled.
     *
     * @param hbmType The type of HBM that was disabled. See
     *        {@link com.android.systemui.biometrics.HbmTypes}.
     * @param displayId The displayId for which the HBM is disabled. See
     *        {@link android.view.Display#getDisplayId()}.
     */
    void onHbmDisabled(int hbmType, int displayId);
}
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.ComponentName;
import android.graphics.Rect;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.fingerprint.IUdfpsHbmListener;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.service.notification.StatusBarNotification;
@@ -155,6 +156,11 @@ oneway interface IStatusBar
    // Used to hide the authentication dialog, e.g. when the application cancels authentication
    void hideAuthenticationDialog();

    /**
     * Sets an instance of IUdfpsHbmListener for UdfpsController.
     */
    void setUdfpsHbmListener(in IUdfpsHbmListener listener);

    /**
     * Notifies System UI that the display is ready to show system decorations.
     */
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.ComponentName;
import android.graphics.Rect;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.fingerprint.IUdfpsHbmListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.UserHandle;
@@ -120,6 +121,11 @@ interface IStatusBarService
    // Used to hide the authentication dialog, e.g. when the application cancels authentication
    void hideAuthenticationDialog();

    /**
     * Sets an instance of IUdfpsHbmListener for UdfpsController.
     */
    void setUdfpsHbmListener(in IUdfpsHbmListener listener);

    /**
     * Show a warning that the device is about to go to sleep due to user inactivity.
     */
+40 −8
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.content.Context;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.display.DisplayManager;
import android.hardware.fingerprint.IUdfpsHbmListener;
import android.inputmethodservice.InputMethodService.BackDispositionMode;
import android.os.Bundle;
import android.os.Handler;
@@ -142,6 +143,7 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
    //TODO(b/169175022) Update name and when feature name is locked.
    private static final int MSG_EMERGENCY_ACTION_LAUNCH_GESTURE      = 58 << MSG_SHIFT;
    private static final int MSG_SET_NAVIGATION_BAR_LUMA_SAMPLING_ENABLED = 59 << MSG_SHIFT;
    private static final int MSG_SET_UDFPS_HBM_LISTENER = 60 << MSG_SHIFT;

    public static final int FLAG_EXCLUDE_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -286,21 +288,38 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
                IBiometricSysuiReceiver receiver,
                int[] sensorIds, boolean credentialAllowed,
                boolean requireConfirmation, int userId, String opPackageName,
                long operationId) { }
        default void onBiometricAuthenticated() { }
        default void onBiometricHelp(String message) { }
        default void onBiometricError(int modality, int error, int vendorCode) { }
        default void hideAuthenticationDialog() { }
                long operationId) {
        }

        default void onBiometricAuthenticated() {
        }

        default void onBiometricHelp(String message) {
        }

        default void onBiometricError(int modality, int error, int vendorCode) {
        }

        default void hideAuthenticationDialog() {
        }

        /**
         * @see IStatusBar#setUdfpsHbmListener(IUdfpsHbmListener)
         */
        default void setUdfpsHbmListener(IUdfpsHbmListener listener) {
        }

        /**
         * @see IStatusBar#onDisplayReady(int)
         */
        default void onDisplayReady(int displayId) { }
        default void onDisplayReady(int displayId) {
        }

        /**
         * @see DisplayManager.DisplayListener#onDisplayRemoved(int)
         */
        default void onDisplayRemoved(int displayId) { }
        default void onDisplayRemoved(int displayId) {
        }

        /**
         * @see IStatusBar#onRecentsAnimationStateChanged(boolean)
@@ -892,6 +911,13 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
        }
    }

    @Override
    public void setUdfpsHbmListener(IUdfpsHbmListener listener) {
        synchronized (mLock) {
            mHandler.obtainMessage(MSG_SET_UDFPS_HBM_LISTENER, listener).sendToTarget();
        }
    }

    @Override
    public void onDisplayReady(int displayId) {
        synchronized (mLock) {
@@ -1286,7 +1312,7 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
                        mCallbacks.get(i).onBiometricHelp((String) msg.obj);
                    }
                    break;
                case MSG_BIOMETRIC_ERROR:
                case MSG_BIOMETRIC_ERROR: {
                    SomeArgs someArgs = (SomeArgs) msg.obj;
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).onBiometricError(
@@ -1297,11 +1323,17 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
                    }
                    someArgs.recycle();
                    break;
                }
                case MSG_BIOMETRIC_HIDE:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).hideAuthenticationDialog();
                    }
                    break;
                case MSG_SET_UDFPS_HBM_LISTENER:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).setUdfpsHbmListener((IUdfpsHbmListener) msg.obj);
                    }
                    break;
                case MSG_SHOW_CHARGING_ANIMATION:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).showWirelessChargingAnimation(msg.arg1);
+9 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.ComponentName;
import android.graphics.Rect;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.fingerprint.IUdfpsHbmListener;
import android.os.Bundle;
import android.view.WindowInsetsController.Appearance;
import android.view.WindowInsetsController.Behavior;
@@ -463,6 +464,14 @@ public class CommandQueueTest extends SysuiTestCase {
        verify(mCallbacks).hideAuthenticationDialog();
    }

    @Test
    public void testSetUdfpsHbmListener() {
        final IUdfpsHbmListener listener = mock(IUdfpsHbmListener.class);
        mCommandQueue.setUdfpsHbmListener(listener);
        waitForIdleSync();
        verify(mCallbacks).setUdfpsHbmListener(eq(listener));
    }

    @Test
    public void testSuppressAmbientDisplay() {
        mCommandQueue.suppressAmbientDisplay(true);
Loading