From 6452b5c2b450da8de1f6ee4717b9940b49616b1e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 4 Dec 2023 17:54:48 +0100 Subject: [PATCH] Make DefaultMdmService a singleton and use Binds instead of Provides. --- .../main/java/im/vector/app/core/di/SingletonModule.kt | 8 +++----- .../java/im/vector/app/features/mdm/DefaultMdmService.kt | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vector-app/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector-app/src/main/java/im/vector/app/core/di/SingletonModule.kt index 0c250eedb8..9c173268cc 100644 --- a/vector-app/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector-app/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -111,6 +111,9 @@ import javax.inject.Singleton @Binds abstract fun bindEmojiSpanify(emojiCompatWrapper: EmojiCompatWrapper): EmojiSpanify + @Binds + abstract fun bindMdmService(service: DefaultMdmService): MdmService + @Binds abstract fun bindFontScale(fontScale: FontScalePreferencesImpl): FontScalePreferences @@ -173,11 +176,6 @@ import javax.inject.Singleton return Matrix(context, configuration) } - @Provides - fun providesMdmService(context: Context): MdmService { - return DefaultMdmService(context) - } - @Provides fun providesCurrentSession(activeSessionHolder: ActiveSessionHolder): Session { // TODO handle session injection better diff --git a/vector/src/main/java/im/vector/app/features/mdm/DefaultMdmService.kt b/vector/src/main/java/im/vector/app/features/mdm/DefaultMdmService.kt index 0523a1dd41..6633f3ce06 100644 --- a/vector/src/main/java/im/vector/app/features/mdm/DefaultMdmService.kt +++ b/vector/src/main/java/im/vector/app/features/mdm/DefaultMdmService.kt @@ -25,7 +25,9 @@ import androidx.core.content.getSystemService import dagger.hilt.android.qualifiers.ApplicationContext import timber.log.Timber import javax.inject.Inject +import javax.inject.Singleton +@Singleton class DefaultMdmService @Inject constructor( @ApplicationContext applicationContext: Context ) : MdmService {