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

Commit f53802eb authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Send signals to the Falsing system.

Adds signal-sending to Flexiglass to report the appropriate signals to
the Falsing system and drive it.

Fix: 297262816
Test: unit tests added where relevant
Test: manually verified that the right signals are sent at the right
times by Flexiglass.

Change-Id: I405fc27a50c9bb75e198f90d9fd7d8210af82a69
parent 12136eef
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TextField
import androidx.compose.material3.TextField
@@ -45,7 +44,6 @@ import androidx.compose.ui.unit.dp
import com.android.systemui.bouncer.ui.viewmodel.PasswordBouncerViewModel
import com.android.systemui.bouncer.ui.viewmodel.PasswordBouncerViewModel


/** UI for the input part of a password-requiring version of the bouncer. */
/** UI for the input part of a password-requiring version of the bouncer. */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@Composable
internal fun PasswordBouncer(
internal fun PasswordBouncer(
    viewModel: PasswordBouncerViewModel,
    viewModel: PasswordBouncerViewModel,
+33 −25
Original line number Original line Diff line number Diff line
@@ -21,6 +21,8 @@ import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composable
@@ -199,6 +201,12 @@ internal fun PatternBouncer(
            .onSizeChanged { containerSize = it }
            .onSizeChanged { containerSize = it }
            .thenIf(isInputEnabled) {
            .thenIf(isInputEnabled) {
                Modifier.pointerInput(Unit) {
                Modifier.pointerInput(Unit) {
                        awaitEachGesture {
                            awaitFirstDown()
                            viewModel.onDown()
                        }
                    }
                    .pointerInput(Unit) {
                        detectDragGestures(
                        detectDragGestures(
                            onDragStart = { start ->
                            onDragStart = { start ->
                                inputPosition = start
                                inputPosition = start
@@ -209,8 +217,8 @@ internal fun PatternBouncer(
                                if (isAnimationEnabled) {
                                if (isAnimationEnabled) {
                                    lineFadeOutAnimatables.values.forEach { animatable ->
                                    lineFadeOutAnimatables.values.forEach { animatable ->
                                        // Launch using the longer-lived scope because we want these
                                        // Launch using the longer-lived scope because we want these
                                    // animations to proceed to completion even if the surrounding
                                        // animations to proceed to completion even if the
                                    // scope is canceled.
                                        // surrounding scope is canceled.
                                        scope.launch { animatable.animateTo(1f) }
                                        scope.launch { animatable.animateTo(1f) }
                                    }
                                    }
                                }
                                }
+9 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,8 @@ import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.tween
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Column
@@ -76,7 +78,13 @@ internal fun PinBouncer(


    Column(
    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = modifier,
        modifier =
            modifier.pointerInput(Unit) {
                awaitEachGesture {
                    awaitFirstDown()
                    viewModel.onDown()
                }
            }
    ) {
    ) {
        PinInputDisplay(viewModel)
        PinInputDisplay(viewModel)
        Spacer(Modifier.height(100.dp))
        Spacer(Modifier.height(100.dp))
+17 −1
Original line number Original line Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


@file:OptIn(ExperimentalComposeUiApi::class)

package com.android.systemui.scene.ui.composable
package com.android.systemui.scene.ui.composable


import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxSize
@@ -25,6 +27,9 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.motionEventSpy
import androidx.compose.ui.input.pointer.motionEventSpy
import androidx.compose.ui.input.pointer.PointerEventPass
import androidx.compose.ui.input.pointer.motionEventSpy
import androidx.compose.ui.input.pointer.pointerInput
import com.android.compose.animation.scene.Back
import com.android.compose.animation.scene.Back
import com.android.compose.animation.scene.ObservableTransitionState as SceneTransitionObservableTransitionState
import com.android.compose.animation.scene.ObservableTransitionState as SceneTransitionObservableTransitionState
import com.android.compose.animation.scene.SceneKey as SceneTransitionSceneKey
import com.android.compose.animation.scene.SceneKey as SceneTransitionSceneKey
@@ -82,7 +87,18 @@ fun SceneContainer(
        onChangeScene = viewModel::onSceneChanged,
        onChangeScene = viewModel::onSceneChanged,
        transitions = SceneContainerTransitions,
        transitions = SceneContainerTransitions,
        state = state,
        state = state,
        modifier = modifier.fillMaxSize().motionEventSpy { viewModel.onUserInput() },
        modifier =
            modifier
                .fillMaxSize()
                .motionEventSpy { event -> viewModel.onMotionEvent(event) }
                .pointerInput(Unit) {
                    awaitPointerEventScope {
                        while (true) {
                            awaitPointerEvent(PointerEventPass.Final)
                            viewModel.onMotionEventComplete()
                        }
                    }
                }
    ) {
    ) {
        sceneByKey.forEach { (sceneKey, composableScene) ->
        sceneByKey.forEach { (sceneKey, composableScene) ->
            scene(
            scene(
+31 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@ import com.android.systemui.authentication.domain.interactor.AuthenticationInter
import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.bouncer.data.repository.BouncerRepository
import com.android.systemui.bouncer.data.repository.BouncerRepository
import com.android.systemui.classifier.FalsingClassifier
import com.android.systemui.classifier.domain.interactor.FalsingInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.FeatureFlags
@@ -50,6 +52,7 @@ constructor(
    private val authenticationInteractor: AuthenticationInteractor,
    private val authenticationInteractor: AuthenticationInteractor,
    private val sceneInteractor: SceneInteractor,
    private val sceneInteractor: SceneInteractor,
    featureFlags: FeatureFlags,
    featureFlags: FeatureFlags,
    private val falsingInteractor: FalsingInteractor,
) {
) {


    /** The user-facing message to show in the bouncer. */
    /** The user-facing message to show in the bouncer. */
@@ -103,6 +106,34 @@ constructor(
        }
        }
    }
    }


    /** Notifies that the user has places down a pointer, not necessarily dragging just yet. */
    fun onDown() {
        falsingInteractor.avoidGesture()
    }

    /**
     * Notifies of "intentional" (i.e. non-false) user interaction with the UI which is very likely
     * to be real user interaction with the bouncer and not the result of a false touch in the
     * user's pocket or by the user's face while holding their device up to their ear.
     */
    fun onIntentionalUserInput() {
        falsingInteractor.updateFalseConfidence(FalsingClassifier.Result.passed(0.6))
    }

    /**
     * Notifies of false input which is very likely to be the result of a false touch in the user's
     * pocket or by the user's face while holding their device up to their ear.
     */
    fun onFalseUserInput() {
        falsingInteractor.updateFalseConfidence(
            FalsingClassifier.Result.falsed(
                /* confidence= */ 0.7,
                /* context= */ javaClass.simpleName,
                /* reason= */ "empty pattern input",
            )
        )
    }

    /**
    /**
     * Either shows the bouncer or unlocks the device, if the bouncer doesn't need to be shown.
     * Either shows the bouncer or unlocks the device, if the bouncer doesn't need to be shown.
     *
     *
Loading