This commit is contained in:
Milos Kozak 2021-10-01 16:55:40 +02:00
commit 8050fedaf6
35 changed files with 66 additions and 69 deletions

View file

@ -165,7 +165,7 @@ class MainActivity : NoSplashAppCompatActivity() {
actionBarDrawerToggle.syncState() actionBarDrawerToggle.syncState()
} }
public override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
disposable.clear() disposable.clear()
} }

View file

@ -171,7 +171,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
} }
} }
public override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
disposable.clear() disposable.clear()
iobCobCalculator.stopCalculation("onPause") iobCobCalculator.stopCalculation("onPause")
@ -183,7 +183,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
super.onDestroy() super.onDestroy()
} }
public override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
disposable.add(rxBus disposable.add(rxBus
.toObservable(EventAutosensCalculationFinished::class.java) .toObservable(EventAutosensCalculationFinished::class.java)

View file

@ -19,7 +19,7 @@ class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
private var plugin: PluginBase? = null private var plugin: PluginBase? = null
public override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_single_fragment) setContentView(R.layout.activity_single_fragment)
plugin = pluginStore.plugins[intent.getIntExtra("plugin", -1)] plugin = pluginStore.plugins[intent.getIntExtra("plugin", -1)]
@ -52,7 +52,7 @@ class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
return super.onCreateOptionsMenu(menu) return super.onCreateOptionsMenu(menu)
} }
public override fun attachBaseContext(newBase: Context) { override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleHelper.wrap(newBase)) super.attachBaseContext(LocaleHelper.wrap(newBase))
} }
} }

View file

@ -50,7 +50,7 @@ class StorageConstraintPlugin @Inject constructor(
return value return value
} }
open fun availableInternalMemorySize(): Long { fun availableInternalMemorySize(): Long {
val path = Environment.getDataDirectory() val path = Environment.getDataDirectory()
val stat = StatFs(path.path) val stat = StatFs(path.path)
val blockSize = stat.blockSizeLong val blockSize = stat.blockSizeLong

View file

@ -148,8 +148,9 @@ class LocalProfilePlugin @Inject constructor(
fun storeSettings(activity: FragmentActivity? = null) { fun storeSettings(activity: FragmentActivity? = null) {
for (i in 0 until numOfProfiles) { for (i in 0 until numOfProfiles) {
profiles[i].run { profiles[i].run {
name?.let { name ->
val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_" val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_"
sp.putString(localProfileNumbered + "name", name!!) sp.putString(localProfileNumbered + "name", name)
sp.putBoolean(localProfileNumbered + "mgdl", mgdl) sp.putBoolean(localProfileNumbered + "mgdl", mgdl)
sp.putDouble(localProfileNumbered + "dia", dia) sp.putDouble(localProfileNumbered + "dia", dia)
sp.putString(localProfileNumbered + "ic", ic.toString()) sp.putString(localProfileNumbered + "ic", ic.toString())
@ -159,6 +160,7 @@ class LocalProfilePlugin @Inject constructor(
sp.putString(localProfileNumbered + "targethigh", targetHigh.toString()) sp.putString(localProfileNumbered + "targethigh", targetHigh.toString())
} }
} }
}
sp.putInt(Constants.LOCAL_PROFILE + "_profiles", numOfProfiles) sp.putInt(Constants.LOCAL_PROFILE + "_profiles", numOfProfiles)
sp.putLong(R.string.key_local_profile_last_change, dateUtil.now()) sp.putLong(R.string.key_local_profile_last_change, dateUtil.now())

View file

@ -177,8 +177,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 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)

View file

@ -70,7 +70,7 @@ class SetupWizardActivity : NoSplashAppCompatActivity() {
} }
} }
public override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
disposable.clear() disposable.clear()
} }

View file

@ -55,7 +55,7 @@ buildscript {
} }
plugins { plugins {
id "io.gitlab.arturbosch.detekt" version "1.16.0-RC2" id "io.gitlab.arturbosch.detekt" version "1.18.1"
id "org.jlleitschuh.gradle.ktlint" version "10.2.0" id "org.jlleitschuh.gradle.ktlint" version "10.2.0"
} }

View file

