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