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

Commit 19f87369 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

Removes SysUiViewModel

It was an empty interface that was not adding any value. Removing it as
per feedback from adamp@

Bug: 354269846
Test: smoke test with flexiglass - visited every scene before/after
unlock and after relock
Flag: com.android.systemui.scene_container

Change-Id: I294a3b7d143ca37a703fcd384dd639f9c2595b7e
parent 711005ea
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import com.android.systemui.authentication.domain.interactor.AuthenticationResul
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.SysUiViewModel
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.MutableStateFlow
@@ -40,7 +39,7 @@ sealed class AuthMethodBouncerViewModel(
     * being able to attempt to unlock the device.
     */
    val isInputEnabled: StateFlow<Boolean>,
) : SysUiViewModel, ExclusiveActivatable() {
) : ExclusiveActivatable() {

    private val _animateFailure = MutableStateFlow(false)
    /**
+1 −2
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.systemui.deviceentry.shared.model.FaceTimeoutMessage
import com.android.systemui.deviceentry.shared.model.FingerprintFailureMessage
import com.android.systemui.deviceentry.shared.model.FingerprintLockoutMessage
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.SysUiViewModel
import com.android.systemui.res.R.string.kg_too_many_failed_attempts_countdown
import com.android.systemui.user.ui.viewmodel.UserSwitcherViewModel
import com.android.systemui.util.kotlin.Utils.Companion.sample
@@ -80,7 +79,7 @@ constructor(
    private val deviceUnlockedInteractor: DeviceUnlockedInteractor,
    private val deviceEntryBiometricsAllowedInteractor: DeviceEntryBiometricsAllowedInteractor,
    private val flags: ComposeBouncerFlags,
) : SysUiViewModel, ExclusiveActivatable() {
) : ExclusiveActivatable() {
    /**
     * A message shown when the user has attempted the wrong credential too many times and now must
     * wait a while before attempting to authenticate again.
+1 −2
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.SysUiViewModel
import com.android.systemui.user.ui.viewmodel.UserSwitcherViewModel
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@@ -63,7 +62,7 @@ constructor(
    private val pinViewModelFactory: PinBouncerViewModel.Factory,
    private val patternViewModelFactory: PatternBouncerViewModel.Factory,
    private val passwordViewModelFactory: PasswordBouncerViewModel.Factory,
) : SysUiViewModel, ExclusiveActivatable() {
) : ExclusiveActivatable() {
    private val _selectedUserImage = MutableStateFlow<Bitmap?>(null)
    val selectedUserImage: StateFlow<Bitmap?> = _selectedUserImage.asStateFlow()

+1 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteract
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.ClockSize
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.SysUiViewModel
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor
import com.android.systemui.scene.shared.model.Scenes
@@ -60,7 +59,7 @@ constructor(
    private val unfoldTransitionInteractor: UnfoldTransitionInteractor,
    private val occlusionInteractor: SceneContainerOcclusionInteractor,
    private val deviceEntryInteractor: DeviceEntryInteractor,
) : SysUiViewModel, ExclusiveActivatable() {
) : ExclusiveActivatable() {
    @VisibleForTesting val clockSize = clockInteractor.clockSize

    val isUdfpsVisible: Boolean
+7 −10
Original line number Diff line number Diff line
@@ -24,13 +24,10 @@ import com.android.app.tracing.coroutines.traceCoroutine
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

/** Defines interface for all System UI view-models. */
interface SysUiViewModel

/**
 * Returns a remembered [SysUiViewModel] of the type [T]. If the returned instance is also an
 * Returns a remembered view-model of the type [T]. If the returned instance is also an
 * [Activatable], it's automatically kept active until this composable leaves the composition; if
 * the [key] changes, the old [SysUiViewModel] is deactivated and a new one will be instantiated,
 * the [key] changes, the old view-model is deactivated and a new one will be instantiated,
 * activated, and returned.
 *
 * The [traceName] is used for coroutine performance tracing purposes. Please try to use a label
@@ -39,7 +36,7 @@ interface SysUiViewModel
 * of some complex concatenation or templating scheme.
 */
@Composable
fun <T : SysUiViewModel> rememberViewModel(
fun <T> rememberViewModel(
    traceName: String,
    key: Any = Unit,
    factory: () -> T,
@@ -52,16 +49,16 @@ fun <T : SysUiViewModel> rememberViewModel(
}

/**
 * Invokes [block] in a new coroutine with a new [SysUiViewModel] that is automatically activated
 * whenever `this` [View]'s Window's [WindowLifecycleState] is at least at
 * [minWindowLifecycleState], and is automatically canceled once that is no longer the case.
 * Invokes [block] in a new coroutine with a new view-model that is automatically activated whenever
 * `this` [View]'s Window's [WindowLifecycleState] is at least at [minWindowLifecycleState], and is
 * automatically canceled once that is no longer the case.
 *
 * The [traceName] is used for coroutine performance tracing purposes. Please try to use a label
 * that's unique enough and easy enough to find in code search; this should help correlate
 * performance findings with actual code. One recommendation: prefer whole string literals instead
 * of some complex concatenation or templating scheme.
 */
suspend fun <T : SysUiViewModel> View.viewModel(
suspend fun <T> View.viewModel(
    traceName: String,
    minWindowLifecycleState: WindowLifecycleState,
    factory: () -> T,
Loading