@ -5,7 +5,7 @@ import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.locale.LocaleHelper
open class DialogAppCompatActivity : DaggerAppCompatActivity() { open class DialogAppCompatActivity : DaggerAppCompatActivity() {
public override fun attachBaseContext(newBase: Context) { override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleHelper.wrap(newBase)) super.attachBaseContext(LocaleHelper.wrap(newBase))
} }
} }

View file

@ -7,12 +7,12 @@ import info.nightscout.androidaps.utils.locale.LocaleHelper
open class NoSplashAppCompatActivity : DaggerAppCompatActivityWithResult() { open class NoSplashAppCompatActivity : DaggerAppCompatActivityWithResult() {
public override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setTheme(R.style.AppTheme_NoActionBar) setTheme(R.style.AppTheme_NoActionBar)
} }
public override fun attachBaseContext(newBase: Context) { override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleHelper.wrap(newBase)) super.attachBaseContext(LocaleHelper.wrap(newBase))
} }
} }

View file

@ -127,7 +127,7 @@ class PrefImportListActivity : DaggerAppCompatActivity() {
return false return false
} }
public override fun attachBaseContext(newBase: Context) { override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleHelper.wrap(newBase)) super.attachBaseContext(LocaleHelper.wrap(newBase))
} }
} }

View file

