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

Commit 15d418fb authored by Beverly's avatar Beverly
Browse files

Calculate udfps padding instead of using lock_icon_padding

This is the start of deprecating lock_icon_padding.

Test: manual
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor DEVELOPMENT
Bug: 278719514
Change-Id: Iff89340d52a9b47c7346fd7087e31785c17476b2
parent 94ca052b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1905,4 +1905,7 @@
    <!-- Bouncer user switcher margins -->
    <dimen name="bouncer_user_switcher_view_mode_user_switcher_bottom_margin">0dp</dimen>
    <dimen name="bouncer_user_switcher_view_mode_view_flipper_bottom_margin">0dp</dimen>

    <!-- UDFPS view attributes -->
    <dimen name="udfps_icon_size">6mm</dimen>
</resources>
+14 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.biometrics.domain.interactor

import android.content.Context
import android.view.MotionEvent
import com.android.systemui.biometrics.AuthController
import com.android.systemui.biometrics.shared.model.UdfpsOverlayParams
@@ -23,12 +24,15 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin
import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.res.R
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn

/** Encapsulates business logic for interacting with the UDFPS overlay. */
@@ -36,10 +40,12 @@ import kotlinx.coroutines.flow.stateIn
class UdfpsOverlayInteractor
@Inject
constructor(
    @Application context: Context,
    private val authController: AuthController,
    private val selectedUserInteractor: SelectedUserInteractor,
    @Application scope: CoroutineScope
) {
    private val iconSize: Int = context.resources.getDimensionPixelSize(R.dimen.udfps_icon_size)

    /** Whether a touch is within the under-display fingerprint sensor area */
    fun isTouchWithinUdfpsArea(ev: MotionEvent): Boolean {
@@ -70,6 +76,14 @@ constructor(
            }
            .stateIn(scope, started = SharingStarted.Eagerly, initialValue = UdfpsOverlayParams())

    // Padding between the fingerprint icon and its bounding box in pixels.
    val iconPadding: Flow<Int> =
        udfpsOverlayParams.map { params ->
            val sensorWidth = params.nativeSensorBounds.right - params.nativeSensorBounds.left
            val nativePadding = (sensorWidth - iconSize) / 2
            (nativePadding * params.scaleFactor).toInt()
        }

    companion object {
        private const val TAG = "UdfpsOverlayInteractor"
    }
+3 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel

import android.content.Context
import com.android.settingslib.Utils
import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor
import com.android.systemui.common.ui.data.repository.ConfigurationRepository
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -26,7 +27,6 @@ import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.ui.view.DeviceEntryIconView
import com.android.systemui.res.R
import javax.inject.Inject
import kotlin.math.roundToInt
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
@@ -45,6 +45,7 @@ constructor(
    deviceEntryUdfpsInteractor: DeviceEntryUdfpsInteractor,
    transitionInteractor: KeyguardTransitionInteractor,
    deviceEntryIconViewModel: DeviceEntryIconViewModel,
    udfpsOverlayInteractor: UdfpsOverlayInteractor,
) {
    private val isShowingAod: Flow<Boolean> =
        transitionInteractor.startedKeyguardState.map { keyguardState ->
@@ -73,11 +74,7 @@ constructor(
                isTransitionToAod && isUdfps
            }
            .distinctUntilChanged()
    private val padding: Flow<Int> =
        configurationRepository.scaleForResolution.map { scale ->
            (context.resources.getDimensionPixelSize(R.dimen.lock_icon_padding) * scale)
                .roundToInt()
        }
    private val padding: Flow<Int> = udfpsOverlayInteractor.iconPadding

    val viewModel: Flow<ForegroundIconViewModel> =
        combine(
+1 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ open class AuthContainerViewTest : SysuiTestCase() {
            )
        udfpsOverlayInteractor =
                UdfpsOverlayInteractor(
                        context,
                        authController,
                        selectedUserInteractor,
                        testScope.backgroundScope,
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ class UdfpsOverlayInteractorTest : SysuiTestCase() {
    private fun createUdpfsOverlayInteractor() {
        underTest =
            UdfpsOverlayInteractor(
                context,
                authController,
                selectedUserInteractor,
                testScope.backgroundScope
Loading