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

Commit 38dc11f8 authored by Aaron Liu's avatar Aaron Liu Committed by Automerger Merge Worker
Browse files

Merge "[conflict] Merge "Remove visibility and show race condition." into...

Merge "[conflict] Merge "Remove visibility and show race condition." into tm-qpr-dev am: c1ed09a3 am: 50576fe8" into udc-dev am: b5cc9c1b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21990488



Change-Id: I64a600d74d1eba609db49cf42f7e2d05621e4fe5
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0e400c28 b5cc9c1b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -55,4 +55,5 @@ interface BouncerViewDelegate {
    fun willRunDismissFromKeyguard(): Boolean
    /** @return the {@link OnBackAnimationCallback} to animate Bouncer during a back gesture. */
    fun getBackCallback(): OnBackAnimationCallback
    fun showPromptReason(reason: Int)
}
+5 −31
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN
import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel
import com.android.systemui.keyguard.shared.model.KeyguardBouncerModel
import com.android.systemui.log.dagger.BouncerLog
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
@@ -43,10 +42,8 @@ import kotlinx.coroutines.flow.map
 */
interface KeyguardBouncerRepository {
    /** Values associated with the PrimaryBouncer (pin/pattern/password) input. */
    val primaryBouncerVisible: StateFlow<Boolean>
    val primaryBouncerShow: StateFlow<KeyguardBouncerModel?>
    val primaryBouncerShow: StateFlow<Boolean>
    val primaryBouncerShowingSoon: StateFlow<Boolean>
    val primaryBouncerHide: StateFlow<Boolean>
    val primaryBouncerStartingToHide: StateFlow<Boolean>
    val primaryBouncerStartingDisappearAnimation: StateFlow<Runnable?>
    /** Determines if we want to instantaneously show the primary bouncer instead of translating. */
@@ -76,14 +73,10 @@ interface KeyguardBouncerRepository {

    fun setPrimaryScrimmed(isScrimmed: Boolean)

    fun setPrimaryVisible(isVisible: Boolean)

    fun setPrimaryShow(keyguardBouncerModel: KeyguardBouncerModel?)
    fun setPrimaryShow(isShowing: Boolean)

    fun setPrimaryShowingSoon(showingSoon: Boolean)

    fun setPrimaryHide(hide: Boolean)

    fun setPrimaryStartingToHide(startingToHide: Boolean)

    fun setPrimaryStartDisappearAnimation(runnable: Runnable?)
@@ -117,14 +110,10 @@ constructor(
    @BouncerLog private val buffer: TableLogBuffer,
) : KeyguardBouncerRepository {
    /** Values associated with the PrimaryBouncer (pin/pattern/password) input. */
    private val _primaryBouncerVisible = MutableStateFlow(false)
    override val primaryBouncerVisible = _primaryBouncerVisible.asStateFlow()
    private val _primaryBouncerShow = MutableStateFlow<KeyguardBouncerModel?>(null)
    private val _primaryBouncerShow = MutableStateFlow(false)
    override val primaryBouncerShow = _primaryBouncerShow.asStateFlow()
    private val _primaryBouncerShowingSoon = MutableStateFlow(false)
    override val primaryBouncerShowingSoon = _primaryBouncerShowingSoon.asStateFlow()
    private val _primaryBouncerHide = MutableStateFlow(false)
    override val primaryBouncerHide = _primaryBouncerHide.asStateFlow()
    private val _primaryBouncerStartingToHide = MutableStateFlow(false)
    override val primaryBouncerStartingToHide = _primaryBouncerStartingToHide.asStateFlow()
    private val _primaryBouncerDisappearAnimation = MutableStateFlow<Runnable?>(null)
@@ -177,10 +166,6 @@ constructor(
        _primaryBouncerScrimmed.value = isScrimmed
    }

    override fun setPrimaryVisible(isVisible: Boolean) {
        _primaryBouncerVisible.value = isVisible
    }

    override fun setAlternateVisible(isVisible: Boolean) {
        if (isVisible && !_alternateBouncerVisible.value) {
            lastAlternateBouncerVisibleTime = clock.uptimeMillis()
@@ -194,18 +179,14 @@ constructor(
        _alternateBouncerUIAvailable.value = isAvailable
    }

    override fun setPrimaryShow(keyguardBouncerModel: KeyguardBouncerModel?) {
        _primaryBouncerShow.value = keyguardBouncerModel
    override fun setPrimaryShow(isShowing: Boolean) {
        _primaryBouncerShow.value = isShowing
    }

    override fun setPrimaryShowingSoon(showingSoon: Boolean) {
        _primaryBouncerShowingSoon.value = showingSoon
    }

    override fun setPrimaryHide(hide: Boolean) {
        _primaryBouncerHide.value = hide
    }

    override fun setPrimaryStartingToHide(startingToHide: Boolean) {
        _primaryBouncerStartingToHide.value = startingToHide
    }
@@ -248,19 +229,12 @@ constructor(
            return
        }

        primaryBouncerVisible
            .logDiffsForTable(buffer, "", "PrimaryBouncerVisible", false)
            .launchIn(applicationScope)
        primaryBouncerShow
            .map { it != null }
            .logDiffsForTable(buffer, "", "PrimaryBouncerShow", false)
            .launchIn(applicationScope)
        primaryBouncerShowingSoon
            .logDiffsForTable(buffer, "", "PrimaryBouncerShowingSoon", false)
            .launchIn(applicationScope)
        primaryBouncerHide
            .logDiffsForTable(buffer, "", "PrimaryBouncerHide", false)
            .launchIn(applicationScope)
        primaryBouncerStartingToHide
            .logDiffsForTable(buffer, "", "PrimaryBouncerStartingToHide", false)
            .launchIn(applicationScope)
+2 −2
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ constructor(
    /** Whether the keyguard is going away. */
    val isKeyguardGoingAway: Flow<Boolean> = repository.isKeyguardGoingAway
    /** Whether the primary bouncer is showing or not. */
    val primaryBouncerShowing: Flow<Boolean> = bouncerRepository.primaryBouncerVisible
    val primaryBouncerShowing: Flow<Boolean> = bouncerRepository.primaryBouncerShow
    /** Whether the alternate bouncer is showing or not. */
    val alternateBouncerShowing: Flow<Boolean> = bouncerRepository.alternateBouncerVisible
    /** Observable for the [StatusBarState] */
@@ -159,7 +159,7 @@ constructor(
        if (featureFlags.isEnabled(Flags.FACE_AUTH_REFACTOR)) {
            combine(
                    isKeyguardVisible,
                    bouncerRepository.primaryBouncerVisible,
                    primaryBouncerShowing,
                    onCameraLaunchDetected,
                ) { isKeyguardVisible, isPrimaryBouncerShowing, cameraLaunchEvent ->
                    when {
+40 −41
Original line number Diff line number Diff line
@@ -21,12 +21,15 @@ import android.content.res.ColorStateList
import android.hardware.biometrics.BiometricSourceType
import android.os.Handler
import android.os.Trace
import android.view.View
import android.os.UserHandle
import android.os.UserManager
import android.util.Log
import android.view.View
import com.android.keyguard.KeyguardConstants
import com.android.keyguard.KeyguardSecurityModel
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.settingslib.Utils
import com.android.systemui.DejankUtils
import com.android.systemui.R
import com.android.systemui.classifier.FalsingCollector
@@ -37,7 +40,6 @@ import com.android.systemui.keyguard.data.BouncerView
import com.android.systemui.keyguard.data.repository.KeyguardBouncerRepository
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants
import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel
import com.android.systemui.keyguard.shared.model.KeyguardBouncerModel
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.shared.system.SysUiStatsLog
import com.android.systemui.statusbar.phone.KeyguardBypassController
@@ -81,23 +83,21 @@ constructor(

    /** Runnable to show the primary bouncer. */
    val showRunnable = Runnable {
        repository.setPrimaryVisible(true)
        repository.setPrimaryShow(
            KeyguardBouncerModel(
                promptReason = repository.bouncerPromptReason ?: 0,
                errorMessage = repository.bouncerErrorMessage,
                expansionAmount = repository.panelExpansionAmount.value
            )
        repository.setPrimaryShow(true)
        primaryBouncerView.delegate?.showPromptReason(repository.bouncerPromptReason)
        (repository.bouncerErrorMessage as? String)?.let {
            repository.setShowMessage(
                BouncerShowMessageModel(message = it, Utils.getColorError(context))
            )
        }
        repository.setPrimaryShowingSoon(false)
        primaryBouncerCallbackInteractor.dispatchVisibilityChanged(View.VISIBLE)
    }

    val keyguardAuthenticated: Flow<Boolean> = repository.keyguardAuthenticated.filterNotNull()
    val show: Flow<KeyguardBouncerModel> = repository.primaryBouncerShow.filterNotNull()
    val hide: Flow<Unit> = repository.primaryBouncerHide.filter { it }.map {}
    val show: Flow<Unit> = repository.primaryBouncerShow.filter { it }.map {}
    val hide: Flow<Unit> = repository.primaryBouncerShow.filter { !it }.map {}
    val startingToHide: Flow<Unit> = repository.primaryBouncerStartingToHide.filter { it }.map {}
    val isVisible: Flow<Boolean> = repository.primaryBouncerVisible
    val isBackButtonEnabled: Flow<Boolean> = repository.isBackButtonEnabled.filterNotNull()
    val showMessage: Flow<BouncerShowMessageModel> = repository.showMessage.filterNotNull()
    val startingDisappearAnimation: Flow<Runnable> =
@@ -107,10 +107,11 @@ constructor(
    val panelExpansionAmount: Flow<Float> = repository.panelExpansionAmount
    /** 0f = bouncer fully hidden. 1f = bouncer fully visible. */
    val bouncerExpansion: Flow<Float> =
        combine(repository.panelExpansionAmount, repository.primaryBouncerVisible) {
            panelExpansion,
            primaryBouncerVisible ->
            if (primaryBouncerVisible) {
        combine(
            repository.panelExpansionAmount,
            repository.primaryBouncerShow
        ) { panelExpansion, primaryBouncerIsShowing ->
            if (primaryBouncerIsShowing) {
                1f - panelExpansion
            } else {
                0f
@@ -120,10 +121,9 @@ constructor(
    val isInteractable: Flow<Boolean> = bouncerExpansion.map { it > 0.9 }
    val sideFpsShowing: Flow<Boolean> = repository.sideFpsShowing

    /**
     * This callback needs to be a class field so it does not get garbage collected.
     */
    val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() {
    /** This callback needs to be a class field so it does not get garbage collected. */
    val keyguardUpdateMonitorCallback =
        object : KeyguardUpdateMonitorCallback() {
            override fun onBiometricRunningStateChanged(
                running: Boolean,
                biometricSourceType: BiometricSourceType?
@@ -147,14 +147,13 @@ constructor(
    fun show(isScrimmed: Boolean) {
        // Reset some states as we show the bouncer.
        repository.setKeyguardAuthenticated(null)
        repository.setPrimaryHide(false)
        repository.setPrimaryStartingToHide(false)

        val resumeBouncer =
            (repository.primaryBouncerVisible.value ||
                repository.primaryBouncerShowingSoon.value) && needsFullscreenBouncer()
            (isBouncerShowing() || repository.primaryBouncerShowingSoon.value) &&
                needsFullscreenBouncer()

        if (!resumeBouncer && repository.primaryBouncerShow.value != null) {
        if (!resumeBouncer && isBouncerShowing()) {
            // If bouncer is visible, the bouncer is already showing.
            return
        }
@@ -201,9 +200,7 @@ constructor(
        keyguardStateController.notifyPrimaryBouncerShowing(false /* showing */)
        cancelShowRunnable()
        repository.setPrimaryShowingSoon(false)
        repository.setPrimaryVisible(false)
        repository.setPrimaryHide(true)
        repository.setPrimaryShow(null)
        repository.setPrimaryShow(false)
        primaryBouncerCallbackInteractor.dispatchVisibilityChanged(View.INVISIBLE)
        Trace.endSection()
    }
@@ -320,9 +317,8 @@ constructor(
        val fpsDetectionRunning: Boolean = keyguardUpdateMonitor.isFingerprintDetectionRunning
        val isUnlockingWithFpAllowed: Boolean =
            keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed
        val bouncerVisible = repository.primaryBouncerVisible.value
        val toShow =
            (repository.primaryBouncerVisible.value &&
            (isBouncerShowing() &&
                sfpsEnabled &&
                fpsDetectionRunning &&
                isUnlockingWithFpAllowed &&
@@ -332,7 +328,7 @@ constructor(
            Log.d(
                TAG,
                ("sideFpsToShow=$toShow\n" +
                    "bouncerVisible=$bouncerVisible\n" +
                    "isBouncerShowing=${isBouncerShowing()}\n" +
                    "configEnabled=$sfpsEnabled\n" +
                    "fpsDetectionRunning=$fpsDetectionRunning\n" +
                    "isUnlockingWithFpAllowed=$isUnlockingWithFpAllowed\n" +
@@ -344,8 +340,7 @@ constructor(

    /** Returns whether bouncer is fully showing. */
    fun isFullyShowing(): Boolean {
        return (repository.primaryBouncerShowingSoon.value ||
            repository.primaryBouncerVisible.value) &&
        return (repository.primaryBouncerShowingSoon.value || isBouncerShowing()) &&
            repository.panelExpansionAmount.value == KeyguardBouncerConstants.EXPANSION_VISIBLE &&
            repository.primaryBouncerStartingDisappearAnimation.value == null
    }
@@ -391,6 +386,10 @@ constructor(
        mainHandler.removeCallbacks(showRunnable)
    }

    private fun isBouncerShowing(): Boolean {
        return repository.primaryBouncerShow.value
    }

    companion object {
        private const val TAG = "PrimaryBouncerInteractor"
    }
+0 −24
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.shared.model

/** Models the state of the lock-screen bouncer */
data class KeyguardBouncerModel(
    val promptReason: Int = 0,
    val errorMessage: CharSequence? = null,
    val expansionAmount: Float = 0f,
)
Loading