@ -17,8 +17,7 @@ import javax.inject.Singleton
import kotlin.math.roundToInt import kotlin.math.roundToInt
@OpenForTesting @OpenForTesting
@Singleton @Singleton class AppRepository @Inject internal constructor(
open class AppRepository @Inject internal constructor(
internal val database: AppDatabase internal val database: AppDatabase
) { ) {
@ -489,7 +488,7 @@ open class AppRepository @Inject internal constructor(
private fun Single<List<Carbs>>.expand() = this.map { it.map(::expandCarbs).flatten() } private fun Single<List<Carbs>>.expand() = this.map { it.map(::expandCarbs).flatten() }
private fun Single<List<Carbs>>.filterOutExtended() = this.map { it.filter { c -> c.duration == 0L } } private fun Single<List<Carbs>>.filterOutExtended() = this.map { it.filter { c -> c.duration == 0L } }
private fun Single<List<Carbs>>.fromTo(from: Long, to: Long) = this.map { it.filter { c -> c.timestamp in from..to } } private fun Single<List<Carbs>>.fromTo(from: Long, to: Long) = this.map { it.filter { c -> c.timestamp in from..to } }
private fun Single<List<Carbs>>.until(to: Long) = this.map { it.filter { c -> c.timestamp <= to } } private infix fun Single<List<Carbs>>.until(to: Long) = this.map { it.filter { c -> c.timestamp <= to } }
private fun Single<List<Carbs>>.from(start: Long) = this.map { it.filter { c -> c.timestamp >= start } } private fun Single<List<Carbs>>.from(start: Long) = this.map { it.filter { c -> c.timestamp >= start } }
private fun Single<List<Carbs>>.sort() = this.map { it.sortedBy { c -> c.timestamp } } private fun Single<List<Carbs>>.sort() = this.map { it.sortedBy { c -> c.timestamp } }

View file

@ -21,7 +21,7 @@ data class UserEntry(
var action: Action, var action: Action,
var source: Sources, var source: Sources,
var note: String, var note: String,
var values: List<ValueWithUnit?> var values: List<@JvmSuppressWildcards ValueWithUnit?>
) : DBEntry, DBEntryWithTime { ) : DBEntry, DBEntryWithTime {
enum class Action (val colorGroup: ColorGroup) { enum class Action (val colorGroup: ColorGroup) {
BOLUS (ColorGroup.InsulinTreatment), BOLUS (ColorGroup.InsulinTreatment),

View file

@ -22,7 +22,7 @@ class AppConfirmSettingPacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
buffer.put(reqMsgType) // 명령코드 buffer.put(reqMsgType) // 명령코드
buffer.putInt(otp) // 응답시 전달받은 opt (random 6digit numbner) buffer.putInt(otp) // 응답시 전달받은 opt (random 6digit numbner)

View file

@ -20,7 +20,7 @@ class BasalLimitInquirePacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -21,7 +21,7 @@ class BasalPauseSettingPacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
buffer.put(status.toByte()) // (1:pause, 2: cancel pause) buffer.put(status.toByte()) // (1:pause, 2: cancel pause)
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -20,7 +20,7 @@ class DisplayTimeInquirePacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -20,7 +20,7 @@ class InjectionBasalSettingPacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
buffer.put(pattern.toByte()) buffer.put(pattern.toByte())
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -21,7 +21,7 @@ class InjectionMealSettingPacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
buffer.putShort(amount.toShort()) buffer.putShort(amount.toShort())
buffer.putLong(bcDttm) buffer.putLong(bcDttm)
return suffixEncode(buffer) return suffixEncode(buffer)

View file

@ -20,7 +20,7 @@ class InjectionSnackSettingPacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
buffer.putShort(amount.toShort()) buffer.putShort(amount.toShort())
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -20,7 +20,7 @@ class LanguageInquirePacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -20,7 +20,7 @@ class SneckLimitInquirePacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -20,7 +20,7 @@ class SoundInquirePacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -20,7 +20,7 @@ class TimeInquirePacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer) return suffixEncode(buffer)
} }

View file

@ -31,7 +31,7 @@ class TimeInquireResponsePacket(
val result2 = getByteToInt(bufferData) val result2 = getByteToInt(bufferData)
if(!isSuccInquireResponseResult(result2)) { if(!isSuccInquireResponseResult(result2)) {
failed = true failed = true
return; return
} }
} }

View file

@ -25,7 +25,7 @@ class TimeSettingPacket(
} }
override fun encode(msgSeq:Int): ByteArray { override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END); val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
val date = DateTime(time).withZone(DateTimeZone.UTC) val date = DateTime(time).withZone(DateTimeZone.UTC)
buffer.put((date.year - 2000 and 0xff).toByte()) buffer.put((date.year - 2000 and 0xff).toByte())
buffer.put((date.monthOfYear and 0xff).toByte()) buffer.put((date.monthOfYear and 0xff).toByte())

View file

@ -54,9 +54,12 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
@Inject lateinit var medtronicUtil: MedtronicUtil @Inject lateinit var medtronicUtil: MedtronicUtil
@Inject lateinit var medtronicPumpHistoryDecoder: MedtronicPumpHistoryDecoder @Inject lateinit var medtronicPumpHistoryDecoder: MedtronicPumpHistoryDecoder
private val MAX_COMMAND_TRIES = 3 companion object {
private val DEFAULT_TIMEOUT = 2000
private val RILEYLINK_TIMEOUT: Long = 15 * 60 * 1000L // 15 min private const val MAX_COMMAND_TRIES = 3
private const val DEFAULT_TIMEOUT = 2000
private const val RILEYLINK_TIMEOUT: Long = 15 * 60 * 1000L // 15 min
}
var errorResponse: String? = null var errorResponse: String? = null
private set private set
@ -92,7 +95,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
* *
* @return * @return
*/ */
fun isDeviceReachable(canPreventTuneUp: Boolean): Boolean { private fun isDeviceReachable(canPreventTuneUp: Boolean): Boolean {
val state = medtronicPumpStatus.pumpDeviceState val state = medtronicPumpStatus.pumpDeviceState
if (state !== PumpDeviceState.PumpUnreachable) medtronicPumpStatus.pumpDeviceState = PumpDeviceState.WakingUp if (state !== PumpDeviceState.PumpUnreachable) medtronicPumpStatus.pumpDeviceState = PumpDeviceState.WakingUp
for (retry in 0..4) { for (retry in 0..4) {
@ -189,6 +192,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
} }
} }
@Suppress("SameParameterValue")
@Throws(RileyLinkCommunicationException::class) @Throws(RileyLinkCommunicationException::class)
private fun runCommandWithFrames(commandType: MedtronicCommandType, frames: List<List<Byte>>): PumpMessage? { private fun runCommandWithFrames(commandType: MedtronicCommandType, frames: List<List<Byte>>): PumpMessage? {
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: " + commandType.name) aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: " + commandType.name)
@ -266,7 +270,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
while (!done) { while (!done) {
// examine current response for problems. // examine current response for problems.
val frameData = currentResponse.frameData val frameData = currentResponse.frameData
if (frameData.size > 0 && currentResponse.frameNumber == expectedFrameNum) { if (frameData.isNotEmpty() && currentResponse.frameNumber == expectedFrameNum) {
// success! got a frame. // success! got a frame.
if (frameData.size != 64) { if (frameData.size != 64) {
aapsLogger.warn(LTag.PUMPCOMM, "Expected frame of length 64, got frame of length " + frameData.size) aapsLogger.warn(LTag.PUMPCOMM, "Expected frame of length 64, got frame of length " + frameData.size)
@ -286,12 +290,12 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
done = true // successful completion done = true // successful completion
} }
} else { } else {
if (frameData.size == 0) { if (frameData.isEmpty()) {
aapsLogger.error(LTag.PUMPCOMM, "null frame data, retrying") aapsLogger.error(LTag.PUMPCOMM, "null frame data, retrying")
} else if (currentResponse.frameNumber != expectedFrameNum) { } else if (currentResponse.frameNumber != expectedFrameNum) {
aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Expected frame number %d, received %d (retrying)", expectedFrameNum, aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Expected frame number %d, received %d (retrying)", expectedFrameNum,
currentResponse.frameNumber)) currentResponse.frameNumber))
} else if (frameData.size == 0) { } else if (frameData.isEmpty()) {
aapsLogger.warn(LTag.PUMPCOMM, "Frame has zero length, retrying") aapsLogger.warn(LTag.PUMPCOMM, "Frame has zero length, retrying")
} }
failures++ failures++
@ -381,8 +385,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
medtronicPumpStatus.pumpDeviceState = PumpDeviceState.Active medtronicPumpStatus.pumpDeviceState = PumpDeviceState.Active
// create message // create message
val msg: PumpMessage val msg: PumpMessage = bodyData?.let { makePumpMessage(commandType, it) } ?: makePumpMessage(commandType)
msg = bodyData?.let { makePumpMessage(commandType, it) } ?: makePumpMessage(commandType)
// send and wait for response // send and wait for response
val response = sendAndListen(msg, timeoutMs) val response = sendAndListen(msg, timeoutMs)
@ -396,8 +399,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
} }
// All pump communications go through this function. // All pump communications go through this function.
@Throws(RileyLinkCommunicationException::class) @Throws(RileyLinkCommunicationException::class) private /*override*/ fun sendAndListen(msg: PumpMessage, timeout_ms: Int): PumpMessage {
protected /*override*/ fun sendAndListen(msg: PumpMessage, timeout_ms: Int): PumpMessage {
return super.sendAndListen(msg, timeout_ms)!! return super.sendAndListen(msg, timeout_ms)!!
} }
@ -451,7 +453,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
return responseData return responseData
} }
val contents = response.rawContent val contents = response.rawContent
return if (contents.size > 0) { return if (contents.isNotEmpty()) {
if (contents.size >= expectedLength) { if (contents.size >= expectedLength) {
aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Content: %s", method, ByteUtil.shortHexString(contents))) aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Content: %s", method, ByteUtil.shortHexString(contents)))
null null
@ -493,8 +495,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
for (retries in 0..MAX_COMMAND_TRIES) { for (retries in 0..MAX_COMMAND_TRIES) {
try { try {
// create message // create message
var msg: PumpMessage val msg: PumpMessage = makePumpMessage(commandType)
msg = makePumpMessage(commandType)
// send and wait for response // send and wait for response
var response = sendAndListen(msg, DEFAULT_TIMEOUT + DEFAULT_TIMEOUT * retries) var response = sendAndListen(msg, DEFAULT_TIMEOUT + DEFAULT_TIMEOUT * retries)
@ -527,7 +528,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
aapsLogger.debug(LTag.PUMPCOMM, "End Response: {}", ByteUtil.getHex(data)) aapsLogger.debug(LTag.PUMPCOMM, "End Response: {}", ByteUtil.getHex(data))
var basalProfile: BasalProfile? = medtronicConverter.decodeBasalProfile(medtronicPumpPlugin.pumpDescription.pumpType, data) val basalProfile: BasalProfile? = medtronicConverter.decodeBasalProfile(medtronicPumpPlugin.pumpDescription.pumpType, data)
// checkResponseRawContent(data, commandType) { // checkResponseRawContent(data, commandType) {
// basalProfile = medtronicConverter.decodeBasalProfile(medtronicPumpPlugin.pumpDescription.pumpType, data) // basalProfile = medtronicConverter.decodeBasalProfile(medtronicPumpPlugin.pumpDescription.pumpType, data)
// } // }

View file

@ -98,7 +98,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
} }
override fun getStatus(): ConnectionState { override fun getStatus(): ConnectionState {
return connection?.let { it.connectionState() } return connection?.connectionState()
?: NotConnected ?: NotConnected
} }
// used for sync connections // used for sync connections
@ -154,7 +154,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
val ltk = assertPaired() val ltk = assertPaired()
var eapSqn = podState.increaseEapAkaSequenceNumber() val eapSqn = podState.increaseEapAkaSequenceNumber()
var newSqn = conn.establishSession(ltk, msgSeq, ids, eapSqn) var newSqn = conn.establishSession(ltk, msgSeq, ids, eapSqn)
@ -180,7 +180,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
?: throw FailedToConnectException("connection lost") ?: throw FailedToConnectException("connection lost")
} }
@kotlin.ExperimentalStdlibApi
override fun pairNewPod(): Observable<PodEvent> = Observable.create { emitter -> override fun pairNewPod(): Observable<PodEvent> = Observable.create { emitter ->
if (!busy.compareAndSet(false, true)) { if (!busy.compareAndSet(false, true)) {
throw BusyException() throw BusyException()

View file

@ -23,7 +23,6 @@ internal class LTKExchanger(
private val keyExchange = KeyExchange(aapsLogger, X25519KeyGenerator(), RandomByteGenerator()) private val keyExchange = KeyExchange(aapsLogger, X25519KeyGenerator(), RandomByteGenerator())
private var seq: Byte = 1 private var seq: Byte = 1
@kotlin.ExperimentalStdlibApi
@Throws(PairingException::class) @Throws(PairingException::class)
fun negotiateLTK(): PairResult { fun negotiateLTK(): PairResult {
val sp1sp2 = PairMessage( val sp1sp2 = PairMessage(
@ -114,7 +113,6 @@ internal class LTKExchanger(
keyExchange.validatePodConf(payload) keyExchange.validatePodConf(payload)
} }
@kotlin.ExperimentalStdlibApi
private fun sp2(): ByteArray { private fun sp2(): ByteArray {
// This is GetPodStatus command, with page 0 parameter. // This is GetPodStatus command, with page 0 parameter.
// We could replace that in the future with the serialized GetPodStatus() // We could replace that in the future with the serialized GetPodStatus()
@ -127,7 +125,7 @@ internal class LTKExchanger(
val payload = parseKeys(arrayOf(P0), msg.payload)[0] val payload = parseKeys(arrayOf(P0), msg.payload)[0]
aapsLogger.debug(LTag.PUMPBTCOMM, "P0 payload from pod: ${payload.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "P0 payload from pod: ${payload.toHex()}")
if (!payload.contentEquals(UNKNOWN_P0_PAYLOAD)) { if (!payload.contentEquals(UNKNOWN_P0_PAYLOAD)) {
aapsLogger.warn(LTag.PUMPBTCOMM, "Reveived invalid P0 payload: ${payload.toHex()}") aapsLogger.warn(LTag.PUMPBTCOMM, "Received invalid P0 payload: ${payload.toHex()}")
} }
} }

View file

@ -17,13 +17,13 @@ class AlertConfiguration(
get() { get() {
var firstByte = (type.index.toInt() shl 4).toByte() var firstByte = (type.index.toInt() shl 4).toByte()
if (enabled) { if (enabled) {
firstByte = firstByte or (1 shl 3) firstByte = firstByte or (1 shl 3).toByte()
} }
if (trigger is AlertTrigger.ReservoirVolumeTrigger) { if (trigger is AlertTrigger.ReservoirVolumeTrigger) {
firstByte = firstByte or (1 shl 2) firstByte = firstByte or (1 shl 2).toByte()
} }
if (autoOff) { if (autoOff) {
firstByte = firstByte or (1 shl 1) firstByte = firstByte or (1 shl 1).toByte()
} }
firstByte = firstByte or ((durationInMinutes.toInt() shr 8 and 0x01).toByte()) firstByte = firstByte or ((durationInMinutes.toInt() shr 8 and 0x01).toByte())
return ByteBuffer.allocate(6) return ByteBuffer.allocate(6)

View file

@ -16,6 +16,6 @@ data class HistoryRecord(
) { ) {
fun pumpId(): Long { fun pumpId(): Long {
val entropy = ULID.getEntropy(id) val entropy = ULID.getEntropy(id)
return ByteBuffer.wrap(entropy).getLong() return ByteBuffer.wrap(entropy).long
} }
} }

View file

@ -22,7 +22,7 @@
<string name="key_omnipod_common_preferences_category_confirmation_beeps" translatable="false">omnipod_common_preferences_category_confirmation</string> <string name="key_omnipod_common_preferences_category_confirmation_beeps" translatable="false">omnipod_common_preferences_category_confirmation</string>
<string name="key_common_preferences_category_other_settings" translatable="false">common_preferences_category_other</string> <string name="key_common_preferences_category_other_settings" translatable="false">common_preferences_category_other</string>
<string name="key_omnipod_common_notification_delivery_suspended_sound_enabled">AAPS.Omnipod.notification_delivery_suspended_sound_enabled</string> <string name="key_omnipod_common_notification_delivery_suspended_sound_enabled" translatable="false">AAPS.Omnipod.notification_delivery_suspended_sound_enabled</string>
<string name="omnipod_common_preferences_notification_delivery_suspended_sound_enabled">Sound when delivery suspended notification enabled</string> <string name="omnipod_common_preferences_notification_delivery_suspended_sound_enabled">Sound when delivery suspended notification enabled</string>
<!-- Exceptions --> <!-- Exceptions -->

View file

@ -267,7 +267,7 @@ class OpenHumansUploader @Inject internal constructor(
put("currentTemp", JSONObject(it.currentTempJson)) put("currentTemp", JSONObject(it.currentTempJson))
put("iobData", JSONObject(it.iobDataJson)) put("iobData", JSONObject(it.iobDataJson))
put("profile", JSONObject(it.profileJson)) put("profile", JSONObject(it.profileJson))
put("autosensData", JSONObject(it.autosensDataJson)) put("autosensData", JSONObject(it.autosensDataJson ?: ""))
put("mealData", JSONObject(it.mealDataJson)) put("mealData", JSONObject(it.mealDataJson))
put("isMicroBolusAllowed", it.isMicroBolusAllowed) put("isMicroBolusAllowed", it.isMicroBolusAllowed)
put("result", JSONObject(it.resultJson)) put("result", JSONObject(it.resultJson))

View file

@ -69,7 +69,6 @@ abstract class PumpPluginAbstract protected constructor(
protected var displayConnectionMessages = false protected var displayConnectionMessages = false
var pumpType: PumpType = PumpType.GENERIC_AAPS var pumpType: PumpType = PumpType.GENERIC_AAPS
get() = field
set(value) { set(value) {
field = value field = value
pumpDescription.fillFor(value) pumpDescription.fillFor(value)

View file

@ -58,7 +58,7 @@ public class WearUtilMocker {
return REF_NOW - (Constants.DAY_IN_MS * d + Constants.HOUR_IN_MS * h + Constants.MINUTE_IN_MS * m + Constants.SECOND_IN_MS * s); return REF_NOW - (Constants.DAY_IN_MS * d + Constants.HOUR_IN_MS * h + Constants.MINUTE_IN_MS * m + Constants.SECOND_IN_MS * s);
} }
private static Answer bundleToDataMapMock = invocation -> { private static final Answer bundleToDataMapMock = invocation -> {
DataMap map = new DataMap(); DataMap map = new DataMap();
Bundle bundle = invocation.getArgument(0); Bundle bundle = invocation.getArgument(0);
for(String key: bundle.keySet()) { for(String key: bundle.keySet()) {