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

Commit 84be5de9 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android (Google) Code Review
Browse files

Merge "Cleanup of the flag ONE_WAY_HAPTICS_API_MIGRATION on...

Merge "Cleanup of the flag ONE_WAY_HAPTICS_API_MIGRATION on BiometricViewBinder and PromptViewModel" into main
parents 24c55144 d0f2af74
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.biometrics;

import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_BIOMETRIC_PROMPT_TRANSITION;

import android.animation.Animator;
@@ -63,7 +64,6 @@ import com.android.app.animation.Interpolators;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.res.R;
import com.android.systemui.biometrics.AuthController.ScaleFactorProvider;
import com.android.systemui.biometrics.domain.interactor.PromptCredentialInteractor;
import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor;
@@ -76,8 +76,8 @@ import com.android.systemui.biometrics.ui.binder.Spaghetti;
import com.android.systemui.biometrics.ui.viewmodel.CredentialViewModel;
import com.android.systemui.biometrics.ui.viewmodel.PromptViewModel;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.util.concurrency.DelayableExecutor;

@@ -280,7 +280,6 @@ public class AuthContainerView extends LinearLayout

    // TODO(b/251476085): remove Config and further decompose these properties out of view classes
    AuthContainerView(@NonNull Config config,
            @NonNull FeatureFlags featureFlags,
            @NonNull CoroutineScope applicationCoroutineScope,
            @Nullable List<FingerprintSensorPropertiesInternal> fpProps,
            @Nullable List<FaceSensorPropertiesInternal> faceProps,
@@ -295,7 +294,7 @@ public class AuthContainerView extends LinearLayout
            @NonNull Provider<CredentialViewModel> credentialViewModelProvider,
            @NonNull @Background DelayableExecutor bgExecutor,
            @NonNull VibratorHelper vibratorHelper) {
        this(config, featureFlags, applicationCoroutineScope, fpProps, faceProps,
        this(config, applicationCoroutineScope, fpProps, faceProps,
                wakefulnessLifecycle, panelInteractionDetector, userManager, lockPatternUtils,
                jankMonitor, promptSelectorInteractor, promptCredentialInteractor, promptViewModel,
                credentialViewModelProvider, new Handler(Looper.getMainLooper()), bgExecutor,
@@ -304,7 +303,6 @@ public class AuthContainerView extends LinearLayout

    @VisibleForTesting
    AuthContainerView(@NonNull Config config,
            @NonNull FeatureFlags featureFlags,
            @NonNull CoroutineScope applicationCoroutineScope,
            @Nullable List<FingerprintSensorPropertiesInternal> fpProps,
            @Nullable List<FaceSensorPropertiesInternal> faceProps,
@@ -368,7 +366,7 @@ public class AuthContainerView extends LinearLayout
        showPrompt(config, layoutInflater, promptViewModel,
                Utils.findFirstSensorProperties(fpProps, mConfig.mSensorIds),
                Utils.findFirstSensorProperties(faceProps, mConfig.mSensorIds),
                vibratorHelper, featureFlags);
                vibratorHelper);

        // TODO: De-dupe the logic with AuthCredentialPasswordView
        setOnKeyListener((v, keyCode, event) -> {
@@ -390,8 +388,7 @@ public class AuthContainerView extends LinearLayout
            @NonNull PromptViewModel viewModel,
            @Nullable FingerprintSensorPropertiesInternal fpProps,
            @Nullable FaceSensorPropertiesInternal faceProps,
            @NonNull VibratorHelper vibratorHelper,
            @NonNull FeatureFlags featureFlags
            @NonNull VibratorHelper vibratorHelper
    ) {
        if (Utils.isBiometricAllowed(config.mPromptInfo)) {
            mPromptSelectorInteractorProvider.get().useBiometricsForAuthentication(
@@ -407,7 +404,7 @@ public class AuthContainerView extends LinearLayout
                    getJankListener(view, TRANSIT,
                            BiometricViewSizeBinder.ANIMATE_MEDIUM_TO_LARGE_DURATION_MS),
                    mBackgroundView, mBiometricCallback, mApplicationCoroutineScope,
                    vibratorHelper, featureFlags);
                    vibratorHelper);

            // TODO(b/251476085): migrate these dependencies
            if (fpProps != null && fpProps.isAnyUdfpsType()) {
+1 −5
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ import com.android.systemui.dagger.qualifiers.Application;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.data.repository.BiometricType;
import com.android.systemui.statusbar.CommandQueue;
@@ -120,7 +119,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,

    private final Handler mHandler;
    private final Context mContext;
    private final FeatureFlags mFeatureFlags;
    private final Execution mExecution;
    private final CommandQueue mCommandQueue;
    private final ActivityTaskManager mActivityTaskManager;
@@ -743,7 +741,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
    }
    @Inject
    public AuthController(Context context,
            @NonNull FeatureFlags featureFlags,
            @Application CoroutineScope applicationCoroutineScope,
            Execution execution,
            CommandQueue commandQueue,
@@ -770,7 +767,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
            @NonNull UdfpsUtils udfpsUtils,
            @NonNull VibratorHelper vibratorHelper) {
        mContext = context;
        mFeatureFlags = featureFlags;
        mExecution = execution;
        mUserManager = userManager;
        mLockPatternUtils = lockPatternUtils;
@@ -1316,7 +1312,7 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
        config.mRequestId = requestId;
        config.mSensorIds = sensorIds;
        config.mScaleProvider = this::getScaleFactor;
        return new AuthContainerView(config, mFeatureFlags, mApplicationCoroutineScope, mFpProps, mFaceProps,
        return new AuthContainerView(config, mApplicationCoroutineScope, mFpProps, mFaceProps,
                wakefulnessLifecycle, panelInteractionDetector, userManager, lockPatternUtils,
                mInteractionJankMonitor, mPromptCredentialInteractor, mPromptSelectorInteractor,
                viewModel, mCredentialViewModelProvider, bgExecutor, mVibratorHelper);
+5 −10
Original line number Diff line number Diff line
@@ -49,8 +49,6 @@ import com.android.systemui.biometrics.ui.viewmodel.FingerprintStartMode
import com.android.systemui.biometrics.ui.viewmodel.PromptMessage
import com.android.systemui.biometrics.ui.viewmodel.PromptSize
import com.android.systemui.biometrics.ui.viewmodel.PromptViewModel
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags.ONE_WAY_HAPTICS_API_MIGRATION
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
import com.android.systemui.statusbar.VibratorHelper
@@ -78,7 +76,6 @@ object BiometricViewBinder {
        legacyCallback: Spaghetti.Callback,
        applicationScope: CoroutineScope,
        vibratorHelper: VibratorHelper,
        featureFlags: FeatureFlags,
    ): Spaghetti {
        val accessibilityManager = view.context.getSystemService(AccessibilityManager::class.java)!!

@@ -380,7 +377,6 @@ object BiometricViewBinder {
                }

                // Play haptics
                if (featureFlags.isEnabled(ONE_WAY_HAPTICS_API_MIGRATION)) {
                launch {
                    viewModel.hapticsToPlay.collect { hapticFeedbackConstant ->
                        if (hapticFeedbackConstant != HapticFeedbackConstants.NO_HAPTICS) {
@@ -391,7 +387,6 @@ object BiometricViewBinder {
                }
            }
        }
        }

        return adapter
    }
+7 −20
Original line number Diff line number Diff line
@@ -29,10 +29,7 @@ import com.android.systemui.biometrics.shared.model.BiometricModality
import com.android.systemui.biometrics.shared.model.DisplayRotation
import com.android.systemui.biometrics.shared.model.PromptKind
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags.ONE_WAY_HAPTICS_API_MIGRATION
import com.android.systemui.res.R
import com.android.systemui.statusbar.VibratorHelper
import javax.inject.Inject
import kotlinx.coroutines.Job
import kotlinx.coroutines.coroutineScope
@@ -52,9 +49,7 @@ class PromptViewModel
constructor(
    displayStateInteractor: DisplayStateInteractor,
    promptSelectorInteractor: PromptSelectorInteractor,
    private val vibrator: VibratorHelper,
    @Application context: Context,
    private val featureFlags: FeatureFlags,
) {
    /** The set of modalities available for this prompt */
    val modalities: Flow<BiometricModalities> =
@@ -339,7 +334,7 @@ constructor(
        _message.value = PromptMessage.Error(message)

        if (hapticFeedback) {
            vibrator.error(failedModality)
            vibrateOnError()
        }

        messageJob?.cancel()
@@ -457,7 +452,7 @@ constructor(
        _message.value = PromptMessage.Empty

        if (!needsUserConfirmation) {
            vibrator.success(modality)
            vibrateOnSuccess()
        }

        messageJob?.cancel()
@@ -495,7 +490,7 @@ constructor(
        _isAuthenticated.value = authState.asExplicitlyConfirmed()
        _message.value = PromptMessage.Empty

        vibrator.success(authState.authenticatedModality)
        vibrateOnSuccess()

        messageJob?.cancel()
        messageJob = null
@@ -530,20 +525,12 @@ constructor(
        _forceLargeSize.value = true
    }

    private fun VibratorHelper.success(modality: BiometricModality) {
        if (featureFlags.isEnabled(ONE_WAY_HAPTICS_API_MIGRATION)) {
    private fun vibrateOnSuccess() {
        _hapticsToPlay.value = HapticFeedbackConstants.CONFIRM
        } else {
            vibrateAuthSuccess("$TAG, modality = $modality BP::success")
        }
    }

    private fun VibratorHelper.error(modality: BiometricModality = BiometricModality.None) {
        if (featureFlags.isEnabled(ONE_WAY_HAPTICS_API_MIGRATION)) {
    private fun vibrateOnError() {
        _hapticsToPlay.value = HapticFeedbackConstants.REJECT
        } else {
            vibrateAuthError("$TAG, modality = $modality BP::error")
        }
    }

    /** Clears the [hapticsToPlay] variable by setting it to the NO_HAPTICS default. */
+0 −3
Original line number Diff line number Diff line
@@ -505,7 +505,6 @@ open class AuthContainerViewTest : SysuiTestCase() {
                this.authenticators = authenticators
            }
        },
        featureFlags,
        testScope.backgroundScope,
        fingerprintProps,
        faceProps,
@@ -519,9 +518,7 @@ open class AuthContainerViewTest : SysuiTestCase() {
        PromptViewModel(
            displayStateInteractor,
            promptSelectorInteractor,
            vibrator,
            context,
            featureFlags
        ),
        { credentialViewModel },
        Handler(TestableLooper.get(this).looper),
Loading