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

Commit d4286fa1 authored by Aaron Liu's avatar Aaron Liu Committed by Android (Google) Code Review
Browse files

Merge "[Bouncer] Set message for dismiss api." into tm-qpr-dev

parents 3f1d8757 2e482ce2
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.InputMethodManager;

@@ -152,7 +153,9 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
    }

    public void startAppearAnimation() {
        if (TextUtils.isEmpty(mMessageAreaController.getMessage())) {
            mMessageAreaController.setMessage(getInitialMessageResId());
        }
        mView.startAppearAnimation();
    }

+5 −0
Original line number Diff line number Diff line
@@ -103,6 +103,11 @@ public class KeyguardMessageAreaController<T extends KeyguardMessageArea>
        mView.setNextMessageColor(colorState);
    }

    /** Returns the message of the underlying TextView. */
    public CharSequence getMessage() {
        return mView.getText();
    }

    /**
     * Reload colors from resources.
     **/
+2 −22
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@

package com.android.systemui.keyguard.data.repository

import android.hardware.biometrics.BiometricSourceType
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.keyguard.ViewMediatorCallback
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel
@@ -70,33 +68,15 @@ constructor(
    private val _keyguardAuthenticated = MutableStateFlow<Boolean?>(null)
    /** Determines if user is already unlocked */
    val keyguardAuthenticated = _keyguardAuthenticated.asStateFlow()

    var bouncerPromptReason: Int? = null
    private val _showMessage = MutableStateFlow<BouncerShowMessageModel?>(null)
    val showMessage = _showMessage.asStateFlow()
    private val _resourceUpdateRequests = MutableStateFlow(false)
    val resourceUpdateRequests = _resourceUpdateRequests.asStateFlow()

    val bouncerPromptReason: Int
        get() = viewMediatorCallback.bouncerPromptReason
    val bouncerErrorMessage: CharSequence?
        get() = viewMediatorCallback.consumeCustomMessage()

    init {
        val callback =
            object : KeyguardUpdateMonitorCallback() {
                override fun onStrongAuthStateChanged(userId: Int) {
                    bouncerPromptReason = viewMediatorCallback.bouncerPromptReason
                }

                override fun onLockedOutStateChanged(type: BiometricSourceType) {
                    if (type == BiometricSourceType.FINGERPRINT) {
                        bouncerPromptReason = viewMediatorCallback.bouncerPromptReason
                    }
                }
            }

        keyguardUpdateMonitor.registerCallback(callback)
    }

    fun setPrimaryScrimmed(isScrimmed: Boolean) {
        _primaryBouncerScrimmed.value = isScrimmed
    }
+4 −12
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ object KeyguardBouncerViewBinder {
                    viewModel.setBouncerViewDelegate(delegate)
                    launch {
                        viewModel.show.collect {
                            hostViewController.showPromptReason(it.promptReason)
                            it.errorMessage?.let { errorMessage ->
                                hostViewController.showErrorMessage(errorMessage)
                            }
                            hostViewController.showPrimarySecurityScreen()
                            hostViewController.appear(
                                SystemBarUtils.getStatusBarHeight(view.context)
@@ -101,18 +105,6 @@ object KeyguardBouncerViewBinder {
                        }
                    }

                    launch {
                        viewModel.showPromptReason.collect { prompt ->
                            hostViewController.showPromptReason(prompt)
                        }
                    }

                    launch {
                        viewModel.showBouncerErrorMessage.collect { errorMessage ->
                            hostViewController.showErrorMessage(errorMessage)
                        }
                    }

                    launch {
                        viewModel.showWithFullExpansion.collect { model ->
                            hostViewController.resetSecurityContainer()
+0 −8
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import com.android.systemui.statusbar.phone.KeyguardBouncer.EXPANSION_VISIBLE
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map

/** Models UI state for the lock screen bouncer; handles user input. */
@@ -45,13 +44,6 @@ constructor(
    /** Observe whether bouncer is showing. */
    val show: Flow<KeyguardBouncerModel> = interactor.show

    /** Observe bouncer prompt when bouncer is showing. */
    val showPromptReason: Flow<Int> = interactor.show.map { it.promptReason }

    /** Observe bouncer error message when bouncer is showing. */
    val showBouncerErrorMessage: Flow<CharSequence> =
        interactor.show.map { it.errorMessage }.filterNotNull()

    /** Observe visible expansion when bouncer is showing. */
    val showWithFullExpansion: Flow<KeyguardBouncerModel> =
        interactor.show.filter { it.expansionAmount == EXPANSION_VISIBLE }
Loading