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

Commit 71f0123c authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

1/N sideFPs bouncer, separate altBouncer callback

The AltBouncer callback should only
handle events relevant to any alternate
bouncer (ie: show and hide). Other callbacks
like setQsExpanded and onTouch should be moved
out to a different callback since they're not
relevant to all alternate bouncers.

This CL also converts UdfpsKeyguardViewController to
kotlin and, when the modern bouncer is enabled,
uses the BouncerInteractor for the bouncerExpansion
to determine whether to show the UDPFS affordance
or not.

Test: atest UdfpsKeyguardViewControllerTest
Test: atest UdfpsKeyguardViewControllerWithCoroutinesTest
Test: wallet activity shows udfps affordance
Test: tapping home controls affordances
shows udfps bouncer
Test: tapping notification w/ intent shows
udfps bouncer
Bug: 237362467

Change-Id: Ibb9b55e6b1a629e28f523ac62058f7e5cf40faed
Merged-In: Ibb9b55e6b1a629e28f523ac62058f7e5cf40faed
parent 4a164f86
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -60,7 +60,9 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.domain.interactor.BouncerInteractor;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shade.ShadeExpansionStateManager;
@@ -119,6 +121,7 @@ public class UdfpsController implements DozeReceiver {
    @NonNull private final SystemUIDialogManager mDialogManager;
    @NonNull private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    @NonNull private final VibratorHelper mVibrator;
    @NonNull private final FeatureFlags mFeatureFlags;
    @NonNull private final FalsingManager mFalsingManager;
    @NonNull private final PowerManager mPowerManager;
    @NonNull private final AccessibilityManager mAccessibilityManager;
@@ -130,6 +133,7 @@ public class UdfpsController implements DozeReceiver {
    @NonNull private final LatencyTracker mLatencyTracker;
    @VisibleForTesting @NonNull final BiometricDisplayListener mOrientationListener;
    @NonNull private final ActivityLaunchAnimator mActivityLaunchAnimator;
    @NonNull private final BouncerInteractor mBouncerInteractor;

    // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple
    // sensors, this, in addition to a lot of the code here, will be updated.
@@ -212,7 +216,8 @@ public class UdfpsController implements DozeReceiver {
                            mUnlockedScreenOffAnimationController,
                            mUdfpsDisplayMode, requestId, reason, callback,
                            (view, event, fromUdfpsView) -> onTouch(requestId, event,
                                    fromUdfpsView), mActivityLaunchAnimator)));
                                    fromUdfpsView), mActivityLaunchAnimator, mFeatureFlags,
                            mBouncerInteractor)));
        }

        @Override
