Loading packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.keyguard.ui.viewmodel.fakeDeviceEntryIconViewModelTransition import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.shade.shadeTestUtil import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat Loading @@ -43,6 +44,7 @@ import kotlin.test.Test import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 Loading Loading @@ -84,6 +86,12 @@ class UdfpsAccessibilityOverlayViewModelTest(flags: FlagsParameterization) : Sys @Before fun setup() { underTest = kosmos.deviceEntryUdfpsAccessibilityOverlayViewModel overrideResource(R.integer.udfps_padding_debounce_duration, 0) } @After fun teardown() { mContext.orCreateTestableResources.removeOverride(R.integer.udfps_padding_debounce_duration) } @Test Loading Loading @@ -118,6 +126,7 @@ class UdfpsAccessibilityOverlayViewModelTest(flags: FlagsParameterization) : Sys runCurrent() assertThat(visible).isFalse() } fun fpNotRunning_overlayNotVisible() = testScope.runTest { val visible by collectLastValue(underTest.visible) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt +13 −0 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepos import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -43,6 +46,16 @@ class DeviceEntryForegroundViewModelTest : SysuiTestCase() { private val underTest: DeviceEntryForegroundViewModel = kosmos.deviceEntryForegroundIconViewModel @Before fun setup() { context.orCreateTestableResources.addOverride(R.integer.udfps_padding_debounce_duration, 0) } @After fun teardown() { context.orCreateTestableResources.removeOverride(R.integer.udfps_padding_debounce_duration) } @Test fun aodIconColorWhite() = testScope.runTest { Loading packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2056,6 +2056,9 @@ <!-- UDFPS view attributes --> <!-- UDFPS icon size in microns/um --> <dimen name="udfps_icon_size" format="float">6000</dimen> <!-- Limits the updates to at most one update per debounce duration to avoid too many updates due to quick changes to padding. --> <integer name="udfps_padding_debounce_duration">100</integer> <!-- Microns/ums (1000 um = 1mm) per pixel for the given device. If unspecified, UI that relies on this value will not be sized correctly. --> <item name="pixel_pitch" format="float" type="dimen">-1</item> Loading packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/UdfpsOverlayInteractor.kt +5 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,10 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlin.math.max /** Encapsulates business logic for interacting with the UDFPS overlay. */ @SysUISingleton Loading Loading @@ -124,8 +126,9 @@ constructor( udfpsOverlayParams.map { params -> val sensorWidth = params.nativeSensorBounds.right - params.nativeSensorBounds.left val nativePadding = (sensorWidth - iconSize) / 2 (nativePadding * params.scaleFactor).toInt() } // padding can be negative when udfpsOverlayParams has not been initialized yet. max(0, (nativePadding * params.scaleFactor).toInt()) }.distinctUntilChanged() companion object { private const val TAG = "UdfpsOverlayInteractor" Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt +7 −1 Original line number Diff line number Diff line Loading @@ -31,8 +31,10 @@ import com.android.systemui.shade.ShadeDisplayAware import javax.inject.Inject import kotlin.math.roundToInt import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf Loading @@ -40,6 +42,7 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart /** Models the UI state for the device entry icon foreground view (displayed icon). */ @OptIn(FlowPreview::class) @ExperimentalCoroutinesApi @SysUISingleton class DeviceEntryForegroundViewModel Loading Loading @@ -97,7 +100,7 @@ constructor( private val padding: Flow<Int> = deviceEntryUdfpsInteractor.isUdfpsSupported.flatMapLatest { udfpsSupported -> if (udfpsSupported) { udfpsOverlayInteractor.iconPadding udfpsOverlayInteractor.iconPadding.debounce(udfpsPaddingDebounceDuration.toLong()) } else { configurationInteractor.scaleForResolution.map { scale -> (context.resources.getDimensionPixelSize(R.dimen.lock_icon_padding) * scale) Loading @@ -120,6 +123,9 @@ constructor( ) } private val udfpsPaddingDebounceDuration: Int get() = context.resources.getInteger(R.integer.udfps_padding_debounce_duration) data class ForegroundIconViewModel( val type: DeviceEntryIconView.IconType, val useAodVariant: Boolean, Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.keyguard.ui.viewmodel.fakeDeviceEntryIconViewModelTransition import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.shade.shadeTestUtil import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat Loading @@ -43,6 +44,7 @@ import kotlin.test.Test import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 Loading Loading @@ -84,6 +86,12 @@ class UdfpsAccessibilityOverlayViewModelTest(flags: FlagsParameterization) : Sys @Before fun setup() { underTest = kosmos.deviceEntryUdfpsAccessibilityOverlayViewModel overrideResource(R.integer.udfps_padding_debounce_duration, 0) } @After fun teardown() { mContext.orCreateTestableResources.removeOverride(R.integer.udfps_padding_debounce_duration) } @Test Loading Loading @@ -118,6 +126,7 @@ class UdfpsAccessibilityOverlayViewModelTest(flags: FlagsParameterization) : Sys runCurrent() assertThat(visible).isFalse() } fun fpNotRunning_overlayNotVisible() = testScope.runTest { val visible by collectLastValue(underTest.visible) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt +13 −0 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepos import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -43,6 +46,16 @@ class DeviceEntryForegroundViewModelTest : SysuiTestCase() { private val underTest: DeviceEntryForegroundViewModel = kosmos.deviceEntryForegroundIconViewModel @Before fun setup() { context.orCreateTestableResources.addOverride(R.integer.udfps_padding_debounce_duration, 0) } @After fun teardown() { context.orCreateTestableResources.removeOverride(R.integer.udfps_padding_debounce_duration) } @Test fun aodIconColorWhite() = testScope.runTest { Loading
packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2056,6 +2056,9 @@ <!-- UDFPS view attributes --> <!-- UDFPS icon size in microns/um --> <dimen name="udfps_icon_size" format="float">6000</dimen> <!-- Limits the updates to at most one update per debounce duration to avoid too many updates due to quick changes to padding. --> <integer name="udfps_padding_debounce_duration">100</integer> <!-- Microns/ums (1000 um = 1mm) per pixel for the given device. If unspecified, UI that relies on this value will not be sized correctly. --> <item name="pixel_pitch" format="float" type="dimen">-1</item> Loading
packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/UdfpsOverlayInteractor.kt +5 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,10 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlin.math.max /** Encapsulates business logic for interacting with the UDFPS overlay. */ @SysUISingleton Loading Loading @@ -124,8 +126,9 @@ constructor( udfpsOverlayParams.map { params -> val sensorWidth = params.nativeSensorBounds.right - params.nativeSensorBounds.left val nativePadding = (sensorWidth - iconSize) / 2 (nativePadding * params.scaleFactor).toInt() } // padding can be negative when udfpsOverlayParams has not been initialized yet. max(0, (nativePadding * params.scaleFactor).toInt()) }.distinctUntilChanged() companion object { private const val TAG = "UdfpsOverlayInteractor" Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt +7 −1 Original line number Diff line number Diff line Loading @@ -31,8 +31,10 @@ import com.android.systemui.shade.ShadeDisplayAware import javax.inject.Inject import kotlin.math.roundToInt import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf Loading @@ -40,6 +42,7 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart /** Models the UI state for the device entry icon foreground view (displayed icon). */ @OptIn(FlowPreview::class) @ExperimentalCoroutinesApi @SysUISingleton class DeviceEntryForegroundViewModel Loading Loading @@ -97,7 +100,7 @@ constructor( private val padding: Flow<Int> = deviceEntryUdfpsInteractor.isUdfpsSupported.flatMapLatest { udfpsSupported -> if (udfpsSupported) { udfpsOverlayInteractor.iconPadding udfpsOverlayInteractor.iconPadding.debounce(udfpsPaddingDebounceDuration.toLong()) } else { configurationInteractor.scaleForResolution.map { scale -> (context.resources.getDimensionPixelSize(R.dimen.lock_icon_padding) * scale) Loading @@ -120,6 +123,9 @@ constructor( ) } private val udfpsPaddingDebounceDuration: Int get() = context.resources.getInteger(R.integer.udfps_padding_debounce_duration) data class ForegroundIconViewModel( val type: DeviceEntryIconView.IconType, val useAodVariant: Boolean, Loading