Do not check for BT perm in NSC mode

This commit is contained in:
Milos Kozak 2022-01-07 21:44:48 +01:00
parent fd814baa60
commit b2bd7a7d21
3 changed files with 6 additions and 4 deletions

View file

@ -179,7 +179,7 @@ class CommandQueueImplementation @Inject constructor(
@Synchronized fun notifyAboutNewCommand() {
waitForFinishedThread()
if (thread == null || thread!!.state == Thread.State.TERMINATED) {
thread = QueueThread(this, context, aapsLogger, rxBus, activePlugin, rh, sp, androidPermission)
thread = QueueThread(this, context, aapsLogger, rxBus, activePlugin, rh, sp, androidPermission, config)
thread!!.start()
aapsLogger.debug(LTag.PUMPQUEUE, "Starting new thread")
} else {

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.androidaps.queue.events.EventQueueChanged
@ -28,7 +29,8 @@ class QueueThread internal constructor(
private val activePlugin: ActivePlugin,
private val rh: ResourceHelper,
private val sp: SP,
private val androidPermission: AndroidPermission
private val androidPermission: AndroidPermission,
private val config: Config
) : Thread() {
private var connectLogged = false
@ -50,7 +52,7 @@ class QueueThread internal constructor(
val secondsElapsed = (System.currentTimeMillis() - connectionStartTime) / 1000
val pump = activePlugin.activePump
// Manifest.permission.BLUETOOTH_CONNECT
if (Build.VERSION.SDK_INT >= /*Build.VERSION_CODES.S*/31)
if (config.PUMPDRIVERS && Build.VERSION.SDK_INT >= /*Build.VERSION_CODES.S*/31)
if (androidPermission.permissionNotGranted(context, "android.permission.BLUETOOTH_CONNECT")) {
aapsLogger.debug(LTag.PUMPQUEUE, "no permission")
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTING))

View file

@ -81,7 +81,7 @@ class QueueThreadTest : TestBaseWithProfile() {
.thenReturn(percentageConstraint)
Mockito.`when`(rh.gs(ArgumentMatchers.eq(R.string.temp_basal_absolute), anyObject(), anyObject())).thenReturn("TEMP BASAL %1\$.2f U/h %2\$d min")
sut = QueueThread(commandQueue, context, aapsLogger, rxBus, activePlugin, rh, sp, androidPermission)
sut = QueueThread(commandQueue, context, aapsLogger, rxBus, activePlugin, rh, sp, androidPermission, config)
}
@Test