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

Commit b13dc6a1 authored by Joe Bolinger's avatar Joe Bolinger
Browse files

Do not show side fingerprint sensor overlay on keyguard.

Bug: 197265282
Test: atest SidefpsControllerTest
Test: manual (lock device and verify no overlay on keyguard)
Change-Id: I7ff487e3d15d68ea1b182c6c7e7fd255801e4dea
parent f2e41730
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);
}
+1 −1
Original line number Diff line number Diff line
@@ -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.
+16 −2
Original line number Diff line number Diff line
@@ -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 −7
Original line number Diff line number Diff line
@@ -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())
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -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);
            }
Loading