NSCLIENT mode: do not create local profile switch

This commit is contained in:
Milos Kozak 2021-09-30 19:08:38 +02:00
parent 45b58719a6
commit 9f1a87110d

View file

@ -64,7 +64,8 @@ class CommandQueue @Inject constructor(
private val buildHelper: BuildHelper, private val buildHelper: BuildHelper,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val repository: AppRepository, private val repository: AppRepository,
private val fabricPrivacy: FabricPrivacy private val fabricPrivacy: FabricPrivacy,
private val config: Config
) : CommandQueueProvider { ) : CommandQueueProvider {
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -79,6 +80,10 @@ class CommandQueue @Inject constructor(
.toObservable(EventProfileSwitchChanged::class.java) .toObservable(EventProfileSwitchChanged::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ .subscribe({
if (config.NSCLIENT) { // Effective profileswitch should be synced over NS
rxBus.send(EventNewBasalProfile())
return@subscribe
}
aapsLogger.debug(LTag.PROFILE, "onProfileSwitch") aapsLogger.debug(LTag.PROFILE, "onProfileSwitch")
profileFunction.getRequestedProfile()?.let { profileFunction.getRequestedProfile()?.let {
val nonCustomized = ProfileSealed.PS(it).convertToNonCustomizedProfile(dateUtil) val nonCustomized = ProfileSealed.PS(it).convertToNonCustomizedProfile(dateUtil)
@ -173,7 +178,7 @@ class CommandQueue @Inject constructor(
// After new command added to the queue // After new command added to the queue
// start thread again if not already running // start thread again if not already running
@Synchronized @Synchronized
open fun notifyAboutNewCommand() { fun notifyAboutNewCommand() {
waitForFinishedThread() waitForFinishedThread()
if (thread == null || thread!!.state == Thread.State.TERMINATED) { if (thread == null || thread!!.state == Thread.State.TERMINATED) {
thread = QueueThread(this, context, aapsLogger, rxBus, activePlugin, resourceHelper, sp) thread = QueueThread(this, context, aapsLogger, rxBus, activePlugin, resourceHelper, sp)
@ -195,7 +200,9 @@ class CommandQueue @Inject constructor(
override fun independentConnect(reason: String, callback: Callback?) { override fun independentConnect(reason: String, callback: Callback?) {
aapsLogger.debug(LTag.PUMPQUEUE, "Starting new queue") aapsLogger.debug(LTag.PUMPQUEUE, "Starting new queue")
val tempCommandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, buildHelper, dateUtil, repository, fabricPrivacy) val tempCommandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper,
constraintChecker, profileFunction, activePlugin, context, sp,
buildHelper, dateUtil, repository, fabricPrivacy, config)
tempCommandQueue.readStatus(reason, callback) tempCommandQueue.readStatus(reason, callback)
tempCommandQueue.disposable.clear() tempCommandQueue.disposable.clear()
} }