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

Commit d4cfbb80 authored by Beverly's avatar Beverly
Browse files

Remove references to udfps_view_performance flag

Flag for this bugfix has shipped.

Flag: com.android.systemui.udfps_view_performance
Test: atest UdfpsControllerOverlayTest
Fixes: 225183106
Change-Id: I6d5493d3019f36b4e1e1e43b99c16949b6bed359
parent 61018dce
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -324,7 +324,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    fun showUdfpsOverlay_awake() =
        testScope.runTest {
            withReason(REASON_AUTH_KEYGUARD) {
                mSetFlagsRule.enableFlags(Flags.FLAG_UDFPS_VIEW_PERFORMANCE)
                powerRepository.updateWakefulness(
                    rawState = WakefulnessState.AWAKE,
                    lastWakeReason = WakeSleepReason.POWER_BUTTON,
@@ -341,7 +340,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    fun showUdfpsOverlay_whileGoingToSleep() =
        testScope.runTest {
            withReasonSuspend(REASON_AUTH_KEYGUARD) {
                mSetFlagsRule.enableFlags(Flags.FLAG_UDFPS_VIEW_PERFORMANCE)
                keyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.OFF,
                    to = KeyguardState.GONE,
@@ -370,7 +368,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    fun showUdfpsOverlay_whileAsleep() =
        testScope.runTest {
            withReasonSuspend(REASON_AUTH_KEYGUARD) {
                mSetFlagsRule.enableFlags(Flags.FLAG_UDFPS_VIEW_PERFORMANCE)
                keyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.OFF,
                    to = KeyguardState.GONE,
@@ -399,7 +396,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    fun neverRemoveViewThatHasNotBeenAdded() =
        testScope.runTest {
            withReasonSuspend(REASON_AUTH_KEYGUARD) {
                mSetFlagsRule.enableFlags(Flags.FLAG_UDFPS_VIEW_PERFORMANCE)
                controllerOverlay.show(udfpsController, overlayParams)
                val view = controllerOverlay.getTouchOverlay()
                view?.let {
@@ -414,7 +410,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    fun showUdfpsOverlay_afterFinishedTransitioningToAOD() =
        testScope.runTest {
            withReasonSuspend(REASON_AUTH_KEYGUARD) {
                mSetFlagsRule.enableFlags(Flags.FLAG_UDFPS_VIEW_PERFORMANCE)
                keyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.OFF,
                    to = KeyguardState.GONE,
@@ -542,7 +537,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    fun addViewPending_layoutIsNotUpdated() =
        testScope.runTest {
            withReasonSuspend(REASON_AUTH_KEYGUARD) {
                mSetFlagsRule.enableFlags(Flags.FLAG_UDFPS_VIEW_PERFORMANCE)
                mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)

                // GIVEN going to sleep
@@ -580,7 +574,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    fun updateOverlayParams_viewLayoutUpdated() =
        testScope.runTest {
            withReasonSuspend(REASON_AUTH_KEYGUARD) {
                mSetFlagsRule.enableFlags(Flags.FLAG_UDFPS_VIEW_PERFORMANCE)
                powerRepository.updateWakefulness(
                    rawState = WakefulnessState.AWAKE,
                    lastWakeReason = WakeSleepReason.POWER_BUTTON,
+142 −156
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.view.accessibility.AccessibilityManager.TouchExplorationStateChan
import androidx.annotation.LayoutRes
import androidx.annotation.VisibleForTesting
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.Flags.udfpsViewPerformance
import com.android.systemui.animation.ActivityTransitionAnimator
import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor
import com.android.systemui.biometrics.shared.model.UdfpsOverlayParams
@@ -82,17 +81,17 @@ import kotlinx.coroutines.launch

private const val TAG = "UdfpsControllerOverlay"

@VisibleForTesting
const val SETTING_REMOVE_ENROLLMENT_UI = "udfps_overlay_remove_enrollment_ui"
@VisibleForTesting const val SETTING_REMOVE_ENROLLMENT_UI = "udfps_overlay_remove_enrollment_ui"

/**
 * Keeps track of the overlay state and UI resources associated with a single FingerprintService
 * request. This state can persist across configuration changes via the [show] and [hide]
 * methods.
 * request. This state can persist across configuration changes via the [show] and [hide] methods.
 */
@ExperimentalCoroutinesApi
@UiThread
class UdfpsControllerOverlay @JvmOverloads constructor(
class UdfpsControllerOverlay
@JvmOverloads
constructor(
    private val context: Context,
    private val inflater: LayoutInflater,
    private val windowManager: WindowManager,
@@ -118,8 +117,7 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
    private val udfpsKeyguardAccessibilityDelegate: UdfpsKeyguardAccessibilityDelegate,
    private val transitionInteractor: KeyguardTransitionInteractor,
    private val selectedUserInteractor: SelectedUserInteractor,
        private val deviceEntryUdfpsTouchOverlayViewModel:
            Lazy<DeviceEntryUdfpsTouchOverlayViewModel>,
    private val deviceEntryUdfpsTouchOverlayViewModel: Lazy<DeviceEntryUdfpsTouchOverlayViewModel>,
    private val defaultUdfpsTouchOverlayViewModel: Lazy<DefaultUdfpsTouchOverlayViewModel>,
    private val shadeInteractor: ShadeInteractor,
    private val udfpsOverlayInteractor: UdfpsOverlayInteractor,
@@ -129,20 +127,20 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
    private val currentStateUpdatedToOffAodOrDozing: Flow<Unit> =
        transitionInteractor.currentKeyguardState
            .filter {
                it == KeyguardState.OFF ||
                    it == KeyguardState.AOD ||
                    it == KeyguardState.DOZING
                it == KeyguardState.OFF || it == KeyguardState.AOD || it == KeyguardState.DOZING
            }
            .map {} // map to Unit
    private var listenForCurrentKeyguardState: Job? = null
    private var addViewRunnable: Runnable? = null
    private var overlayViewLegacy: UdfpsView? = null
        private set

    private var overlayTouchView: UdfpsTouchOverlay? = null

    /**
     * Get the current UDFPS overlay touch view which is a different View depending on whether
     * the DeviceEntryUdfpsRefactor flag is enabled or not.
     * Get the current UDFPS overlay touch view which is a different View depending on whether the
     * DeviceEntryUdfpsRefactor flag is enabled or not.
     *
     * @return The view, when [isShowing], else null
     */
    fun getTouchOverlay(): View? {
@@ -158,18 +156,23 @@ class UdfpsControllerOverlay @JvmOverloads constructor(

    private var overlayTouchListener: TouchExplorationStateChangeListener? = null

    private val coreLayoutParams = WindowManager.LayoutParams(
    private val coreLayoutParams =
        WindowManager.LayoutParams(
                WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
                0 /* flags set in computeLayoutParams() */,
                PixelFormat.TRANSLUCENT
    ).apply {
            )
            .apply {
                title = TAG
                fitInsetsTypes = 0
                gravity = android.view.Gravity.TOP or android.view.Gravity.LEFT
        layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
        flags = (Utils.FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS or
                layoutInDisplayCutoutMode =
                    WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
                flags =
                    (Utils.FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS or
                        WindowManager.LayoutParams.FLAG_SPLIT_TOUCH)
        privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY or
                privateFlags =
                    WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY or
                        WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION
                // Avoid announcing window title.
                accessibilityTitle = " "
@@ -209,9 +212,10 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
            sensorBounds = Rect(params.sensorBounds)
            try {
                if (DeviceEntryUdfpsRefactor.isEnabled) {
                    overlayTouchView = (inflater.inflate(
                            R.layout.udfps_touch_overlay, null, false
                    ) as UdfpsTouchOverlay).apply {
                    overlayTouchView =
                        (inflater.inflate(R.layout.udfps_touch_overlay, null, false)
                                as UdfpsTouchOverlay)
                            .apply {
                                // This view overlaps the sensor area
                                // prevent it from being selectable during a11y
                                if (requestReason.isImportantForAccessibility()) {
@@ -235,9 +239,8 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
                                }
                            }
                } else {
                    overlayViewLegacy = (inflater.inflate(
                            R.layout.udfps_view, null, false
                    ) as UdfpsView).apply {
                    overlayViewLegacy =
                        (inflater.inflate(R.layout.udfps_view, null, false) as UdfpsView).apply {
                            overlayParams = params
                            setUdfpsDisplayModeProvider(udfpsDisplayModeProvider)
                            val animation = inflateUdfpsAnimation(this, controller)
@@ -284,30 +287,18 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
    }

    private fun addViewNowOrLater(view: View, animation: UdfpsAnimationViewController<*>?) {
        if (udfpsViewPerformance()) {
            addViewRunnable = kotlinx.coroutines.Runnable {
        addViewRunnable =
            kotlinx.coroutines.Runnable {
                Trace.setCounter("UdfpsAddView", 1)
                windowManager.addView(
                        view,
                        coreLayoutParams.updateDimensions(animation)
                )
                windowManager.addView(view, coreLayoutParams.updateDimensions(animation))
            }
        if (powerInteractor.detailedWakefulness.value.isAwake()) {
            // Device is awake, so we add the view immediately.
            addViewIfPending()
        } else {
            listenForCurrentKeyguardState?.cancel()
                listenForCurrentKeyguardState = scope.launch {
                    currentStateUpdatedToOffAodOrDozing.collect {
                        addViewIfPending()
                    }
                }
            }
        } else {
            windowManager.addView(
                    view,
                    coreLayoutParams.updateDimensions(animation)
            )
            listenForCurrentKeyguardState =
                scope.launch { currentStateUpdatedToOffAodOrDozing.collect { addViewIfPending() } }
        }
    }

@@ -340,12 +331,15 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
    ): UdfpsAnimationViewController<*>? {
        DeviceEntryUdfpsRefactor.assertInLegacyMode()

        val isEnrollment = when (requestReason) {
            REASON_ENROLL_FIND_SENSOR, REASON_ENROLL_ENROLLING -> true
        val isEnrollment =
            when (requestReason) {
                REASON_ENROLL_FIND_SENSOR,
                REASON_ENROLL_ENROLLING -> true
                else -> false
            }

        val filteredRequestReason = if (isEnrollment && shouldRemoveEnrollmentUi()) {
        val filteredRequestReason =
            if (isEnrollment && shouldRemoveEnrollmentUi()) {
                REASON_AUTH_OTHER
            } else {
                requestReason
@@ -434,14 +428,10 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
            udfpsDisplayModeProvider.disable(null)
        }
        getTouchOverlay()?.apply {
            if (udfpsViewPerformance()) {
            if (this.parent != null) {
                windowManager.removeView(this)
            }
            Trace.setCounter("UdfpsAddView", 0)
            } else {
                windowManager.removeView(this)
            }
            setOnTouchListener(null)
            setOnHoverListener(null)
            overlayTouchListener?.let {
@@ -475,8 +465,10 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
        val paddingX = animation?.paddingX ?: 0
        val paddingY = animation?.paddingY ?: 0

        val isEnrollment = when (requestReason) {
            REASON_ENROLL_FIND_SENSOR, REASON_ENROLL_ENROLLING -> true
        val isEnrollment =
            when (requestReason) {
                REASON_ENROLL_FIND_SENSOR,
                REASON_ENROLL_ENROLLING -> true
                else -> false
            }

@@ -485,12 +477,7 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
            if (accessibilityManager.isTouchExplorationEnabled && isEnrollment) {
                Rect(overlayParams.sensorBounds)
            } else {
                Rect(
                    0,
                    0,
                    overlayParams.naturalDisplayWidth,
                    overlayParams.naturalDisplayHeight
                )
                Rect(0, 0, overlayParams.naturalDisplayWidth, overlayParams.naturalDisplayHeight)
            }

        val rot = overlayParams.rotation
@@ -498,7 +485,8 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
            if (!shouldRotate(animation)) {
                Log.v(
                    TAG,
                    "Skip rotating UDFPS bounds " + Surface.rotationToString(rot) +
                    "Skip rotating UDFPS bounds " +
                        Surface.rotationToString(rot) +
                        " animation=$animation" +
                        " isGoingToSleep=${keyguardUpdateMonitor.isGoingToSleep}" +
                        " isOccluded=${keyguardStateController.isOccluded}"
@@ -559,6 +547,4 @@ class UdfpsControllerOverlay @JvmOverloads constructor(

@RequestReason
private fun Int.isImportantForAccessibility() =
    this == REASON_ENROLL_FIND_SENSOR ||
            this == REASON_ENROLL_ENROLLING ||
            this == REASON_AUTH_BP
    this == REASON_ENROLL_FIND_SENSOR || this == REASON_ENROLL_ENROLLING || this == REASON_AUTH_BP