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

Commit cf40bf90 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Using Vibrator provided by Dagger in the MSDLModule

To avoid a duplicate service call, the vibrator provided by
FrameworkServicesModule is used. Since the vibrator is nullable, an
empty MSDL player is returned if no vibrator is provided.

Test: presubmit
Flag: NONE this is a change to the way we retrive the same service
Bug: 368595426

Change-Id: I0ed8371174b73f8a4bd47771c090633b47974c62
parent 1b9ad86f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ class MSDLCoreStartable @Inject constructor(private val msdlPlayer: MSDLPlayer)
    override fun start() {}

    override fun dump(pw: PrintWriter, args: Array<out String>) {
        pw.println("MSDLPlayer history of the last ${MSDLHistoryLogger.HISTORY_SIZE} events:")
        pw.println(msdlPlayer)
        pw.println("MSDL player history of the last ${MSDLHistoryLogger.HISTORY_SIZE} events:")
        msdlPlayer.getHistory().forEach { event -> pw.println("$event") }
    }
}
+2 −8
Original line number Diff line number Diff line
@@ -17,10 +17,8 @@
package com.android.systemui.haptics.msdl.dagger

import android.annotation.SuppressLint
import android.content.Context
import android.os.VibratorManager
import android.os.Vibrator
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
@@ -30,9 +28,5 @@ object MSDLModule {
    @SuppressLint("NonInjectedService")
    @Provides
    @SysUISingleton
    fun provideMSDLPlayer(@Application context: Context): MSDLPlayer {
        val vibratorManager =
            context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
        return MSDLPlayer.createPlayer(vibratorManager.defaultVibrator)
    }
    fun provideMSDLPlayer(vibrator: Vibrator?): MSDLPlayer = MSDLPlayer.createPlayer(vibrator)
}