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

Commit 9666b56a 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 am: 388b57a0

parents 664195f9 388b57a0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5130,4 +5130,5 @@
  <java-symbol type="style" name="ThemeOverlay.DeviceDefault.Dark.ActionBar.Accent" />

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

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

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

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

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

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

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

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

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

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

@Module
+11 −0
Original line number Diff line number Diff line
@@ -75,6 +75,12 @@ constructor(
     */
    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 {
        // UNLOCKS WHEN AUTH METHOD REMOVED.
        //
@@ -130,7 +136,12 @@ constructor(
            }

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

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

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

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

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

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

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

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