diff options
6 files changed, 122 insertions, 9 deletions
diff --git a/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl b/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl new file mode 100644 index 000000000000..b79d6e0f9dfe --- /dev/null +++ b/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl @@ -0,0 +1,47 @@ +/* + * 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); +} + diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index fea07519fb4d..f19a12340873 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -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; @@ -156,6 +157,11 @@ oneway interface IStatusBar 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. */ void onDisplayReady(int displayId); diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index 2e25ea3601da..c8a91d8cee10 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -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; @@ -121,6 +122,11 @@ interface IStatusBarService 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. */ void showInattentiveSleepWarning(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index 059903961eae..1ff30a32c4ef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -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) @@ -893,6 +912,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) { mHandler.obtainMessage(MSG_DISPLAY_READY, displayId, 0).sendToTarget(); @@ -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); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java index 8ec03d76cfea..58738e734a06 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java @@ -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; @@ -464,6 +465,14 @@ public class CommandQueueTest extends SysuiTestCase { } @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); waitForIdleSync(); diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java index 302a23fb262c..c4f5575c22ab 100644 --- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java +++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java @@ -36,6 +36,7 @@ import android.hardware.biometrics.IBiometricSysuiReceiver; import android.hardware.biometrics.PromptInfo; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; +import android.hardware.fingerprint.IUdfpsHbmListener; import android.net.Uri; import android.os.Binder; import android.os.Build; @@ -828,12 +829,24 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D } @Override + public void setUdfpsHbmListener(IUdfpsHbmListener listener) { + enforceStatusBarService(); + if (mBar != null) { + try { + mBar.setUdfpsHbmListener(listener); + } catch (RemoteException ex) { + } + } + } + + @Override public void startTracing() { if (mBar != null) { try { mBar.startTracing(); mTracingEnabled = true; - } catch (RemoteException ex) {} + } catch (RemoteException ex) { + } } } |