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

Commit 1799c7e9 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Automerger Merge Worker
Browse files

Merge "[flexiglass] Bouncer throttling - data and domain layers." into udc-dev...

Merge "[flexiglass] Bouncer throttling - data and domain layers." into udc-dev am: 388b57a0 am: cbce4535

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



Change-Id: I6823fa8e67096a595ffe65ed598e066db289fd09
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7e945e9c cbce4535
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -5131,4 +5131,5 @@
  <java-symbol type="style" name="ThemeOverlay.DeviceDefault.Dark.ActionBar.Accent" />
  <java-symbol type="style" name="ThemeOverlay.DeviceDefault.Dark.ActionBar.Accent" />


  <java-symbol type="drawable" name="focus_event_pressed_key_background" />
  <java-symbol type="drawable" name="focus_event_pressed_key_background" />
  <java-symbol type="string" name="lockscreen_too_many_failed_attempts_countdown" />
</resources>
</resources>
+17 −0
Original line number Original line Diff line number Diff line
@@ -51,6 +51,12 @@ interface AuthenticationRepository {
     */
     */
    val isBypassEnabled: StateFlow<Boolean>
    val isBypassEnabled: StateFlow<Boolean>


    /**
     * Number of consecutively failed authentication attempts. This resets to `0` when
     * authentication succeeds.
     */
    val failedAuthenticationAttempts: StateFlow<Int>

    /** See [isUnlocked]. */
    /** See [isUnlocked]. */
    fun setUnlocked(isUnlocked: Boolean)
    fun setUnlocked(isUnlocked: Boolean)


@@ -59,6 +65,9 @@ interface AuthenticationRepository {


    /** See [isBypassEnabled]. */
    /** See [isBypassEnabled]. */
    fun setBypassEnabled(isBypassEnabled: Boolean)
    fun setBypassEnabled(isBypassEnabled: Boolean)

    /** See [failedAuthenticationAttempts]. */
    fun setFailedAuthenticationAttempts(failedAuthenticationAttempts: Int)
}
}


class AuthenticationRepositoryImpl @Inject constructor() : AuthenticationRepository {
class AuthenticationRepositoryImpl @Inject constructor() : AuthenticationRepository {
@@ -75,6 +84,10 @@ class AuthenticationRepositoryImpl @Inject constructor() : AuthenticationReposit
    private val _isBypassEnabled = MutableStateFlow(false)
    private val _isBypassEnabled = MutableStateFlow(false)
    override val isBypassEnabled: StateFlow<Boolean> = _isBypassEnabled.asStateFlow()
    override val isBypassEnabled: StateFlow<Boolean> = _isBypassEnabled.asStateFlow()


    private val _failedAuthenticationAttempts = MutableStateFlow(0)
    override val failedAuthenticationAttempts: StateFlow<Int> =
        _failedAuthenticationAttempts.asStateFlow()

    override fun setUnlocked(isUnlocked: Boolean) {
    override fun setUnlocked(isUnlocked: Boolean) {
        _isUnlocked.value = isUnlocked
        _isUnlocked.value = isUnlocked
    }
    }
@@ -86,6 +99,10 @@ class AuthenticationRepositoryImpl @Inject constructor() : AuthenticationReposit
    override fun setAuthenticationMethod(authenticationMethod: AuthenticationMethodModel) {
    override fun setAuthenticationMethod(authenticationMethod: AuthenticationMethodModel) {
        _authenticationMethod.value = authenticationMethod
        _authenticationMethod.value = authenticationMethod
    }
    }

    override fun setFailedAuthenticationAttempts(failedAuthenticationAttempts: Int) {
        _failedAuthenticationAttempts.value = failedAuthenticationAttempts
    }
}
}


@Module
@Module
+11 −0
Original line number Original line Diff line number Diff line
@@ -75,6 +75,12 @@ constructor(
     */
     */
    val isBypassEnabled: StateFlow<Boolean> = repository.isBypassEnabled
    val isBypassEnabled: StateFlow<Boolean> = repository.isBypassEnabled


    /**
     * Number of consecutively failed authentication attempts. This resets to `0` when
     * authentication succeeds.
     */
    val failedAuthenticationAttempts: StateFlow<Int> = repository.failedAuthenticationAttempts

    init {
    init {
        // UNLOCKS WHEN AUTH METHOD REMOVED.
        // UNLOCKS WHEN AUTH METHOD REMOVED.
        //
        //
@@ -130,7 +136,12 @@ constructor(
            }
            }


        if (isSuccessful) {
        if (isSuccessful) {
            repository.setFailedAuthenticationAttempts(0)
            repository.setUnlocked(true)
            repository.setUnlocked(true)
        } else {
            repository.setFailedAuthenticationAttempts(
                repository.failedAuthenticationAttempts.value + 1
            )
        }
        }


        return isSuccessful
        return isSuccessful
+4 −2
Original line number Original line Diff line number Diff line
@@ -36,8 +36,10 @@ sealed class AuthenticationMethodModel(


    data class Password(val password: String) : AuthenticationMethodModel(isSecure = true)
    data class Password(val password: String) : AuthenticationMethodModel(isSecure = true)


    data class Pattern(val coordinates: List<PatternCoordinate>) :
    data class Pattern(
        AuthenticationMethodModel(isSecure = true) {
        val coordinates: List<PatternCoordinate>,
        val isPatternVisible: Boolean = true,
    ) : AuthenticationMethodModel(isSecure = true) {


        data class PatternCoordinate(
        data class PatternCoordinate(
            val x: Int,
            val x: Int,
+9 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.bouncer.data.repo
package com.android.systemui.bouncer.data.repo


import com.android.systemui.bouncer.shared.model.AuthenticationThrottledModel
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import javax.inject.Inject
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.MutableStateFlow
@@ -29,7 +30,15 @@ class BouncerRepository @Inject constructor() {
    /** The user-facing message to show in the bouncer. */
    /** The user-facing message to show in the bouncer. */
    val message: StateFlow<String?> = _message.asStateFlow()
    val message: StateFlow<String?> = _message.asStateFlow()


    private val _throttling = MutableStateFlow<AuthenticationThrottledModel?>(null)
    /** The current authentication throttling state. If `null`, there's no throttling. */
    val throttling: StateFlow<AuthenticationThrottledModel?> = _throttling.asStateFlow()

    fun setMessage(message: String?) {
    fun setMessage(message: String?) {
        _message.value = message
        _message.value = message
    }
    }

    fun setThrottling(throttling: AuthenticationThrottledModel?) {
        _throttling.value = throttling
    }
}
}
Loading