Merge "Do not show side fingerprint sensor overlay on keyguard." into sc-v2-dev am: 6b60bde8b1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15841127 Change-Id: I80af22338c407b2eb77259d91eb5c2ddd28f28a9
This commit is contained in:
@@ -21,9 +21,9 @@ package android.hardware.fingerprint;
|
||||
*/
|
||||
oneway interface ISidefpsController {
|
||||
|
||||
// Shows the overlay.
|
||||
void show();
|
||||
// Shows the overlay for the given sensor with a reason from BiometricOverlayConstants.
|
||||
void show(int sensorId, int reason);
|
||||
|
||||
// Hides the overlay.
|
||||
void hide();
|
||||
void hide(int sensorId);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import android.hardware.fingerprint.IUdfpsOverlayControllerCallback;
|
||||
* @hide
|
||||
*/
|
||||
oneway interface IUdfpsOverlayController {
|
||||
// Shows the overlay.
|
||||
// Shows the overlay for the given sensor with a reason from BiometricOverlayConstants.
|
||||
void showUdfpsOverlay(int sensorId, int reason, IUdfpsOverlayControllerCallback callback);
|
||||
|
||||
// Hides the overlay.
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.systemui.biometrics
|
||||
import android.content.Context
|
||||
import android.graphics.PixelFormat
|
||||
import android.graphics.Rect
|
||||
import android.hardware.biometrics.BiometricOverlayConstants
|
||||
import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_KEYGUARD
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.hardware.fingerprint.FingerprintManager
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
|
||||
@@ -100,14 +102,20 @@ class SidefpsController @Inject constructor(
|
||||
|
||||
init {
|
||||
fingerprintManager?.setSidefpsController(object : ISidefpsController.Stub() {
|
||||
override fun show() = mainExecutor.execute {
|
||||
override fun show(
|
||||
sensorId: Int,
|
||||
@BiometricOverlayConstants.ShowReason reason: Int
|
||||
) = if (reason.isReasonToShow()) doShow() else hide(sensorId)
|
||||
|
||||
private fun doShow() = mainExecutor.execute {
|
||||
if (overlayView == null) {
|
||||
overlayView = createOverlayForDisplay()
|
||||
} else {
|
||||
Log.v(TAG, "overlay already shown")
|
||||
}
|
||||
}
|
||||
override fun hide() = mainExecutor.execute { overlayView = null }
|
||||
|
||||
override fun hide(sensorId: Int) = mainExecutor.execute { overlayView = null }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -165,6 +173,12 @@ class SidefpsController @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@BiometricOverlayConstants.ShowReason
|
||||
private fun Int.isReasonToShow(): Boolean = when (this) {
|
||||
REASON_AUTH_KEYGUARD -> false
|
||||
else -> true
|
||||
}
|
||||
|
||||
@RawRes
|
||||
private fun Display.asSideFpsAnimation(): Int = when (rotation) {
|
||||
Surface.ROTATION_0 -> R.raw.sfps_pulse
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.android.systemui.biometrics
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_KEYGUARD
|
||||
import android.hardware.biometrics.BiometricOverlayConstants.REASON_UNKNOWN
|
||||
import android.hardware.biometrics.SensorProperties
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.hardware.display.DisplayManagerGlobal
|
||||
@@ -128,25 +130,25 @@ class SidefpsControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testSubscribesToOrientationChangesWhenShowingOverlay() {
|
||||
overlayController.show()
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(displayManager).registerDisplayListener(any(), eq(handler))
|
||||
|
||||
overlayController.hide()
|
||||
overlayController.hide(SENSOR_ID)
|
||||
executor.runAllReady()
|
||||
verify(displayManager).unregisterDisplayListener(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShowsAndHides() {
|
||||
overlayController.show()
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(windowManager).addView(overlayCaptor.capture(), any())
|
||||
|
||||
reset(windowManager)
|
||||
overlayController.hide()
|
||||
overlayController.hide(SENSOR_ID)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(windowManager, never()).addView(any(), any())
|
||||
@@ -156,7 +158,7 @@ class SidefpsControllerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun testShowsOnce() {
|
||||
repeat(5) {
|
||||
overlayController.show()
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
}
|
||||
|
||||
@@ -166,15 +168,23 @@ class SidefpsControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testHidesOnce() {
|
||||
overlayController.show()
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
repeat(5) {
|
||||
overlayController.hide()
|
||||
overlayController.hide(SENSOR_ID)
|
||||
executor.runAllReady()
|
||||
}
|
||||
|
||||
verify(windowManager).addView(any(), any())
|
||||
verify(windowManager).removeView(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIgnoredForKeyguard() {
|
||||
overlayController.show(SENSOR_ID, REASON_AUTH_KEYGUARD)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(windowManager, never()).addView(any(), any())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class SensorOverlays {
|
||||
@NonNull AcquisitionClient<?> client) {
|
||||
if (mSidefpsController.isPresent()) {
|
||||
try {
|
||||
mSidefpsController.get().show();
|
||||
mSidefpsController.get().show(sensorId, reason);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when showing the side-fps overlay", e);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public final class SensorOverlays {
|
||||
public void hide(int sensorId) {
|
||||
if (mSidefpsController.isPresent()) {
|
||||
try {
|
||||
mSidefpsController.get().hide();
|
||||
mSidefpsController.get().hide(sensorId);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when hiding the side-fps overlay", e);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class SensorOverlaysTest {
|
||||
verify(mUdfpsOverlayController).showUdfpsOverlay(eq(SENSOR_ID), eq(reason), any());
|
||||
}
|
||||
if (sidefps != null) {
|
||||
verify(mSidefpsController).show();
|
||||
verify(mSidefpsController).show(eq(SENSOR_ID), eq(reason));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class SensorOverlaysTest {
|
||||
verify(mUdfpsOverlayController).hideUdfpsOverlay(eq(SENSOR_ID));
|
||||
}
|
||||
if (sidefps != null) {
|
||||
verify(mSidefpsController).hide();
|
||||
verify(mSidefpsController).hide(eq(SENSOR_ID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user