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()
}
public override fun onDestroy() {
override fun onDestroy() {
super.onDestroy()
disposable.clear()
}

View file

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

View file

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

View file

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

View file

@ -148,15 +148,17 @@ class LocalProfilePlugin @Inject constructor(
fun storeSettings(activity: FragmentActivity? = null) {
for (i in 0 until numOfProfiles) {
profiles[i].run {
val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_"
sp.putString(localProfileNumbered + "name", name!!)
sp.putBoolean(localProfileNumbered + "mgdl", mgdl)
sp.putDouble(localProfileNumbered + "dia", dia)
sp.putString(localProfileNumbered + "ic", ic.toString())
sp.putString(localProfileNumbered + "isf", isf.toString())
sp.putString(localProfileNumbered + "basal", basal.toString())
sp.putString(localProfileNumbered + "targetlow", targetLow.toString())
sp.putString(localProfileNumbered + "targethigh", targetHigh.toString())
name?.let { name ->
val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_"
sp.putString(localProfileNumbered + "name", name)
sp.putBoolean(localProfileNumbered + "mgdl", mgdl)
sp.putDouble(localProfileNumbered + "dia", dia)
sp.putString(localProfileNumbered + "ic", ic.toString())
sp.putString(localProfileNumbered + "isf", isf.toString())
sp.putString(localProfileNumbered + "basal", basal.toString())
sp.putString(localProfileNumbered + "targetlow", targetLow.toString())
sp.putString(localProfileNumbered + "targethigh", targetHigh.toString())
}
}
}
sp.putInt(Constants.LOCAL_PROFILE + "_profiles", numOfProfiles)

View file

@ -177,8 +177,7 @@ class CommandQueue @Inject constructor(
// After new command added to the queue
// start thread again if not already running
@Synchronized
fun notifyAboutNewCommand() {
@Synchronized fun notifyAboutNewCommand() {
waitForFinishedThread()
if (thread == null || thread!!.state == Thread.State.TERMINATED) {
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()
disposable.clear()
}

View file

@ -55,7 +55,7 @@ buildscript {
}
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"
}

View file

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

View file

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

View file

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

View file

@ -17,8 +17,7 @@ import javax.inject.Singleton
import kotlin.math.roundToInt
@OpenForTesting
@Singleton
open class AppRepository @Inject internal constructor(
@Singleton class AppRepository @Inject internal constructor(
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>>.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>>.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>>.sort() = this.map { it.sortedBy { c -> c.timestamp } }

View file

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

View file

@ -22,7 +22,7 @@ class AppConfirmSettingPacket(
}
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.putInt(otp) // 응답시 전달받은 opt (random 6digit numbner)

View file

@ -20,7 +20,7 @@ class BasalLimitInquirePacket(
}
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)
}

View file

@ -21,7 +21,7 @@ class BasalPauseSettingPacket(
}
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)
return suffixEncode(buffer)
}

View file

@ -20,7 +20,7 @@ class DisplayTimeInquirePacket(
}
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)
}

View file

@ -20,7 +20,7 @@ class InjectionBasalSettingPacket(
}
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())
return suffixEncode(buffer)
}

View file

@ -21,7 +21,7 @@ class InjectionMealSettingPacket(
}
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.putLong(bcDttm)
return suffixEncode(buffer)

View file

@ -20,7 +20,7 @@ class InjectionSnackSettingPacket(
}
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())
return suffixEncode(buffer)
}

View file

@ -20,7 +20,7 @@ class LanguageInquirePacket(
}
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)
}

View file

@ -20,7 +20,7 @@ class SneckLimitInquirePacket(
}
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)
}

View file

@ -20,7 +20,7 @@ class SoundInquirePacket(
}
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)
}

View file

@ -20,7 +20,7 @@ class TimeInquirePacket(
}
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)
}

View file

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

View file