@@ -590,6 +595,7 @@ public class UdfpsController implements DozeReceiver {
            @NonNull StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            @NonNull DumpManager dumpManager,
            @NonNull KeyguardUpdateMonitor keyguardUpdateMonitor,
            @NonNull FeatureFlags featureFlags,
            @NonNull FalsingManager falsingManager,
            @NonNull PowerManager powerManager,
            @NonNull AccessibilityManager accessibilityManager,
@@ -608,7 +614,8 @@ public class UdfpsController implements DozeReceiver {
            @NonNull LatencyTracker latencyTracker,
            @NonNull ActivityLaunchAnimator activityLaunchAnimator,
            @NonNull Optional<AlternateUdfpsTouchProvider> alternateTouchProvider,
            @BiometricsBackground Executor biometricsExecutor) {
            @BiometricsBackground Executor biometricsExecutor,
            @NonNull BouncerInteractor bouncerInteractor) {
        mContext = context;
        mExecution = execution;
        mVibrator = vibrator;
@@ -638,6 +645,8 @@ public class UdfpsController implements DozeReceiver {
        mActivityLaunchAnimator = activityLaunchAnimator;
        mAlternateTouchProvider = alternateTouchProvider.orElse(null);
        mBiometricExecutor = biometricsExecutor;
        mFeatureFlags = featureFlags;
        mBouncerInteractor = bouncerInteractor;

        mOrientationListener = new BiometricDisplayListener(
                context,
+30 −24
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.R
import com.android.systemui.animation.ActivityLaunchAnimator
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.keyguard.domain.interactor.BouncerInteractor
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.shade.ShadeExpansionStateManager
import com.android.systemui.statusbar.LockscreenShadeTransitionController
@@ -92,6 +94,8 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
        private val controllerCallback: IUdfpsOverlayControllerCallback,
        private val onTouch: (View, MotionEvent, Boolean) -> Boolean,
        private val activityLaunchAnimator: ActivityLaunchAnimator,
        private val featureFlags: FeatureFlags,
        private val bouncerInteractor: BouncerInteractor,
        private val isDebuggable: Boolean = Build.IS_DEBUGGABLE
) {
    /** The view, when [isShowing], or null. */
@@ -246,7 +250,9 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
                    unlockedScreenOffAnimationController,
                    dialogManager,
                    controller,
                    activityLaunchAnimator
                    activityLaunchAnimator,
                    featureFlags,
                    bouncerInteractor
                )
            }
            REASON_AUTH_BP -> {
+440 −438

File changed.

Preview size limit exceeded, changes collapsed.

+12 −6
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.shared.model.BouncerCallbackActionsModel
import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel
import com.android.systemui.keyguard.shared.model.KeyguardBouncerModel
import com.android.systemui.statusbar.phone.KeyguardBouncer.EXPANSION_HIDDEN
import com.android.systemui.statusbar.phone.KeyguardBouncer
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
@@ -41,9 +41,15 @@ constructor(
    /** Determines if we want to instantaneously show the bouncer instead of translating. */
    private val _isScrimmed = MutableStateFlow(false)
    val isScrimmed = _isScrimmed.asStateFlow()
    /** Set amount of how much of the bouncer is showing on the screen */
    private val _expansionAmount = MutableStateFlow(EXPANSION_HIDDEN)
    val expansionAmount = _expansionAmount.asStateFlow()
    /**
     * Set how much of the panel is showing on the screen.
     * ```
     *      0f = panel fully hidden = bouncer fully showing
     *      1f = panel fully showing = bouncer fully hidden
     * ```
     */
    private val _panelExpansionAmount = MutableStateFlow(KeyguardBouncer.EXPANSION_HIDDEN)
    val panelExpansionAmount = _panelExpansionAmount.asStateFlow()
    private val _isVisible = MutableStateFlow(false)
    val isVisible = _isVisible.asStateFlow()
    private val _show = MutableStateFlow<KeyguardBouncerModel?>(null)
@@ -96,8 +102,8 @@ constructor(
        _isScrimmed.value = isScrimmed
    }

    fun setExpansion(expansion: Float) {
        _expansionAmount.value = expansion
    fun setPanelExpansion(panelExpansion: Float) {
        _panelExpansionAmount.value = panelExpansion
    }

    fun setVisible(isVisible: Boolean) {
+25 −11
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.policy.KeyguardStateController
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
@@ -77,7 +78,7 @@ constructor(
            KeyguardBouncerModel(
                promptReason = repository.bouncerPromptReason ?: 0,
                errorMessage = repository.bouncerErrorMessage,
                expansionAmount = repository.expansionAmount.value
                expansionAmount = repository.panelExpansionAmount.value
            )
        )
        repository.setShowingSoon(false)
@@ -90,7 +91,6 @@ constructor(
    val startingToHide: Flow<Unit> = repository.startingToHide.filter { it }.map {}
    val isVisible: Flow<Boolean> = repository.isVisible
    val isBackButtonEnabled: Flow<Boolean> = repository.isBackButtonEnabled.filterNotNull()
    val expansionAmount: Flow<Float> = repository.expansionAmount
    val showMessage: Flow<BouncerShowMessageModel> = repository.showMessage.filterNotNull()
    val startingDisappearAnimation: Flow<Runnable> =
        repository.startingDisappearAnimation.filterNotNull()
@@ -98,6 +98,17 @@ constructor(
        repository.onDismissAction.filterNotNull()
    val resourceUpdateRequests: Flow<Boolean> = repository.resourceUpdateRequests.filter { it }
    val keyguardPosition: Flow<Float> = repository.keyguardPosition
    val panelExpansionAmount: Flow<Float> = repository.panelExpansionAmount
    /** 0f = bouncer fully hidden. 1f = bouncer fully visible. */
    val bouncerExpansion: Flow<Float> = //
        combine(repository.panelExpansionAmount, repository.isVisible) { expansionAmount, isVisible
            ->
            if (isVisible) {
                1f - expansionAmount
            } else {
                0f
            }
        }

    // TODO(b/243685699): Move isScrimmed logic to data layer.
    // TODO(b/243695312): Encapsulate all of the show logic for the bouncer.
@@ -128,7 +139,7 @@ constructor(
        Trace.beginSection("KeyguardBouncer#show")
        repository.setScrimmed(isScrimmed)
        if (isScrimmed) {
            setExpansion(KeyguardBouncer.EXPANSION_VISIBLE)
            setPanelExpansion(KeyguardBouncer.EXPANSION_VISIBLE)
        }

        if (resumeBouncer) {
@@ -176,14 +187,17 @@ constructor(
    }

    /**
     * Sets the panel expansion which is calculated further upstream. Expansion is from 0f to 1f
     * where 0f => showing and 1f => hiding
     * Sets the panel expansion which is calculated further upstream. Panel expansion is from 0f
     * (panel fully hidden) to 1f (panel fully showing). As the panel shows (from 0f => 1f), the
     * bouncer hides and as the panel becomes hidden (1f => 0f), the bouncer starts to show.
     * Therefore, a panel expansion of 1f represents the bouncer fully hidden and a panel expansion
     * of 0f represents the bouncer fully showing.
     */
    fun setExpansion(expansion: Float) {
        val oldExpansion = repository.expansionAmount.value
    fun setPanelExpansion(expansion: Float) {
        val oldExpansion = repository.panelExpansionAmount.value
        val expansionChanged = oldExpansion != expansion
        if (repository.startingDisappearAnimation.value == null) {
            repository.setExpansion(expansion)
            repository.setPanelExpansion(expansion)
        }

        if (
@@ -282,7 +296,7 @@ constructor(
    /** Returns whether bouncer is fully showing. */
    fun isFullyShowing(): Boolean {
        return (repository.showingSoon.value || repository.isVisible.value) &&
            repository.expansionAmount.value == KeyguardBouncer.EXPANSION_VISIBLE &&
            repository.panelExpansionAmount.value == KeyguardBouncer.EXPANSION_VISIBLE &&
            repository.startingDisappearAnimation.value == null
    }

@@ -294,8 +308,8 @@ constructor(
    /** If bouncer expansion is between 0f and 1f non-inclusive. */
    fun isInTransit(): Boolean {
        return repository.showingSoon.value ||
            repository.expansionAmount.value != KeyguardBouncer.EXPANSION_HIDDEN &&
                repository.expansionAmount.value != KeyguardBouncer.EXPANSION_VISIBLE
            repository.panelExpansionAmount.value != KeyguardBouncer.EXPANSION_HIDDEN &&
                repository.panelExpansionAmount.value != KeyguardBouncer.EXPANSION_VISIBLE
    }

    /** Return whether bouncer is animating away. */
Loading