Merge changes I7825436b,I93c97788 into main
* changes:
Remove Udfps's BackgroundViewModel
Cleanup unused code that is leftover
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
index dddcf18..a4b55e7 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
@@ -90,7 +90,6 @@
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.domain.interactor.KeyguardFaceAuthInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardViewModels;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -124,8 +123,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.inject.Provider;
-
@SmallTest
@RunWith(AndroidJUnit4.class)
@RunWithLooper(setAsMainLooper = true)
@@ -216,8 +213,6 @@
@Mock
private UdfpsKeyguardAccessibilityDelegate mUdfpsKeyguardAccessibilityDelegate;
@Mock
- private Provider<UdfpsKeyguardViewModels> mUdfpsKeyguardViewModels;
- @Mock
private SelectedUserInteractor mSelectedUserInteractor;
// Capture listeners so that they can be used to send events
@@ -339,7 +334,6 @@
mInputManager,
mock(KeyguardFaceAuthInteractor.class),
mUdfpsKeyguardAccessibilityDelegate,
- mUdfpsKeyguardViewModels,
mSelectedUserInteractor,
mFpsUnlockTracker,
mKeyguardTransitionInteractor,
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
index 65668b5..240728a 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
@@ -86,8 +86,6 @@
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.domain.interactor.KeyguardFaceAuthInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
-import com.android.systemui.keyguard.ui.adapter.UdfpsKeyguardViewControllerAdapter;
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardViewModels;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -115,7 +113,6 @@
import java.util.concurrent.Executor;
import javax.inject.Inject;
-import javax.inject.Provider;
import kotlinx.coroutines.ExperimentalCoroutinesApi;
@@ -152,7 +149,6 @@
@NonNull private final SystemUIDialogManager mDialogManager;
@NonNull private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@NonNull private final KeyguardFaceAuthInteractor mKeyguardFaceAuthInteractor;
- @NonNull private final Provider<UdfpsKeyguardViewModels> mUdfpsKeyguardViewModels;
@NonNull private final VibratorHelper mVibrator;
@NonNull private final FalsingManager mFalsingManager;
@NonNull private final PowerManager mPowerManager;
@@ -623,7 +619,7 @@
} else {
onKeyguard = mOverlay != null
&& mOverlay.getAnimationViewController()
- instanceof UdfpsKeyguardViewControllerAdapter;
+ instanceof UdfpsKeyguardViewControllerLegacy;
}
return onKeyguard
&& mKeyguardStateController.canDismissLockScreen()
@@ -666,7 +662,6 @@
@NonNull InputManager inputManager,
@NonNull KeyguardFaceAuthInteractor keyguardFaceAuthInteractor,
@NonNull UdfpsKeyguardAccessibilityDelegate udfpsKeyguardAccessibilityDelegate,
- @NonNull Provider<UdfpsKeyguardViewModels> udfpsKeyguardViewModelsProvider,
@NonNull SelectedUserInteractor selectedUserInteractor,
@NonNull FpsUnlockTracker fpsUnlockTracker,
@NonNull KeyguardTransitionInteractor keyguardTransitionInteractor,
@@ -737,7 +732,6 @@
return Unit.INSTANCE;
});
mKeyguardFaceAuthInteractor = keyguardFaceAuthInteractor;
- mUdfpsKeyguardViewModels = udfpsKeyguardViewModelsProvider;
final UdfpsOverlayController mUdfpsOverlayController = new UdfpsOverlayController();
mFingerprintManager.setUdfpsOverlayController(mUdfpsOverlayController);
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt
index dae6d08..aabee93 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt
@@ -55,7 +55,6 @@
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
-import com.android.systemui.keyguard.ui.adapter.UdfpsKeyguardViewControllerAdapter
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
import com.android.systemui.statusbar.LockscreenShadeTransitionController
@@ -438,7 +437,7 @@
if (DeviceEntryUdfpsRefactor.isEnabled) {
!keyguardStateController.isShowing
} else {
- animation !is UdfpsKeyguardViewControllerAdapter
+ animation !is UdfpsKeyguardViewControllerLegacy
}
if (keyguardNotShowing) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt
index 109741c..64148f6 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt
@@ -33,7 +33,6 @@
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
-import com.android.systemui.keyguard.ui.adapter.UdfpsKeyguardViewControllerAdapter
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
@@ -81,8 +80,7 @@
primaryBouncerInteractor,
systemUIDialogManager,
dumpManager,
- ),
- UdfpsKeyguardViewControllerAdapter {
+ ) {
private val uniqueIdentifier = this.toString()
private var showingUdfpsBouncer = false
private var udfpsRequested = false
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/controller/UdfpsKeyguardViewController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/controller/UdfpsKeyguardViewController.kt
deleted file mode 100644
index 6f4e1a3..0000000
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/controller/UdfpsKeyguardViewController.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2023 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.biometrics.ui.controller
-
-import com.android.systemui.biometrics.UdfpsAnimationViewController
-import com.android.systemui.biometrics.UdfpsKeyguardView
-import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
-import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
-import com.android.systemui.dump.DumpManager
-import com.android.systemui.keyguard.ui.adapter.UdfpsKeyguardViewControllerAdapter
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardViewModels
-import com.android.systemui.plugins.statusbar.StatusBarStateController
-import com.android.systemui.statusbar.phone.SystemUIDialogManager
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-
-/** Class that coordinates non-HBM animations during keyguard authentication. */
-@ExperimentalCoroutinesApi
-open class UdfpsKeyguardViewController(
- val view: UdfpsKeyguardView,
- statusBarStateController: StatusBarStateController,
- primaryBouncerInteractor: PrimaryBouncerInteractor,
- systemUIDialogManager: SystemUIDialogManager,
- dumpManager: DumpManager,
- private val alternateBouncerInteractor: AlternateBouncerInteractor,
- udfpsKeyguardViewModels: UdfpsKeyguardViewModels,
-) :
- UdfpsAnimationViewController<UdfpsKeyguardView>(
- view,
- statusBarStateController,
- primaryBouncerInteractor,
- systemUIDialogManager,
- dumpManager,
- ),
- UdfpsKeyguardViewControllerAdapter {
- private val uniqueIdentifier = this.toString()
- override val tag: String
- get() = TAG
-
- init {
- udfpsKeyguardViewModels.bindViews(view)
- }
-
- public override fun onViewAttached() {
- super.onViewAttached()
- alternateBouncerInteractor.setAlternateBouncerUIAvailable(true, uniqueIdentifier)
- }
-
- public override fun onViewDetached() {
- super.onViewDetached()
- alternateBouncerInteractor.setAlternateBouncerUIAvailable(false, uniqueIdentifier)
- }
-
- override fun shouldPauseAuth(): Boolean {
- return !view.isVisible()
- }
-
- override fun listenForTouchesOutsideView(): Boolean {
- return true
- }
-
- companion object {
- private const val TAG = "UdfpsKeyguardViewController"
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/adapter/UdfpsKeyguardViewControllerAdapter.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/adapter/UdfpsKeyguardViewControllerAdapter.kt
deleted file mode 100644
index ebf1beb..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/adapter/UdfpsKeyguardViewControllerAdapter.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2023 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.adapter
-
-/**
- * Temporary adapter class while
- * [com.android.systemui.biometrics.ui.controller.UdfpsKeyguardViewController] is being refactored
- * before [com.android.systemui.biometrics.UdfpsKeyguardViewControllerLegacy] is removed.
- *
- * TODO (b/278719514): Delete once udfps keyguard view is fully refactored.
- */
-interface UdfpsKeyguardViewControllerAdapter
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt
index d12d193..c749818 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt
@@ -26,6 +26,7 @@
import com.android.systemui.keyguard.ui.viewmodel.AlternateBouncerUdfpsIconViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.launch
@ExperimentalCoroutinesApi
object AlternateBouncerUdfpsViewBinder {
@@ -71,10 +72,12 @@
bgView.visibility = View.VISIBLE
bgView.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.bgViewModel.collect { bgViewModel ->
- bgView.alpha = bgViewModel.alpha
- bgView.imageTintList = ColorStateList.valueOf(bgViewModel.tint)
+ launch {
+ viewModel.bgColor.collect { color ->
+ bgView.imageTintList = ColorStateList.valueOf(color)
+ }
}
+ launch { viewModel.bgAlpha.collect { alpha -> bgView.alpha = alpha } }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt
index dcf4284..a02e8ac 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt
@@ -131,10 +131,10 @@
bgView.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.CREATED) {
+ launch { bgViewModel.alpha.collect { alpha -> bgView.alpha = alpha } }
launch {
- bgViewModel.viewModel.collect { bgViewModel ->
- bgView.alpha = bgViewModel.alpha
- bgView.imageTintList = ColorStateList.valueOf(bgViewModel.tint)
+ bgViewModel.color.collect { color ->
+ bgView.imageTintList = ColorStateList.valueOf(color)
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsAodFingerprintViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsAodFingerprintViewBinder.kt
deleted file mode 100644
index 52d87d3..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsAodFingerprintViewBinder.kt
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2023 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.binder
-
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.repeatOnLifecycle
-import com.airbnb.lottie.LottieAnimationView
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsAodViewModel
-import com.android.systemui.lifecycle.repeatWhenAttached
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.launch
-
-@ExperimentalCoroutinesApi
-object UdfpsAodFingerprintViewBinder {
-
- /**
- * Drives UI for the UDFPS aod fingerprint view. See [UdfpsFingerprintViewBinder] and
- * [UdfpsBackgroundViewBinder].
- */
- @JvmStatic
- fun bind(
- view: LottieAnimationView,
- viewModel: UdfpsAodViewModel,
- ) {
- view.alpha = 0f
- view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch {
- viewModel.burnInOffsets.collect { burnInOffsets ->
- view.progress = burnInOffsets.progress
- view.translationX = burnInOffsets.x.toFloat()
- view.translationY = burnInOffsets.y.toFloat()
- }
- }
-
- launch { viewModel.alpha.collect { alpha -> view.alpha = alpha } }
-
- launch {
- viewModel.padding.collect { padding ->
- view.setPadding(padding, padding, padding, padding)
- }
- }
- }
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsBackgroundViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsBackgroundViewBinder.kt
deleted file mode 100644
index 0113628..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsBackgroundViewBinder.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2023 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.binder
-
-import android.content.res.ColorStateList
-import android.widget.ImageView
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.repeatOnLifecycle
-import com.android.systemui.keyguard.ui.viewmodel.BackgroundViewModel
-import com.android.systemui.lifecycle.repeatWhenAttached
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.launch
-
-@ExperimentalCoroutinesApi
-object UdfpsBackgroundViewBinder {
-
- /**
- * Drives UI for the udfps background view. See [UdfpsAodFingerprintViewBinder] and
- * [UdfpsFingerprintViewBinder].
- */
- @JvmStatic
- fun bind(
- view: ImageView,
- viewModel: BackgroundViewModel,
- ) {
- view.alpha = 0f
- view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch {
- viewModel.transition.collect {
- view.alpha = it.alpha
- view.scaleX = it.scale
- view.scaleY = it.scale
- view.imageTintList = ColorStateList.valueOf(it.color)
- }
- }
- }
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsFingerprintViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsFingerprintViewBinder.kt
deleted file mode 100644
index d4621e6..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsFingerprintViewBinder.kt
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2023 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.binder
-
-import android.graphics.PorterDuff
-import android.graphics.PorterDuffColorFilter
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.repeatOnLifecycle
-import com.airbnb.lottie.LottieAnimationView
-import com.airbnb.lottie.LottieProperty
-import com.airbnb.lottie.model.KeyPath
-import com.android.systemui.keyguard.ui.viewmodel.FingerprintViewModel
-import com.android.systemui.lifecycle.repeatWhenAttached
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.launch
-
-@ExperimentalCoroutinesApi
-object UdfpsFingerprintViewBinder {
- private var udfpsIconColor = 0
-
- /**
- * Drives UI for the UDFPS fingerprint view when it's NOT on aod. See
- * [UdfpsAodFingerprintViewBinder] and [UdfpsBackgroundViewBinder].
- */
- @JvmStatic
- fun bind(
- view: LottieAnimationView,
- viewModel: FingerprintViewModel,
- ) {
- view.alpha = 0f
- view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch {
- viewModel.transition.collect {
- view.alpha = it.alpha
- view.scaleX = it.scale
- view.scaleY = it.scale
- if (udfpsIconColor != (it.color)) {
- udfpsIconColor = it.color
- view.invalidate()
- }
- }
- }
-
- launch {
- viewModel.burnInOffsets.collect { burnInOffsets ->
- view.translationX = burnInOffsets.x.toFloat()
- view.translationY = burnInOffsets.y.toFloat()
- }
- }
-
- launch {
- viewModel.dozeAmount.collect { dozeAmount ->
- // Lottie progress represents: aod=0 to lockscreen=1
- view.progress = 1f - dozeAmount
- }
- }
-
- launch {
- viewModel.padding.collect { padding ->
- view.setPadding(padding, padding, padding, padding)
- }
- }
- }
- }
-
- // Add a callback that updates the color to `udfpsIconColor` whenever invalidate is called
- view.addValueCallback(KeyPath("**"), LottieProperty.COLOR_FILTER) {
- PorterDuffColorFilter(udfpsIconColor, PorterDuff.Mode.SRC_ATOP)
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardInternalViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardInternalViewBinder.kt
deleted file mode 100644
index aabb3f4..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardInternalViewBinder.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2023 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.biometrics.ui.binder
-
-import android.view.View
-import com.android.systemui.res.R
-import com.android.systemui.keyguard.ui.binder.UdfpsAodFingerprintViewBinder
-import com.android.systemui.keyguard.ui.binder.UdfpsBackgroundViewBinder
-import com.android.systemui.keyguard.ui.binder.UdfpsFingerprintViewBinder
-import com.android.systemui.keyguard.ui.viewmodel.BackgroundViewModel
-import com.android.systemui.keyguard.ui.viewmodel.FingerprintViewModel
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsAodViewModel
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardInternalViewModel
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-
-@ExperimentalCoroutinesApi
-object UdfpsKeyguardInternalViewBinder {
-
- @JvmStatic
- fun bind(
- view: View,
- viewModel: UdfpsKeyguardInternalViewModel,
- aodViewModel: UdfpsAodViewModel,
- fingerprintViewModel: FingerprintViewModel,
- backgroundViewModel: BackgroundViewModel,
- ) {
- view.accessibilityDelegate = viewModel.accessibilityDelegate
-
- // bind child views
- UdfpsAodFingerprintViewBinder.bind(view.requireViewById(R.id.udfps_aod_fp), aodViewModel)
- UdfpsFingerprintViewBinder.bind(
- view.requireViewById(R.id.udfps_lockscreen_fp),
- fingerprintViewModel
- )
- UdfpsBackgroundViewBinder.bind(
- view.requireViewById(R.id.udfps_keyguard_fp_bg),
- backgroundViewModel
- )
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardViewBinder.kt
deleted file mode 100644
index 475d26f..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardViewBinder.kt
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2023 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.binder
-
-import android.graphics.RectF
-import android.view.View
-import android.widget.FrameLayout
-import androidx.asynclayoutinflater.view.AsyncLayoutInflater
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.repeatOnLifecycle
-import com.android.systemui.biometrics.UdfpsKeyguardView
-import com.android.systemui.biometrics.ui.binder.UdfpsKeyguardInternalViewBinder
-import com.android.systemui.keyguard.ui.viewmodel.BackgroundViewModel
-import com.android.systemui.keyguard.ui.viewmodel.FingerprintViewModel
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsAodViewModel
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardInternalViewModel
-import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardViewModel
-import com.android.systemui.lifecycle.repeatWhenAttached
-import com.android.systemui.res.R
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.launch
-
-@ExperimentalCoroutinesApi
-object UdfpsKeyguardViewBinder {
- /**
- * Drives UI for the keyguard UDFPS view. Inflates child views on a background thread. For view
- * binders for its child views, see [UdfpsFingerprintViewBinder], [UdfpsBackgroundViewBinder] &
- * [UdfpsAodFingerprintViewBinder].
- */
- @JvmStatic
- fun bind(
- view: UdfpsKeyguardView,
- viewModel: UdfpsKeyguardViewModel,
- udfpsKeyguardInternalViewModel: UdfpsKeyguardInternalViewModel,
- aodViewModel: UdfpsAodViewModel,
- fingerprintViewModel: FingerprintViewModel,
- backgroundViewModel: BackgroundViewModel,
- ) {
- val layoutInflaterFinishListener =
- AsyncLayoutInflater.OnInflateFinishedListener { inflatedInternalView, _, parent ->
- UdfpsKeyguardInternalViewBinder.bind(
- inflatedInternalView,
- udfpsKeyguardInternalViewModel,
- aodViewModel,
- fingerprintViewModel,
- backgroundViewModel,
- )
- val lp = inflatedInternalView.layoutParams as FrameLayout.LayoutParams
- lp.width = viewModel.sensorBounds.width()
- lp.height = viewModel.sensorBounds.height()
- val relativeToView =
- getBoundsRelativeToView(
- inflatedInternalView,
- RectF(viewModel.sensorBounds),
- )
- lp.setMarginsRelative(
- relativeToView.left.toInt(),
- relativeToView.top.toInt(),
- relativeToView.right.toInt(),
- relativeToView.bottom.toInt(),
- )
- parent!!.addView(inflatedInternalView, lp)
- }
- val inflater = AsyncLayoutInflater(view.context)
- inflater.inflate(R.layout.udfps_keyguard_view_internal, view, layoutInflaterFinishListener)
-
- view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.CREATED) {
- launch {
- combine(aodViewModel.isVisible, fingerprintViewModel.visible) {
- isAodVisible,
- isFingerprintVisible ->
- isAodVisible || isFingerprintVisible
- }
- .collect { view.setVisible(it) }
- }
- }
- }
- }
-
- /**
- * Converts coordinates of RectF relative to the screen to coordinates relative to this view.
- *
- * @param bounds RectF based off screen coordinates in current orientation
- */
- private fun getBoundsRelativeToView(view: View, bounds: RectF): RectF {
- val pos: IntArray = view.locationOnScreen
- return RectF(
- bounds.left - pos[0],
- bounds.top - pos[1],
- bounds.right - pos[0],
- bounds.bottom - pos[1]
- )
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerUdfpsIconViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerUdfpsIconViewModel.kt
index e18893a..f4ae365 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerUdfpsIconViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerUdfpsIconViewModel.kt
@@ -43,6 +43,7 @@
val context: Context,
configurationInteractor: ConfigurationInteractor,
deviceEntryUdfpsInteractor: DeviceEntryUdfpsInteractor,
+ deviceEntryBackgroundViewModel: DeviceEntryBackgroundViewModel,
fingerprintPropertyRepository: FingerprintPropertyRepository,
) {
private val isSupported: Flow<Boolean> = deviceEntryUdfpsInteractor.isUdfpsSupported
@@ -90,26 +91,8 @@
)
}
- private val bgColor: Flow<Int> =
- configurationInteractor.onAnyConfigurationChange
- .map {
- Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorSurface)
- }
- .onStart {
- emit(
- Utils.getColorAttrDefaultColor(
- context,
- com.android.internal.R.attr.colorSurface
- )
- )
- }
- val bgViewModel: Flow<DeviceEntryBackgroundViewModel.BackgroundViewModel> =
- bgColor.map { color ->
- DeviceEntryBackgroundViewModel.BackgroundViewModel(
- alpha = 1f,
- tint = color,
- )
- }
+ val bgColor: Flow<Int> = deviceEntryBackgroundViewModel.color
+ val bgAlpha: Flow<Float> = flowOf(1f)
data class IconLocation(
val left: Int,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryBackgroundViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryBackgroundViewModel.kt
index c45caf0..be9ae1d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryBackgroundViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryBackgroundViewModel.kt
@@ -19,11 +19,10 @@
import android.content.Context
import com.android.settingslib.Utils
-import com.android.systemui.common.ui.data.repository.ConfigurationRepository
+import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onStart
@@ -34,7 +33,7 @@
@Inject
constructor(
val context: Context,
- configurationRepository: ConfigurationRepository, // TODO (b/309655554): create & use interactor
+ configurationInteractor: ConfigurationInteractor,
lockscreenToAodTransitionViewModel: LockscreenToAodTransitionViewModel,
aodToLockscreenTransitionViewModel: AodToLockscreenTransitionViewModel,
goneToAodTransitionViewModel: GoneToAodTransitionViewModel,
@@ -44,8 +43,8 @@
dreamingToLockscreenTransitionViewModel: DreamingToLockscreenTransitionViewModel,
alternateBouncerToAodTransitionViewModel: AlternateBouncerToAodTransitionViewModel,
) {
- private val color: Flow<Int> =
- configurationRepository.onAnyConfigurationChange
+ val color: Flow<Int> =
+ configurationInteractor.onAnyConfigurationChange
.map {
Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorSurface)
}
@@ -57,7 +56,7 @@
)
)
}
- private val alpha: Flow<Float> =
+ val alpha: Flow<Float> =
setOf(
lockscreenToAodTransitionViewModel.deviceEntryBackgroundViewAlpha,
aodToLockscreenTransitionViewModel.deviceEntryBackgroundViewAlpha,
@@ -69,17 +68,4 @@
alternateBouncerToAodTransitionViewModel.deviceEntryBackgroundViewAlpha,
)
.merge()
-
- val viewModel: Flow<BackgroundViewModel> =
- combine(color, alpha) { color, alpha ->
- BackgroundViewModel(
- alpha = alpha,
- tint = color,
- )
- }
-
- data class BackgroundViewModel(
- val alpha: Float,
- val tint: Int,
- )
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsAodViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsAodViewModel.kt
deleted file mode 100644
index 6e77e13e..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsAodViewModel.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2023 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.content.Context
-import com.android.systemui.keyguard.domain.interactor.Offsets
-import com.android.systemui.keyguard.domain.interactor.UdfpsKeyguardInteractor
-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.map
-
-/** View-model for UDFPS AOD view. */
-@ExperimentalCoroutinesApi
-class UdfpsAodViewModel
-@Inject
-constructor(
- val interactor: UdfpsKeyguardInteractor,
- val context: Context,
-) {
- val alpha: Flow<Float> = interactor.dozeAmount
- val burnInOffsets: Flow<Offsets> = interactor.burnInOffsets
- val isVisible: Flow<Boolean> = alpha.map { it != 0f }
-
- // Padding between the fingerprint icon and its bounding box in pixels.
- val padding: Flow<Int> =
- interactor.scaleForResolution.map { scale ->
- (context.resources.getDimensionPixelSize(R.dimen.lock_icon_padding) * scale)
- .roundToInt()
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardInternalViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardInternalViewModel.kt
deleted file mode 100644
index d894a11..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardInternalViewModel.kt
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.systemui.biometrics.UdfpsKeyguardAccessibilityDelegate
-import javax.inject.Inject
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-
-@ExperimentalCoroutinesApi
-class UdfpsKeyguardInternalViewModel
-@Inject
-constructor(val accessibilityDelegate: UdfpsKeyguardAccessibilityDelegate)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardViewModel.kt
deleted file mode 100644
index dca151d..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardViewModel.kt
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2023 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.Rect
-import javax.inject.Inject
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-
-@ExperimentalCoroutinesApi
-class UdfpsKeyguardViewModel @Inject constructor() {
- var sensorBounds: Rect = Rect()
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardViewModels.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardViewModels.kt
deleted file mode 100644
index 098b481..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsKeyguardViewModels.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.android.systemui.keyguard.ui.viewmodel
-
-import android.graphics.Rect
-import com.android.systemui.biometrics.UdfpsKeyguardView
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.keyguard.ui.binder.UdfpsKeyguardViewBinder
-import javax.inject.Inject
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-
-@ExperimentalCoroutinesApi
-@SysUISingleton
-class UdfpsKeyguardViewModels
-@Inject
-constructor(
- private val viewModel: UdfpsKeyguardViewModel,
- private val internalViewModel: UdfpsKeyguardInternalViewModel,
- private val aodViewModel: UdfpsAodViewModel,
- private val lockscreenFingerprintViewModel: FingerprintViewModel,
- private val lockscreenBackgroundViewModel: BackgroundViewModel,
-) {
-
- fun setSensorBounds(sensorBounds: Rect) {
- viewModel.sensorBounds = sensorBounds
- }
-
- fun bindViews(view: UdfpsKeyguardView) {
- UdfpsKeyguardViewBinder.bind(
- view,
- viewModel,
- internalViewModel,
- aodViewModel,
- lockscreenFingerprintViewModel,
- lockscreenBackgroundViewModel
- )
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsLockscreenViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsLockscreenViewModel.kt
deleted file mode 100644
index 642904d..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsLockscreenViewModel.kt
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2023 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.content.Context
-import androidx.annotation.ColorInt
-import com.android.settingslib.Utils.getColorAttrDefaultColor
-import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
-import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
-import com.android.systemui.keyguard.domain.interactor.Offsets
-import com.android.systemui.keyguard.domain.interactor.UdfpsKeyguardInteractor
-import com.android.systemui.keyguard.shared.model.KeyguardState
-import com.android.systemui.keyguard.shared.model.StatusBarState
-import com.android.systemui.res.R
-import com.android.wm.shell.animation.Interpolators
-import javax.inject.Inject
-import kotlin.math.roundToInt
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.merge
-
-/** View-model for UDFPS lockscreen views. */
-@ExperimentalCoroutinesApi
-open class UdfpsLockscreenViewModel(
- context: Context,
- lockscreenColorResId: Int,
- alternateBouncerColorResId: Int,
- transitionInteractor: KeyguardTransitionInteractor,
- udfpsKeyguardInteractor: UdfpsKeyguardInteractor,
- keyguardInteractor: KeyguardInteractor,
-) {
- private val toLockscreen: Flow<TransitionViewModel> =
- transitionInteractor.anyStateToLockscreenTransition.map {
- TransitionViewModel(
- alpha =
- if (it.from == KeyguardState.AOD) {
- it.value // animate
- } else {
- 1f
- },
- scale = 1f,
- color = getColorAttrDefaultColor(context, lockscreenColorResId),
- )
- }
-
- private val toAlternateBouncer: Flow<TransitionViewModel> =
- keyguardInteractor.statusBarState.flatMapLatest { statusBarState ->
- transitionInteractor.transitionStepsToState(KeyguardState.ALTERNATE_BOUNCER).map {
- TransitionViewModel(
- alpha = 1f,
- scale =
- if (visibleInKeyguardState(it.from, statusBarState)) {
- 1f
- } else {
- Interpolators.FAST_OUT_SLOW_IN.getInterpolation(it.value)
- },
- color = getColorAttrDefaultColor(context, alternateBouncerColorResId),
- )
- }
- }
-
- private val fadeOut: Flow<TransitionViewModel> =
- keyguardInteractor.statusBarState.flatMapLatest { statusBarState ->
- merge(
- transitionInteractor.anyStateToGoneTransition,
- transitionInteractor.anyStateToAodTransition,
- transitionInteractor.anyStateToOccludedTransition,
- transitionInteractor.anyStateToPrimaryBouncerTransition,
- transitionInteractor.anyStateToDreamingTransition,
- )
- .map {
- TransitionViewModel(
- alpha =
- if (visibleInKeyguardState(it.from, statusBarState)) {
- 1f - it.value
- } else {
- 0f
- },
- scale = 1f,
- color =
- if (it.from == KeyguardState.ALTERNATE_BOUNCER) {
- getColorAttrDefaultColor(context, alternateBouncerColorResId)
- } else {
- getColorAttrDefaultColor(context, lockscreenColorResId)
- },
- )
- }
- }
-
- private fun visibleInKeyguardState(
- state: KeyguardState,
- statusBarState: StatusBarState
- ): Boolean {
- return when (state) {
- KeyguardState.OFF,
- KeyguardState.DOZING,
- KeyguardState.DREAMING,
- KeyguardState.DREAMING_LOCKSCREEN_HOSTED,
- KeyguardState.AOD,
- KeyguardState.PRIMARY_BOUNCER,
- KeyguardState.GONE,
- KeyguardState.OCCLUDED -> false
- KeyguardState.LOCKSCREEN -> statusBarState == StatusBarState.KEYGUARD
- KeyguardState.ALTERNATE_BOUNCER -> true
- }
- }
-
- private val keyguardStateTransition =
- merge(
- toAlternateBouncer,
- toLockscreen,
- fadeOut,
- )
-
- private val dialogHideAffordancesAlphaMultiplier: Flow<Float> =
- udfpsKeyguardInteractor.dialogHideAffordancesRequest.map { hideAffordances ->
- if (hideAffordances) {
- 0f
- } else {
- 1f
- }
- }
-
- private val alphaMultiplier: Flow<Float> =
- combine(
- transitionInteractor.startedKeyguardState,
- dialogHideAffordancesAlphaMultiplier,
- udfpsKeyguardInteractor.shadeExpansion,
- udfpsKeyguardInteractor.qsProgress,
- ) { startedKeyguardState, dialogHideAffordancesAlphaMultiplier, shadeExpansion, qsProgress
- ->
- if (startedKeyguardState == KeyguardState.ALTERNATE_BOUNCER) {
- 1f
- } else {
- dialogHideAffordancesAlphaMultiplier * (1f - shadeExpansion) * (1f - qsProgress)
- }
- }
-
- val transition: Flow<TransitionViewModel> =
- combine(
- alphaMultiplier,
- keyguardStateTransition,
- ) { alphaMultiplier, keyguardStateTransition ->
- TransitionViewModel(
- alpha = keyguardStateTransition.alpha * alphaMultiplier,
- scale = keyguardStateTransition.scale,
- color = keyguardStateTransition.color,
- )
- }
- val visible: Flow<Boolean> = transition.map { it.alpha != 0f }
-}
-
-@ExperimentalCoroutinesApi
-class FingerprintViewModel
-@Inject
-constructor(
- val context: Context,
- transitionInteractor: KeyguardTransitionInteractor,
- interactor: UdfpsKeyguardInteractor,
- keyguardInteractor: KeyguardInteractor,
-) :
- UdfpsLockscreenViewModel(
- context,
- android.R.attr.textColorPrimary,
- com.android.internal.R.attr.materialColorOnPrimaryFixed,
- transitionInteractor,
- interactor,
- keyguardInteractor,
- ) {
- val dozeAmount: Flow<Float> = interactor.dozeAmount
- val burnInOffsets: Flow<Offsets> = interactor.burnInOffsets
-
- // Padding between the fingerprint icon and its bounding box in pixels.
- val padding: Flow<Int> =
- interactor.scaleForResolution.map { scale ->
- (context.resources.getDimensionPixelSize(R.dimen.lock_icon_padding) * scale)
- .roundToInt()
- }
-}
-
-@ExperimentalCoroutinesApi
-class BackgroundViewModel
-@Inject
-constructor(
- val context: Context,
- transitionInteractor: KeyguardTransitionInteractor,
- interactor: UdfpsKeyguardInteractor,
- keyguardInteractor: KeyguardInteractor,
-) :
- UdfpsLockscreenViewModel(
- context,
- com.android.internal.R.attr.colorSurface,
- com.android.internal.R.attr.materialColorPrimaryFixed,
- transitionInteractor,
- interactor,
- keyguardInteractor,
- )
-
-data class TransitionViewModel(
- val alpha: Float,
- val scale: Float,
- @ColorInt val color: Int,
-)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsAodViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsAodViewModelTest.kt
deleted file mode 100644
index 6512290..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsAodViewModelTest.kt
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2023 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 androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository
-import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.doze.util.BurnInHelperWrapper
-import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
-import com.android.systemui.keyguard.domain.interactor.BurnInInteractor
-import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
-import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory
-import com.android.systemui.keyguard.domain.interactor.UdfpsKeyguardInteractor
-import com.android.systemui.shade.data.repository.FakeShadeRepository
-import com.android.systemui.statusbar.phone.SystemUIDialogManager
-import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.TestScope
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mock
-import org.mockito.MockitoAnnotations
-
-@ExperimentalCoroutinesApi
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class UdfpsAodViewModelTest : SysuiTestCase() {
- private val defaultPadding = 12
- private lateinit var underTest: UdfpsAodViewModel
-
- private lateinit var testScope: TestScope
- private lateinit var configRepository: FakeConfigurationRepository
- private lateinit var bouncerRepository: KeyguardBouncerRepository
- private lateinit var keyguardRepository: FakeKeyguardRepository
- private lateinit var shadeRepository: FakeShadeRepository
- private lateinit var keyguardInteractor: KeyguardInteractor
-
- @Mock private lateinit var dialogManager: SystemUIDialogManager
- @Mock private lateinit var burnInHelper: BurnInHelperWrapper
-
- @Before
- fun setUp() {
- MockitoAnnotations.initMocks(this)
- overrideResource(com.android.systemui.res.R.dimen.lock_icon_padding, defaultPadding)
- testScope = TestScope()
- shadeRepository = FakeShadeRepository()
- KeyguardInteractorFactory.create().also {
- keyguardInteractor = it.keyguardInteractor
- keyguardRepository = it.repository
- configRepository = it.configurationRepository
- bouncerRepository = it.bouncerRepository
- }
- val udfpsKeyguardInteractor =
- UdfpsKeyguardInteractor(
- configRepository,
- BurnInInteractor(
- context,
- burnInHelper,
- testScope.backgroundScope,
- configRepository,
- keyguardInteractor,
- ),
- keyguardInteractor,
- shadeRepository,
- dialogManager,
- )
-
- underTest =
- UdfpsAodViewModel(
- udfpsKeyguardInteractor,
- context,
- )
- }
-
- @Test
- fun alphaAndVisibleUpdates_onDozeAmountChanges() =
- testScope.runTest {
- val alpha by collectLastValue(underTest.alpha)
- val visible by collectLastValue(underTest.isVisible)
-
- keyguardRepository.setDozeAmount(0f)
- runCurrent()
- assertThat(alpha).isEqualTo(0f)
- assertThat(visible).isFalse()
-
- keyguardRepository.setDozeAmount(.65f)
- runCurrent()
- assertThat(alpha).isEqualTo(.65f)
- assertThat(visible).isTrue()
-
- keyguardRepository.setDozeAmount(.23f)
- runCurrent()
- assertThat(alpha).isEqualTo(.23f)
- assertThat(visible).isTrue()
-
- keyguardRepository.setDozeAmount(1f)
- runCurrent()
- assertThat(alpha).isEqualTo(1f)
- assertThat(visible).isTrue()
- }
-
- @Test
- fun paddingUpdates_onScaleForResolutionChanges() =
- testScope.runTest {
- val padding by collectLastValue(underTest.padding)
-
- configRepository.setScaleForResolution(1f)
- runCurrent()
- assertThat(padding).isEqualTo(defaultPadding)
-
- configRepository.setScaleForResolution(2f)
- runCurrent()
- assertThat(padding).isEqualTo(defaultPadding * 2)
-
- configRepository.setScaleForResolution(.5f)
- runCurrent()
- assertThat(padding).isEqualTo((defaultPadding * .5f).toInt())
- }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsFingerprintViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsFingerprintViewModelTest.kt
deleted file mode 100644
index 95b2fe5..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsFingerprintViewModelTest.kt
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2023 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 androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository
-import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository
-import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.doze.util.BurnInHelperWrapper
-import com.android.systemui.keyguard.data.repository.FakeCommandQueue
-import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
-import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
-import com.android.systemui.keyguard.domain.interactor.BurnInInteractor
-import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory
-import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory
-import com.android.systemui.keyguard.domain.interactor.UdfpsKeyguardInteractor
-import com.android.systemui.shade.data.repository.FakeShadeRepository
-import com.android.systemui.statusbar.phone.SystemUIDialogManager
-import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.TestScope
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mock
-import org.mockito.MockitoAnnotations
-
-/** Tests UdfpsFingerprintViewModel specific flows. */
-@ExperimentalCoroutinesApi
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class UdfpsFingerprintViewModelTest : SysuiTestCase() {
- private val defaultPadding = 12
- private lateinit var underTest: FingerprintViewModel
-
- private lateinit var testScope: TestScope
- private lateinit var configRepository: FakeConfigurationRepository
- private lateinit var bouncerRepository: KeyguardBouncerRepository
- private lateinit var keyguardRepository: FakeKeyguardRepository
- private lateinit var fakeCommandQueue: FakeCommandQueue
- private lateinit var transitionRepository: FakeKeyguardTransitionRepository
- private lateinit var shadeRepository: FakeShadeRepository
-
- @Mock private lateinit var burnInHelper: BurnInHelperWrapper
- @Mock private lateinit var dialogManager: SystemUIDialogManager
-
- @Before
- fun setUp() {
- MockitoAnnotations.initMocks(this)
- overrideResource(com.android.systemui.res.R.dimen.lock_icon_padding, defaultPadding)
- testScope = TestScope()
- configRepository = FakeConfigurationRepository()
- keyguardRepository = FakeKeyguardRepository()
- bouncerRepository = FakeKeyguardBouncerRepository()
- fakeCommandQueue = FakeCommandQueue()
- bouncerRepository = FakeKeyguardBouncerRepository()
- transitionRepository = FakeKeyguardTransitionRepository()
- shadeRepository = FakeShadeRepository()
- val keyguardInteractor =
- KeyguardInteractorFactory.create(
- repository = keyguardRepository,
- )
- .keyguardInteractor
-
- val transitionInteractor =
- KeyguardTransitionInteractorFactory.create(
- scope = testScope.backgroundScope,
- repository = transitionRepository,
- keyguardInteractor = keyguardInteractor,
- )
- .keyguardTransitionInteractor
-
- underTest =
- FingerprintViewModel(
- context,
- transitionInteractor,
- UdfpsKeyguardInteractor(
- configRepository,
- BurnInInteractor(
- context,
- burnInHelper,
- testScope.backgroundScope,
- configRepository,
- keyguardInteractor,
- ),
- keyguardInteractor,
- shadeRepository,
- dialogManager,
- ),
- keyguardInteractor,
- )
- }
-
- @Test
- fun paddingUpdates_onScaleForResolutionChanges() =
- testScope.runTest {
- val padding by collectLastValue(underTest.padding)
-
- configRepository.setScaleForResolution(1f)
- runCurrent()
- assertThat(padding).isEqualTo(defaultPadding)
-
- configRepository.setScaleForResolution(2f)
- runCurrent()
- assertThat(padding).isEqualTo(defaultPadding * 2)
-
- configRepository.setScaleForResolution(.5f)
- runCurrent()
- assertThat(padding).isEqualTo((defaultPadding * .5).toInt())
- }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsLockscreenViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsLockscreenViewModelTest.kt
deleted file mode 100644
index 848a94b..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/UdfpsLockscreenViewModelTest.kt
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- * Copyright (C) 2023 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 androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.settingslib.Utils
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository
-import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
-import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
-import com.android.systemui.keyguard.domain.interactor.BurnInInteractor
-import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
-import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory
-import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory
-import com.android.systemui.keyguard.domain.interactor.UdfpsKeyguardInteractor
-import com.android.systemui.keyguard.shared.model.KeyguardState
-import com.android.systemui.keyguard.shared.model.StatusBarState
-import com.android.systemui.keyguard.shared.model.TransitionState
-import com.android.systemui.keyguard.shared.model.TransitionStep
-import com.android.systemui.shade.data.repository.FakeShadeRepository
-import com.android.systemui.statusbar.phone.SystemUIDialogManager
-import com.android.systemui.util.mockito.argumentCaptor
-import com.android.systemui.util.mockito.mock
-import com.android.wm.shell.animation.Interpolators
-import com.google.common.collect.Range
-import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.TestScope
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mock
-import org.mockito.Mockito
-import org.mockito.MockitoAnnotations
-
-/** Tests UDFPS lockscreen view model transitions. */
-@ExperimentalCoroutinesApi
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class UdfpsLockscreenViewModelTest : SysuiTestCase() {
- private val lockscreenColorResId = android.R.attr.textColorPrimary
- private val alternateBouncerResId = com.android.internal.R.attr.materialColorOnPrimaryFixed
- private val lockscreenColor = Utils.getColorAttrDefaultColor(context, lockscreenColorResId)
- private val alternateBouncerColor =
- Utils.getColorAttrDefaultColor(context, alternateBouncerResId)
-
- @Mock private lateinit var dialogManager: SystemUIDialogManager
-
- private lateinit var underTest: UdfpsLockscreenViewModel
- private lateinit var testScope: TestScope
- private lateinit var transitionRepository: FakeKeyguardTransitionRepository
- private lateinit var configRepository: FakeConfigurationRepository
- private lateinit var keyguardRepository: FakeKeyguardRepository
- private lateinit var keyguardInteractor: KeyguardInteractor
- private lateinit var bouncerRepository: FakeKeyguardBouncerRepository
- private lateinit var shadeRepository: FakeShadeRepository
-
- @Before
- fun setUp() {
- MockitoAnnotations.initMocks(this)
- testScope = TestScope()
- transitionRepository = FakeKeyguardTransitionRepository()
- shadeRepository = FakeShadeRepository()
- KeyguardInteractorFactory.create().also {
- keyguardInteractor = it.keyguardInteractor
- keyguardRepository = it.repository
- configRepository = it.configurationRepository
- bouncerRepository = it.bouncerRepository
- }
-
- val transitionInteractor =
- KeyguardTransitionInteractorFactory.create(
- scope = testScope.backgroundScope,
- repository = transitionRepository,
- keyguardInteractor = keyguardInteractor,
- )
- .keyguardTransitionInteractor
-
- underTest =
- UdfpsLockscreenViewModel(
- context,
- lockscreenColorResId,
- alternateBouncerResId,
- transitionInteractor,
- UdfpsKeyguardInteractor(
- configRepository,
- BurnInInteractor(
- context,
- burnInHelperWrapper = mock(),
- testScope.backgroundScope,
- configRepository,
- keyguardInteractor,
- ),
- keyguardInteractor,
- shadeRepository,
- dialogManager,
- ),
- keyguardInteractor,
- )
- }
-
- @Test
- fun goneToAodTransition() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
-
- // TransitionState.STARTED: gone -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.GONE,
- to = KeyguardState.AOD,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "goneToAodTransition",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isFalse()
-
- // TransitionState.RUNNING: gone -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.GONE,
- to = KeyguardState.AOD,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "goneToAodTransition",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isFalse()
-
- // TransitionState.FINISHED: gone -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.GONE,
- to = KeyguardState.AOD,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "goneToAodTransition",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isFalse()
- }
-
- @Test
- fun lockscreenToAod() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
- keyguardRepository.setStatusBarState(StatusBarState.KEYGUARD)
-
- // TransitionState.STARTED: lockscreen -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.AOD,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "lockscreenToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
-
- // TransitionState.RUNNING: lockscreen -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.AOD,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "lockscreenToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isIn(Range.closed(.39f, .41f))
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: lockscreen -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.AOD,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "lockscreenToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isFalse()
- }
-
- @Test
- fun lockscreenShadeLockedToAod() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
- keyguardRepository.setStatusBarState(StatusBarState.SHADE_LOCKED)
-
- // TransitionState.STARTED: lockscreen -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.AOD,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "lockscreenToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isFalse()
-
- // TransitionState.RUNNING: lockscreen -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.AOD,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "lockscreenToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isFalse()
-
- // TransitionState.FINISHED: lockscreen -> AOD
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.AOD,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "lockscreenToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isFalse()
- }
-
- @Test
- fun aodToLockscreen() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
-
- // TransitionState.STARTED: AOD -> lockscreen
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.AOD,
- to = KeyguardState.LOCKSCREEN,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "aodToLockscreen",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isFalse()
-
- // TransitionState.RUNNING: AOD -> lockscreen
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.AOD,
- to = KeyguardState.LOCKSCREEN,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "aodToLockscreen",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isIn(Range.closed(.59f, .61f))
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: AOD -> lockscreen
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.AOD,
- to = KeyguardState.LOCKSCREEN,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "aodToLockscreen",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
- }
-
- @Test
- fun lockscreenToAlternateBouncer() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
- keyguardRepository.setStatusBarState(StatusBarState.KEYGUARD)
-
- // TransitionState.STARTED: lockscreen -> alternate bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.ALTERNATE_BOUNCER,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "lockscreenToAlternateBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.RUNNING: lockscreen -> alternate bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.ALTERNATE_BOUNCER,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "lockscreenToAlternateBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: lockscreen -> alternate bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.ALTERNATE_BOUNCER,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "lockscreenToAlternateBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
- }
-
- fun alternateBouncerToPrimaryBouncer() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
-
- // TransitionState.STARTED: alternate bouncer -> primary bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.ALTERNATE_BOUNCER,
- to = KeyguardState.PRIMARY_BOUNCER,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "alternateBouncerToPrimaryBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.RUNNING: alternate bouncer -> primary bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.ALTERNATE_BOUNCER,
- to = KeyguardState.PRIMARY_BOUNCER,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "alternateBouncerToPrimaryBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isIn(Range.closed(.59f, .61f))
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: alternate bouncer -> primary bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.ALTERNATE_BOUNCER,
- to = KeyguardState.PRIMARY_BOUNCER,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "alternateBouncerToPrimaryBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isFalse()
- }
-
- fun alternateBouncerToAod() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
-
- // TransitionState.STARTED: alternate bouncer -> aod
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.ALTERNATE_BOUNCER,
- to = KeyguardState.AOD,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "alternateBouncerToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.RUNNING: alternate bouncer -> aod
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.ALTERNATE_BOUNCER,
- to = KeyguardState.AOD,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "alternateBouncerToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isIn(Range.closed(.39f, .41f))
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: alternate bouncer -> aod
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.ALTERNATE_BOUNCER,
- to = KeyguardState.AOD,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "alternateBouncerToAod",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isFalse()
- }
-
- @Test
- fun lockscreenToOccluded() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
- keyguardRepository.setStatusBarState(StatusBarState.KEYGUARD)
-
- // TransitionState.STARTED: lockscreen -> occluded
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.OCCLUDED,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "lockscreenToOccluded",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
-
- // TransitionState.RUNNING: lockscreen -> occluded
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.OCCLUDED,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "lockscreenToOccluded",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isIn(Range.closed(.39f, .41f))
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: lockscreen -> occluded
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.LOCKSCREEN,
- to = KeyguardState.OCCLUDED,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "lockscreenToOccluded",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isFalse()
- }
-
- @Test
- fun occludedToLockscreen() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
-
- // TransitionState.STARTED: occluded -> lockscreen
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.OCCLUDED,
- to = KeyguardState.LOCKSCREEN,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "occludedToLockscreen",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
-
- // TransitionState.RUNNING: occluded -> lockscreen
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.OCCLUDED,
- to = KeyguardState.LOCKSCREEN,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "occludedToLockscreen",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: occluded -> lockscreen
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.OCCLUDED,
- to = KeyguardState.LOCKSCREEN,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "occludedToLockscreen",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(lockscreenColor)
- assertThat(visible).isTrue()
- }
-
- @Test
- fun qsProgressChange() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
- givenTransitionToLockscreenFinished()
-
- // qsExpansion = 0f
- shadeRepository.setQsExpansion(0f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(visible).isEqualTo(true)
-
- // qsExpansion = .25
- shadeRepository.setQsExpansion(.2f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(.6f)
- assertThat(visible).isEqualTo(true)
-
- // qsExpansion = .5
- shadeRepository.setQsExpansion(.5f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isEqualTo(false)
-
- // qsExpansion = 1
- shadeRepository.setQsExpansion(1f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isEqualTo(false)
- }
-
- @Test
- fun shadeExpansionChanged() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
- givenTransitionToLockscreenFinished()
-
- // shadeExpansion = 0f
- shadeRepository.setUdfpsTransitionToFullShadeProgress(0f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(visible).isEqualTo(true)
-
- // shadeExpansion = .2
- shadeRepository.setUdfpsTransitionToFullShadeProgress(.2f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(.8f)
- assertThat(visible).isEqualTo(true)
-
- // shadeExpansion = .5
- shadeRepository.setUdfpsTransitionToFullShadeProgress(.5f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(.5f)
- assertThat(visible).isEqualTo(true)
-
- // shadeExpansion = 1
- shadeRepository.setUdfpsTransitionToFullShadeProgress(1f)
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(0f)
- assertThat(visible).isEqualTo(false)
- }
-
- @Test
- fun dialogHideAffordancesRequestChanged() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- givenTransitionToLockscreenFinished()
- runCurrent()
- val captor = argumentCaptor<SystemUIDialogManager.Listener>()
- Mockito.verify(dialogManager).registerListener(captor.capture())
-
- captor.value.shouldHideAffordances(true)
- assertThat(transition?.alpha).isEqualTo(0f)
-
- captor.value.shouldHideAffordances(false)
- assertThat(transition?.alpha).isEqualTo(1f)
- }
-
- @Test
- fun occludedToAlternateBouncer() =
- testScope.runTest {
- val transition by collectLastValue(underTest.transition)
- val visible by collectLastValue(underTest.visible)
-
- // TransitionState.STARTED: occluded -> alternate bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.OCCLUDED,
- to = KeyguardState.ALTERNATE_BOUNCER,
- value = 0f,
- transitionState = TransitionState.STARTED,
- ownerName = "occludedToAlternateBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(0f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.RUNNING: occluded -> alternate bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.OCCLUDED,
- to = KeyguardState.ALTERNATE_BOUNCER,
- value = .6f,
- transitionState = TransitionState.RUNNING,
- ownerName = "occludedToAlternateBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale)
- .isEqualTo(Interpolators.FAST_OUT_SLOW_IN.getInterpolation(.6f))
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
-
- // TransitionState.FINISHED: occluded -> alternate bouncer
- transitionRepository.sendTransitionStep(
- TransitionStep(
- from = KeyguardState.OCCLUDED,
- to = KeyguardState.ALTERNATE_BOUNCER,
- value = 1f,
- transitionState = TransitionState.FINISHED,
- ownerName = "occludedToAlternateBouncer",
- )
- )
- runCurrent()
- assertThat(transition?.alpha).isEqualTo(1f)
- assertThat(transition?.scale).isEqualTo(1f)
- assertThat(transition?.color).isEqualTo(alternateBouncerColor)
- assertThat(visible).isTrue()
- }
-
- private suspend fun givenTransitionToLockscreenFinished() {
- transitionRepository.sendTransitionSteps(
- from = KeyguardState.AOD,
- to = KeyguardState.LOCKSCREEN,
- testScope
- )
- }
-}