SMS: fix sending SMS for Android 9

This commit is contained in:
Milos Kozak 2022-05-19 23:17:18 +02:00
parent 8653c0f0d6
commit 6f358bc0c8

View file

@ -1,25 +1,31 @@
package info.nightscout.androidaps.di package info.nightscout.androidaps.di
import android.content.Context import android.content.Context
import android.os.Build
import android.telephony.SmsManager import android.telephony.SmsManager
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
import javax.inject.Singleton import javax.inject.Singleton
@Module(includes = [ @Module(
includes = [
CoreReceiversModule::class, CoreReceiversModule::class,
CoreFragmentsModule::class, CoreFragmentsModule::class,
CoreDataClassesModule::class CoreDataClassesModule::class
]) ]
)
open class CoreModule { open class CoreModule {
@Provides @Provides
@Singleton @Singleton
fun provideResources(context: Context, fabricPrivacy: FabricPrivacy): ResourceHelper = ResourceHelperImplementation(context, fabricPrivacy) fun provideResources(context: Context, fabricPrivacy: FabricPrivacy): ResourceHelper = ResourceHelperImplementation(context, fabricPrivacy)
@Suppress("DEPRECATION")
@Provides @Provides
fun smsManager(context: Context) : SmsManager? = context.getSystemService(SmsManager::class.java) fun smsManager(context: Context): SmsManager? =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) context.getSystemService(SmsManager::class.java)
else SmsManager.getDefault()
} }