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

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

Merge "Adding MSDL Feedback to the Pin bouncer." into main

parents 12b62f34 92ff273e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
                fakeFeatureFlags,
                mSelectedUserInteractor,
                keyguardKeyboardInteractor,
                null,
            )
    }

+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
                mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
                mKeyguardMessageAreaControllerFactory, mLatencyTracker, mLiftToactivateListener,
                mEmergencyButtonController, mFalsingCollector, featureFlags,
                mSelectedUserInteractor, keyguardKeyboardInteractor) {
                mSelectedUserInteractor, keyguardKeyboardInteractor, null) {
            @Override
            public void onResume(int reason) {
                super.onResume(reason);
+1 −0
Original line number Diff line number Diff line
@@ -237,6 +237,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
                featureFlags,
                mSelectedUserInteractor,
                keyguardKeyboardInteractor,
                null,
            )

        kosmos = testKosmos()
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.keyguard

import android.os.VibrationAttributes
import com.google.android.msdl.domain.InteractionProperties

/**
 * This class represents the set of [InteractionProperties] that only hold [VibrationAttributes] for
 * the case of user authentication.
 */
data class AuthInteractionProperties(
    override val vibrationAttributes: VibrationAttributes =
        VibrationAttributes.createForUsage(VibrationAttributes.USAGE_COMMUNICATION_REQUEST)
) : InteractionProperties
+24 −1
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ package com.android.keyguard;
import static com.android.internal.util.LatencyTracker.ACTION_CHECK_CREDENTIAL;
import static com.android.internal.util.LatencyTracker.ACTION_CHECK_CREDENTIAL_UNLOCKED;
import static com.android.keyguard.KeyguardAbsKeyInputView.MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT;
import static com.android.systemui.Flags.msdlFeedback;

import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.os.AsyncTask;
import android.os.CountDownTimer;
@@ -40,6 +42,9 @@ import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.res.R;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;

import com.google.android.msdl.data.model.MSDLToken;
import com.google.android.msdl.domain.MSDLPlayer;

import java.util.HashMap;
import java.util.Map;

@@ -55,6 +60,8 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
    protected AsyncTask<?, ?, ?> mPendingLockCheck;
    protected boolean mResumed;
    protected boolean mLockedOut;
    @Nullable
    protected MSDLPlayer mMSDLPlayer;

    private final KeyDownListener mKeyDownListener = (keyCode, keyEvent) -> {
        // Fingerprint sensor sends a KeyEvent.KEYCODE_UNKNOWN.
@@ -81,7 +88,8 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
            KeyguardMessageAreaController.Factory messageAreaControllerFactory,
            LatencyTracker latencyTracker, FalsingCollector falsingCollector,
            EmergencyButtonController emergencyButtonController,
            FeatureFlags featureFlags, SelectedUserInteractor selectedUserInteractor) {
            FeatureFlags featureFlags, SelectedUserInteractor selectedUserInteractor,
            @Nullable MSDLPlayer msdlPlayer) {
        super(view, securityMode, keyguardSecurityCallback, emergencyButtonController,
                messageAreaControllerFactory, featureFlags, selectedUserInteractor);
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
@@ -89,6 +97,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
        mLatencyTracker = latencyTracker;
        mFalsingCollector = falsingCollector;
        mEmergencyButtonController = emergencyButtonController;
        mMSDLPlayer = msdlPlayer;
    }

    abstract void resetState();
@@ -178,6 +187,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
    void onPasswordChecked(int userId, boolean matched, int timeoutMs, boolean isValidPassword) {
        boolean dismissKeyguard = mSelectedUserInteractor.getSelectedUserId() == userId;
        if (matched) {
            playAuthenticationHaptics(/* unlock= */true);
            getKeyguardSecurityCallback().reportUnlockAttempt(userId, true, 0);
            if (dismissKeyguard) {
                mDismissing = true;
@@ -185,6 +195,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
                getKeyguardSecurityCallback().dismiss(true, userId, getSecurityMode());
            }
        } else {
            playAuthenticationHaptics(/* unlock= */false);
            mView.resetPasswordText(true /* animate */, false /* announce deletion if no match */);
            if (isValidPassword) {
                getKeyguardSecurityCallback().reportUnlockAttempt(userId, false, timeoutMs);
@@ -201,6 +212,18 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
        }
    }

    private void playAuthenticationHaptics(boolean unlock) {
        if (!msdlFeedback() || mMSDLPlayer == null) return;

        MSDLToken token;
        if (unlock) {
            token = MSDLToken.UNLOCK;
        } else {
            token = MSDLToken.FAILURE;
        }
        mMSDLPlayer.playToken(token, mAuthInteractionProperties);
    }

    protected void startErrorAnimation() { /* no-op */ }

    protected void verifyPasswordAndUnlock() {
Loading