diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddAckWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddAckWorker.kt
index f41e57684f..1bfbd3e4e2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddAckWorker.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddAckWorker.kt
@@ -1,10 +1,12 @@
package info.nightscout.androidaps.plugins.general.nsclient
import android.content.Context
+import android.os.SystemClock
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
+import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.DeviceStatus
import info.nightscout.androidaps.database.transactions.*
@@ -17,6 +19,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.acks.NSAddAck
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog
import info.nightscout.androidaps.receivers.DataWorker
import info.nightscout.androidaps.utils.rx.AapsSchedulers
+import info.nightscout.androidaps.utils.sharedPreferences.SP
import javax.inject.Inject
class NSClientAddAckWorker(
@@ -30,6 +33,7 @@ class NSClientAddAckWorker(
@Inject lateinit var rxBus: RxBus
@Inject lateinit var dataSyncSelector: DataSyncSelector
@Inject lateinit var aapsSchedulers: AapsSchedulers
+ @Inject lateinit var sp: SP
override fun doWork(): Result {
var ret = Result.success()
@@ -37,6 +41,8 @@ class NSClientAddAckWorker(
val ack = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as NSAddAck?
?: return Result.failure(workDataOf("Error" to "missing input data"))
+ if (sp.getBoolean(R.string.key_ns_sync_slow, false)) SystemClock.sleep(1000)
+
when (ack.originalObject) {
is PairTemporaryTarget -> {
val pair = ack.originalObject
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2fe7985621..48799e24d6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -54,6 +54,7 @@
ns_offline_event_last_synced_id
ns_profile_store_last_synced_timestamp
local_profile_last_change
+ ns_sync_slow
Treatments safety
Max allowed bolus [U]
@@ -1128,5 +1129,6 @@
Invalid profile %1$s not accepted from NS
View
Errors
+ Slow down uploads
diff --git a/app/src/main/res/xml/pref_nsclientinternal.xml b/app/src/main/res/xml/pref_nsclientinternal.xml
index c9dbe2d1e5..e2e14efa99 100644
--- a/app/src/main/res/xml/pref_nsclientinternal.xml
+++ b/app/src/main/res/xml/pref_nsclientinternal.xml
@@ -156,7 +156,7 @@
+
+