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

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

Merge "Using MSDL feedback in Keyguard authentication results." into main

parents cad37e09 1b4b60b7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ android_library {
        "dagger2",
        "jsr330",
        "//frameworks/libs/systemui:com_android_systemui_shared_flags_lib",
        "//frameworks/libs/systemui:msdl",
    ],
    resource_dirs: [
        "res",
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.systemui.education.dagger.ContextualEducationModule;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.FlagDependenciesModule;
import com.android.systemui.flags.FlagsModule;
import com.android.systemui.haptics.msdl.dagger.MSDLModule;
import com.android.systemui.inputmethod.InputMethodModule;
import com.android.systemui.keyboard.KeyboardModule;
import com.android.systemui.keyevent.data.repository.KeyEventRepositoryModule;
@@ -231,6 +232,7 @@ import javax.inject.Named;
        MediaProjectionTaskSwitcherModule.class,
        MediaRouterModule.class,
        MotionToolModule.class,
        MSDLModule.class,
        PeopleHubModule.class,
        PeopleModule.class,
        PluginModule.class,
+32 −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.systemui.haptics.msdl.dagger

import android.content.Context
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.google.android.msdl.domain.MSDLPlayer
import dagger.Module
import dagger.Provides

@Module
object MSDLModule {
    @Provides
    @SysUISingleton
    fun provideMSDLPlayer(@Application context: Context): MSDLPlayer =
        MSDLPlayer.createPlayer(context)
}
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import com.android.systemui.statusbar.KeyguardIndicationController
import com.android.systemui.statusbar.VibratorHelper
import com.android.systemui.statusbar.phone.ScreenOffAnimationController
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.google.android.msdl.domain.MSDLPlayer
import dagger.Lazy
import java.util.Optional
import javax.inject.Inject
@@ -112,6 +113,7 @@ constructor(
    private val keyguardViewMediator: KeyguardViewMediator,
    private val deviceEntryUnlockTrackerViewBinder: Optional<DeviceEntryUnlockTrackerViewBinder>,
    @Main private val mainDispatcher: CoroutineDispatcher,
    private val msdlPlayer: MSDLPlayer,
) : CoreStartable {

    private var rootViewHandle: DisposableHandle? = null
@@ -219,6 +221,7 @@ constructor(
                falsingManager,
                keyguardViewMediator,
                mainDispatcher,
                msdlPlayer,
            )
    }

+38 −10
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.DrawableRes
import android.annotation.SuppressLint
import android.graphics.Point
import android.graphics.Rect
import android.os.VibrationAttributes
import android.util.Log
import android.view.HapticFeedbackConstants
import android.view.View
@@ -40,6 +41,7 @@ import com.android.app.animation.Interpolators
import com.android.app.tracing.coroutines.launch
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor.CUJ_SCREEN_OFF_SHOW_AOD
import com.android.systemui.Flags.msdlFeedback
import com.android.systemui.Flags.newAodTransition
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
@@ -79,6 +81,9 @@ import com.android.systemui.util.ui.AnimatedValue
import com.android.systemui.util.ui.isAnimating
import com.android.systemui.util.ui.stopAnimating
import com.android.systemui.util.ui.value
import com.google.android.msdl.data.model.MSDLToken
import com.google.android.msdl.domain.InteractionProperties
import com.google.android.msdl.domain.MSDLPlayer
import kotlin.math.min
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.DisposableHandle
@@ -112,6 +117,7 @@ object KeyguardRootViewBinder {
        falsingManager: FalsingManager?,
        keyguardViewMediator: KeyguardViewMediator?,
        mainImmediateDispatcher: CoroutineDispatcher,
        msdlPlayer: MSDLPlayer?,
    ): DisposableHandle {
        val disposables = DisposableHandles()
        val childViews = mutableMapOf<Int, View>()
@@ -351,6 +357,16 @@ object KeyguardRootViewBinder {
                    if (deviceEntryHapticsInteractor != null && vibratorHelper != null) {
                        launch {
                            deviceEntryHapticsInteractor.playSuccessHaptic.collect {
                                if (msdlFeedback()) {
                                    val properties =
                                        object : InteractionProperties {
                                            override val vibrationAttributes: VibrationAttributes =
                                                VibrationAttributes.createForUsage(
                                                    VibrationAttributes.USAGE_HARDWARE_FEEDBACK
                                                )
                                        }
                                    msdlPlayer?.playToken(MSDLToken.UNLOCK, properties)
                                } else {
                                    vibratorHelper.performHapticFeedback(
                                        view,
                                        HapticFeedbackConstants.CONFIRM,
@@ -358,9 +374,20 @@ object KeyguardRootViewBinder {
                                    )
                                }
                            }
                        }

                        launch {
                            deviceEntryHapticsInteractor.playErrorHaptic.collect {
                                if (msdlFeedback()) {
                                    val properties =
                                        object : InteractionProperties {
                                            override val vibrationAttributes: VibrationAttributes =
                                                VibrationAttributes.createForUsage(
                                                    VibrationAttributes.USAGE_HARDWARE_FEEDBACK
                                                )
                                        }
                                    msdlPlayer?.playToken(MSDLToken.FAILURE, properties)
                                } else {
                                    vibratorHelper.performHapticFeedback(
                                        view,
                                        HapticFeedbackConstants.REJECT,
@@ -371,6 +398,7 @@ object KeyguardRootViewBinder {
                        }
                    }
                }
            }

        if (MigrateClocksToBlueprint.isEnabled) {
            burnInParams.update { current ->
Loading