@ -25,7 +25,7 @@ class TimeSettingPacket(
}
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)
buffer.put((date.year - 2000 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 medtronicPumpHistoryDecoder: MedtronicPumpHistoryDecoder
private val MAX_COMMAND_TRIES = 3
private val DEFAULT_TIMEOUT = 2000
private val RILEYLINK_TIMEOUT: Long = 15 * 60 * 1000L // 15 min
companion object {
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
private set
@ -92,7 +95,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
*
* @return
*/
fun isDeviceReachable(canPreventTuneUp: Boolean): Boolean {
private fun isDeviceReachable(canPreventTuneUp: Boolean): Boolean {
val state = medtronicPumpStatus.pumpDeviceState
if (state !== PumpDeviceState.PumpUnreachable) medtronicPumpStatus.pumpDeviceState = PumpDeviceState.WakingUp
for (retry in 0..4) {
@ -189,6 +192,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
}
}
@Suppress("SameParameterValue")
@Throws(RileyLinkCommunicationException::class)
private fun runCommandWithFrames(commandType: MedtronicCommandType, frames: List<List<Byte>>): PumpMessage? {
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) {
// examine current response for problems.
val frameData = currentResponse.frameData
if (frameData.size > 0 && currentResponse.frameNumber == expectedFrameNum) {
if (frameData.isNotEmpty() && currentResponse.frameNumber == expectedFrameNum) {
// success! got a frame.
if (frameData.size != 64) {
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
}
} else {
if (frameData.size == 0) {
if (frameData.isEmpty()) {
aapsLogger.error(LTag.PUMPCOMM, "null frame data, retrying")
} else if (currentResponse.frameNumber != expectedFrameNum) {
aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Expected frame number %d, received %d (retrying)", expectedFrameNum,
currentResponse.frameNumber))
} else if (frameData.size == 0) {
} else if (frameData.isEmpty()) {
aapsLogger.warn(LTag.PUMPCOMM, "Frame has zero length, retrying")
}
failures++
@ -381,8 +385,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
medtronicPumpStatus.pumpDeviceState = PumpDeviceState.Active
// create message
val msg: PumpMessage
msg = bodyData?.let { makePumpMessage(commandType, it) } ?: makePumpMessage(commandType)
val msg: PumpMessage = bodyData?.let { makePumpMessage(commandType, it) } ?: makePumpMessage(commandType)
// send and wait for response
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.
@Throws(RileyLinkCommunicationException::class)
protected /*override*/ fun sendAndListen(msg: PumpMessage, timeout_ms: Int): PumpMessage {
@Throws(RileyLinkCommunicationException::class) private /*override*/ fun sendAndListen(msg: PumpMessage, timeout_ms: Int): PumpMessage {
return super.sendAndListen(msg, timeout_ms)!!
}
@ -451,7 +453,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
return responseData
}
val contents = response.rawContent
return if (contents.size > 0) {
return if (contents.isNotEmpty()) {
if (contents.size >= expectedLength) {
aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Content: %s", method, ByteUtil.shortHexString(contents)))
null
@ -493,8 +495,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
for (retries in 0..MAX_COMMAND_TRIES) {
try {
// create message
var msg: PumpMessage
msg = makePumpMessage(commandType)
val msg: PumpMessage = makePumpMessage(commandType)
// send and wait for response
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))
var basalProfile: BasalProfile? = medtronicConverter.decodeBasalProfile(medtronicPumpPlugin.pumpDescription.pumpType, data)
val basalProfile: BasalProfile? = medtronicConverter.decodeBasalProfile(medtronicPumpPlugin.pumpDescription.pumpType, data)
// checkResponseRawContent(data, commandType) {
// basalProfile = medtronicConverter.decodeBasalProfile(medtronicPumpPlugin.pumpDescription.pumpType, data)
// }

View file

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

View file

@ -23,7 +23,6 @@ internal class LTKExchanger(
private val keyExchange = KeyExchange(aapsLogger, X25519KeyGenerator(), RandomByteGenerator())
private var seq: Byte = 1
@kotlin.ExperimentalStdlibApi
@Throws(PairingException::class)
fun negotiateLTK(): PairResult {
val sp1sp2 = PairMessage(
@ -114,7 +113,6 @@ internal class LTKExchanger(
keyExchange.validatePodConf(payload)
}
@kotlin.ExperimentalStdlibApi
private fun sp2(): ByteArray {
// This is GetPodStatus command, with page 0 parameter.
// 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]
aapsLogger.debug(LTag.PUMPBTCOMM, "P0 payload from pod: ${payload.toHex()}")
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() {
var firstByte = (type.index.toInt() shl 4).toByte()
if (enabled) {
firstByte = firstByte or (1 shl 3)
firstByte = firstByte or (1 shl 3).toByte()
}
if (trigger is AlertTrigger.ReservoirVolumeTrigger) {
firstByte = firstByte or (1 shl 2)
firstByte = firstByte or (1 shl 2).toByte()
}
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())
return ByteBuffer.allocate(6)

View file

@ -16,6 +16,6 @@ data class HistoryRecord(
) {
fun pumpId(): Long {
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_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>
<!-- Exceptions -->

View file

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

View file

@ -69,7 +69,6 @@ abstract class PumpPluginAbstract protected constructor(
protected var displayConnectionMessages = false
var pumpType: PumpType = PumpType.GENERIC_AAPS
get() = field
set(value) {
field = 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);
}
private static Answer bundleToDataMapMock = invocation -> {
private static final Answer bundleToDataMapMock = invocation -> {
DataMap map = new DataMap();
Bundle bundle = invocation.getArgument(0);
for(String key: bundle.keySet()) {