Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.keyguard.ui.viewmodel import android.graphics.Color import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @ExperimentalCoroutinesApi @SmallTest @RunWith(AndroidJUnit4::class) class DeviceEntryForegroundViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val underTest: DeviceEntryForegroundViewModel = kosmos.deviceEntryForegroundIconViewModel @Test fun aodIconColorWhite() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, testScope = testScope, ) assertThat(viewModel?.useAodVariant).isEqualTo(true) assertThat(viewModel?.tint).isEqualTo(Color.WHITE) } private fun givenUdfpsEnrolledAndEnabled() { kosmos.fakeFingerprintPropertyRepository.supportsUdfps() kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true) } } packages/SystemUI/src/com/android/systemui/keyguard/ui/view/DeviceEntryIconView.kt +6 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,12 @@ constructor( } } /** * Setups different icon states. * - All lottie views will require a LottieOnCompositionLoadedListener to update * LottieProperties (like color) of the view. * - Drawable properties can be updated using ImageView properties like imageTintList. */ private fun setupIconStates() { // Lockscreen States // LOCK Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt +16 −7 Original line number Diff line number Diff line Loading @@ -64,13 +64,6 @@ constructor( } } private val color: Flow<Int> = deviceEntryIconViewModel.useBackgroundProtection.flatMapLatest { useBgProtection -> configurationInteractor.onAnyConfigurationChange .map { getColor(useBgProtection) } .onStart { emit(getColor(useBgProtection)) } } // While dozing, the display can show the AOD UI; show the AOD udfps when dozing private val useAodIconVariant: Flow<Boolean> = deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest { udfspEnrolled -> Loading @@ -81,6 +74,22 @@ constructor( } } private val color: Flow<Int> = useAodIconVariant .flatMapLatest { useAodVariant -> if (useAodVariant) { flowOf(android.graphics.Color.WHITE) } else { deviceEntryIconViewModel.useBackgroundProtection.flatMapLatest { useBgProtection -> configurationInteractor.onAnyConfigurationChange .map { getColor(useBgProtection) } .onStart { emit(getColor(useBgProtection)) } } } } .distinctUntilChanged() private val padding: Flow<Int> = deviceEntryUdfpsInteractor.isUdfpsSupported.flatMapLatest { udfpsSupported -> if (udfpsSupported) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.keyguard.ui.viewmodel import android.graphics.Color import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @ExperimentalCoroutinesApi @SmallTest @RunWith(AndroidJUnit4::class) class DeviceEntryForegroundViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val underTest: DeviceEntryForegroundViewModel = kosmos.deviceEntryForegroundIconViewModel @Test fun aodIconColorWhite() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, testScope = testScope, ) assertThat(viewModel?.useAodVariant).isEqualTo(true) assertThat(viewModel?.tint).isEqualTo(Color.WHITE) } private fun givenUdfpsEnrolledAndEnabled() { kosmos.fakeFingerprintPropertyRepository.supportsUdfps() kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true) } }
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/DeviceEntryIconView.kt +6 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,12 @@ constructor( } } /** * Setups different icon states. * - All lottie views will require a LottieOnCompositionLoadedListener to update * LottieProperties (like color) of the view. * - Drawable properties can be updated using ImageView properties like imageTintList. */ private fun setupIconStates() { // Lockscreen States // LOCK Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt +16 −7 Original line number Diff line number Diff line Loading @@ -64,13 +64,6 @@ constructor( } } private val color: Flow<Int> = deviceEntryIconViewModel.useBackgroundProtection.flatMapLatest { useBgProtection -> configurationInteractor.onAnyConfigurationChange .map { getColor(useBgProtection) } .onStart { emit(getColor(useBgProtection)) } } // While dozing, the display can show the AOD UI; show the AOD udfps when dozing private val useAodIconVariant: Flow<Boolean> = deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest { udfspEnrolled -> Loading @@ -81,6 +74,22 @@ constructor( } } private val color: Flow<Int> = useAodIconVariant .flatMapLatest { useAodVariant -> if (useAodVariant) { flowOf(android.graphics.Color.WHITE) } else { deviceEntryIconViewModel.useBackgroundProtection.flatMapLatest { useBgProtection -> configurationInteractor.onAnyConfigurationChange .map { getColor(useBgProtection) } .onStart { emit(getColor(useBgProtection)) } } } } .distinctUntilChanged() private val padding: Flow<Int> = deviceEntryUdfpsInteractor.isUdfpsSupported.flatMapLatest { udfpsSupported -> if (udfpsSupported) { Loading