From 7acaf8a7e67fab5df8139f5be52c55080f3eae49 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 23:42:40 +0100 Subject: [PATCH] accept NSProfile as bundle --- .../androidaps/plugins/profile/ns/NSProfilePlugin.kt | 7 ++++++- .../info/nightscout/androidaps/receivers/DataReceiver.kt | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt index a47e53afe1..5109f6811c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt @@ -17,6 +17,8 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI +import info.nightscout.androidaps.receivers.BundleStore +import info.nightscout.androidaps.receivers.DataReceiver import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONObject @@ -87,13 +89,16 @@ class NSProfilePlugin @Inject constructor( @Inject lateinit var nsProfilePlugin: NSProfilePlugin @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var bundleStore: BundleStore init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) } override fun doWork(): Result { - inputData.getString("profile")?.let { profileString -> + val bundle = bundleStore.pickup(inputData.getLong(DataReceiver.STORE_KEY, -1)) + ?: return Result.failure() + bundle.getString("profile")?.let { profileString -> nsProfilePlugin.profile = ProfileStore(injector, JSONObject(profileString)) nsProfilePlugin.storeNSProfile() if (nsProfilePlugin.isEnabled()) { diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt index e764f35b2d..3d4d04dbf7 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt @@ -61,9 +61,7 @@ open class DataReceiver : DaggerBroadcastReceiver() { }.build()).build() Intents.ACTION_NEW_PROFILE -> OneTimeWorkRequest.Builder(NSProfilePlugin.NSProfileWorker::class.java) - .setInputData(Data.Builder().also { - it.copyString("profile", bundle, null) - }.build()).build() + .setInputData(bundleInputData(bundle, intent)).build() Intents.ACTION_NEW_SGV -> OneTimeWorkRequest.Builder(NSClientSourcePlugin.NSClientSourceWorker::class.java) .setInputData(Data.Builder().also {