diff --git a/.gitignore b/.gitignore index 4b311a1123..d9e995910d 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ app/.classpath app/.settings/org.eclipse.buildship.core.prefs wear/.classpath wear/.settings/org.eclipse.buildship.core.prefs +app/nsclient/* +app/nsclient2/* +app/pumpcontrol/* diff --git a/.idea/dictionaries/project_dictionary.xml b/.idea/dictionaries/project_dictionary.xml index 79a1572acb..2e08ebd897 100644 --- a/.idea/dictionaries/project_dictionary.xml +++ b/.idea/dictionaries/project_dictionary.xml @@ -3,9 +3,11 @@ aaps abcdef + accu acked actionstring aidex + alarmack allowednumbers androidaps autosens @@ -26,11 +28,15 @@ carbsreq careportal cellnovo + chek + clearalarm crashlytics danar danars dataset datasets + dbadd + dbupdate devicestatus devicestatuses devslope @@ -39,12 +45,14 @@ diaconn enteredby enteredinsulin + eopatch eveningoutpost eversense extendedbolus fileprovider firebase glimp + glunovo gson hmac iage @@ -79,12 +87,14 @@ pred profileswitch pumpbtcomm + pumpcontrol quickwizard readstatus realduration refresheventsfromnightscout rileylink roboelectric + rozman sgvs shortgramm sitechange @@ -108,7 +118,8 @@ tirs totp tunedays - uart + uart + urgentalarm wizzardpage xdrip xstream diff --git a/app/build.gradle b/app/build.gradle index 65236b15cf..c24cc57c18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,7 +105,7 @@ android { defaultConfig { multiDexEnabled true versionCode 1500 - version "3.0.0.2-dev-o" + version "3.1.0.2-dev-a" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt index f3978aacf1..ea2d85eeaa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt @@ -68,6 +68,7 @@ class OpenAPSSMBDynamicISFPlugin @Inject constructor( .shortName(R.string.dynisf_shortname) .preferencesId(R.xml.pref_openapssmbdynamicisf) .setDefault(false) + .showInList(buildHelper.isEngineeringMode() && buildHelper.isDev()) } override fun specialEnableCondition(): Boolean = buildHelper.isEngineeringMode() && buildHelper.isDev() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt index b96dd4bdeb..5fb9dddc8d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt @@ -134,7 +134,8 @@ class AutotuneFragment : DaggerFragment() { profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector) } autotunePlugin.selectedProfile = profileName - resetParam(true) + resetParam() + binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble() } updateGui() } @@ -295,6 +296,7 @@ class AutotuneFragment : DaggerFragment() { .observeOn(aapsSchedulers.main) .subscribe({ updateGui() }, fabricPrivacy::logException) checkNewDay() + binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble() binding.selectWeekDays.visibility = binding.showWeekDaysCheckbox.isChecked.toVisibility() updateGui() } @@ -308,7 +310,6 @@ class AutotuneFragment : DaggerFragment() { @Synchronized private fun updateGui() { _binding ?: return - binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble() profileStore = activePlugin.activeProfileSource.profile ?: ProfileStore(injector, JSONObject(), dateUtil) profileName = if (binding.profileList.text.toString() == rh.gs(R.string.active)) "" else binding.profileList.text.toString() profileFunction.getProfile()?.let { currentProfile -> @@ -413,7 +414,7 @@ class AutotuneFragment : DaggerFragment() { try { if (autotunePlugin.calculationRunning) binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble() - if (binding.tuneDays.value != autotunePlugin.lastNbDays.toDouble()) { + if (binding.tuneDays.text != autotunePlugin.lastNbDays) { autotunePlugin.lastNbDays = binding.tuneDays.text resetParam(false) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt index b57a52d5f0..ae5db7d7df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt @@ -61,6 +61,7 @@ class AutotunePlugin @Inject constructor( .pluginName(R.string.autotune) .shortName(R.string.autotune_shortname) .preferencesId(R.xml.pref_autotune) + .showInList(buildHelper.isEngineeringMode() && buildHelper.isDev()) .description(R.string.autotune_description), aapsLogger, resourceHelper, injector ), Autotune { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt index 6e6e0ab684..25a75d17ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt @@ -5,6 +5,7 @@ import android.bluetooth.BluetoothManager import android.content.Context import android.content.Intent import android.content.pm.PackageManager +import android.os.Build import android.provider.Settings import androidx.annotation.StringRes import androidx.appcompat.app.AppCompatActivity @@ -113,7 +114,7 @@ class ImportExportPrefsImpl @Inject constructor( val n1 = Settings.System.getString(context.contentResolver, "bluetooth_name") val n2 = Settings.Secure.getString(context.contentResolver, "bluetooth_name") val n3 = try { - if (ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter?.name } else null } catch (e: Exception){ diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt index e388adb8bf..baa764d2bd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt @@ -134,8 +134,8 @@ class OverviewMenus @Inject constructor( val item = popup.menu.add(Menu.NONE, m.ordinal + 100 * (g + 1), Menu.NONE, rh.gs(m.nameId)) val title = item.title val s = SpannableString(" $title ") - s.setSpan(ForegroundColorSpan(rh.gac(context, m.attrTextId)), 0, s.length, 0) - s.setSpan(BackgroundColorSpan(rh.gac(context, m.attrId)), 0, s.length, 0) + s.setSpan(ForegroundColorSpan(rh.gac(m.attrTextId)), 0, s.length, 0) + s.setSpan(BackgroundColorSpan(rh.gac(m.attrId)), 0, s.length, 0) item.title = s item.isCheckable = true item.isChecked = settingsCopy[g][m.ordinal] diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt index e08da60f0f..f8ba452203 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt @@ -46,6 +46,7 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.subscribeBy import java.util.* +import java.util.concurrent.TimeUnit import javax.inject.Inject import javax.inject.Singleton @@ -81,6 +82,7 @@ class CommandQueueImplementation @Inject constructor( disposable += rxBus .toObservable(EventProfileSwitchChanged::class.java) .observeOn(aapsSchedulers.io) + .throttleLatest(3L, TimeUnit.SECONDS) .subscribe({ if (config.NSCLIENT) { // Effective profileswitch should be synced over NS, do not create EffectiveProfileSwitch here return@subscribe diff --git a/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt b/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt index 6262e552bc..2be9e2eef9 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt @@ -2,7 +2,6 @@ package info.nightscout.androidaps.utils import android.Manifest import android.annotation.SuppressLint -import android.annotation.TargetApi import android.bluetooth.BluetoothAdapter import android.content.ActivityNotFoundException import android.content.Context @@ -95,13 +94,14 @@ class AndroidPermission @Inject constructor( } } + @SuppressLint("MissingPermission") @Synchronized fun notifyForBtConnectPermission(activity: FragmentActivity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { // Manifest.permission.BLUETOOTH_CONNECT - if (permissionNotGranted(activity, "android.permission.BLUETOOTH_CONNECT") || permissionNotGranted(activity, "android.permission.BLUETOOTH_SCAN")) { + if (permissionNotGranted(activity, Manifest.permission.BLUETOOTH_CONNECT) || permissionNotGranted(activity, Manifest.permission.BLUETOOTH_SCAN)) { val notification = NotificationWithAction(injector, Notification.PERMISSION_BT, rh.gs(R.string.needconnectpermission), Notification.URGENT) - notification.action(R.string.request) { askForPermission(activity, arrayOf("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT")) } + notification.action(R.string.request) { askForPermission(activity, arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT)) } rxBus.send(EventNewNotification(notification)) } else { activity.startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index 6a5a5acf54..449af8dd64 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt @@ -443,12 +443,7 @@ class BolusWizard @Inject constructor( commandQueue.tempBasalPercent(0, 120, true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() { override fun run() { if (!result.success) { - val i = Intent(ctx, ErrorHelperActivity::class.java) - i.putExtra(ErrorHelperActivity.SOUND_ID, R.raw.boluserror) - i.putExtra(ErrorHelperActivity.STATUS, result.comment) - i.putExtra(ErrorHelperActivity.TITLE, rh.gs(R.string.tempbasaldeliveryerror)) - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - ctx.startActivity(i) + ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror) } } }) diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index 5a9ff0129f..0d8a78f482 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -645,7 +645,6 @@ Pro oznámení vyžaduje aplikace oprávnění systémového okna Aplikace potřebuje oprávnění k přístupu k poloze kvůli skenování BT a WiFi identifikaci Aby bylo možné nahrávat logy a exportovat nastavení, je nutné pro aplikaci povolit oprávnění přístupu k úložišti - Aplikace potřebuje oprávnění bluetooth Požadavek Otevřít menu Zavřít menu diff --git a/app/src/main/res/values-da-rDK/strings.xml b/app/src/main/res/values-da-rDK/strings.xml index 0f64e595f1..b21dfe69b3 100644 --- a/app/src/main/res/values-da-rDK/strings.xml +++ b/app/src/main/res/values-da-rDK/strings.xml @@ -636,7 +636,6 @@ Applikationen mangler system vindues tilladelse til notifikationer Applikationen mangler lokations tilladelse til BT scanning og WIFI identifikation Applikationen mangler lagerstyrings tilladelse for at gemme logfiler og exporteringsindstillinger - Applikationen kræver tilladelse til bluetooth Anmod Åbn navigation Luk navigation diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index 0ccb861169..43c2f5b311 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -633,7 +633,6 @@ Die App benötigt die Systemberechtigung für App-Benachrichtigungen Die App benötigt die Berechtigung für den Standort, um Bluetooth und WLAN nutzen zu können Die App benötigt Zugriffsrechte für den Speicher um Log-Dateien zu sichern und die Einstellungen zu exportieren. - App benötigt Bluetooth-Berechtigung Anfordern Menü öffnen Menü schließen diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index d8e5d59e56..7f18165931 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -645,7 +645,6 @@ La aplicación necesita permisos del sistema para poder mostrarse sobre otras aplicaciones, para las notificaciones La aplicación necesita permiso de ubicación para poder buscar dispositivos Bluetooth y redes WiFi La aplicación necesita permiso de almacenamiento para poder almacenar archivos de registro y valores de exportación - La aplicación necesita permiso de bluetooth Solicitar Abrir navegación Cerrar navegación diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 5988390a0d..fd5d099938 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -646,7 +646,6 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S L\'application a besoin de l\'autorisation d\'accès à la fenêtre système pour les notifications L\'application a besoin de l\'autorisation de localisation pour l\'analyse BT et l\'identification WiFi L\'application a besoin d\'une autorisation de stockage pour pouvoir stocker les fichiers journaux et les paramètres d\'exportation - L\'application a besoin de l\'autorisation Bluetooth Demande Ouvrir navigation Fermer navigation diff --git a/app/src/main/res/values-it-rIT/exam.xml b/app/src/main/res/values-it-rIT/exam.xml index 1841752c18..93738aef2c 100644 --- a/app/src/main/res/values-it-rIT/exam.xml +++ b/app/src/main/res/values-it-rIT/exam.xml @@ -136,6 +136,19 @@ Compara i valori in AndroidAPS con lo storico micro (se supportato). Erogare un bolo con parte della tua insulina calcolata \"mancante\" usando una siringa/penna o la funzione caricamento. Non fare nulla e permettere ad AndroidAPS di correggere eventuali glicemie alte. + CHO attivi (COB) + In che modo la modifica del valore ISF influisce sul calcolo dei COB? + L\'aumento di ISF richiederà un tempo maggiore per l\'assorbimento dei CHO + L\'aumento di ISF richiederà un tempo minore per l\'assorbimento dei CHO + L\'aumento di ISF non influirà sull\'assorbimento calcolato dei CHO + In che modo la modifica del valore IC influisce sul calcolo dei COB? + L\'aumento di IC richiederà un tempo maggiore per l\'assorbimento dei CHO + L\'aumento di IC richiederà un tempo minore per l\'assorbimento dei CHO + L\'aumento di IC non influirà sull\'assorbimento calcolato dei CHO + In che modo la modifica della percentuale profilo influisce sul calcolo dei COB? + Impostare il profilo al 150% richiederà un tempo maggiore per l\'assorbimento dei CHO + Impostare il profilo al 150% richiederà un tempo minore per l\'assorbimento dei CHO + Impostare il profilo al 150% non influirà sull\'assorbimento calcolato dei CHO Insulina attiva (IOB) Il valore IOB è influenzato dalle basali temporanee emesse. Non verrà emessa una basale temporanea alta quando la tua glicemia è al di sotto del target. diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 3ef0aad794..191d76f1b6 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -645,7 +645,6 @@ L\'applicazione richiede l\'autorizzazione \"finestra di sistema\" per le notifiche L\'applicazione richiede l\'accesso alla posizione per la scansione bluetooth e l\'identificazione WiFi L\'applicazione richiede l\'accesso alla memoria per memorizzare i file di log ed esportare le impostazioni - L\'applicazione richiede l\'autorizzazione bluetooth Richiesta Apri navigazione Chiudi navigazione @@ -1037,10 +1036,12 @@ solo su smartwatch solo su telefono trascina e rilascia + Cerca GlucoRx Aidex GlucoRx Aidex Ricevi valori glicemia da CGM GlucoRx Aidex. Bloccato dalle opzioni di ricarica Bloccato dalle opzioni di connettività + (Nessuno smartwatch connesso) diff --git a/app/src/main/res/values-iw-rIL/strings.xml b/app/src/main/res/values-iw-rIL/strings.xml index a51a33dfee..536056923b 100644 --- a/app/src/main/res/values-iw-rIL/strings.xml +++ b/app/src/main/res/values-iw-rIL/strings.xml @@ -645,7 +645,6 @@ האפליקציה צריכה הרשאת מערכת של חלונות לצורך התראות דרושה הרשאת מיקום עבור סריקת בלוטות\' וזיהוי WiFi דרושה הרשאת אחסון כדי שתוכלו לאחסן קובצי יומן והגדרות יצוא. - האפליקציה צריכה הרשאה לבלוטות\' בקשה פתח ניווט סגור ניווט diff --git a/app/src/main/res/values-lt-rLT/strings.xml b/app/src/main/res/values-lt-rLT/strings.xml index 211286d69f..dcf41407e5 100644 --- a/app/src/main/res/values-lt-rLT/strings.xml +++ b/app/src/main/res/values-lt-rLT/strings.xml @@ -631,7 +631,6 @@ Norint gauti pranešimus, programai reikalingas sisteminio lango leidimas Programai reikia vietos nustatymo leidimo, kad būtų galima naudoti Bluetooth ir WiFi Aplikacijai reikia leidimo prieigai prie saugyklos, kad galėtų išsaugoti žurnalo įrašus ir eksportavimo nustatymus - Programai reikalinga Bluetooth prieigos teisė Užklausa Atidaryti meniu Uždaryti meniu @@ -894,6 +893,7 @@ Negalimas + Rūšiuoti Prisijungti diff --git a/app/src/main/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml index b1beae35b7..d9a282aaf0 100644 --- a/app/src/main/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -645,7 +645,6 @@ Toepassing vereist systeemvenstermachtiging voor meldingen App heeft locatie toestemming nodig voor Bluetooth scan en WiFi identificatie Applicatie heeft toestemming nodig om log bestanden op te slaan en instellingen te exporteren - Applicatie heeft Bluetooth toestemming nodig Verzoek Open navigatie Sluit navigatie diff --git a/app/src/main/res/values-no-rNO/strings.xml b/app/src/main/res/values-no-rNO/strings.xml index 21dbe2cb6a..b485585ece 100644 --- a/app/src/main/res/values-no-rNO/strings.xml +++ b/app/src/main/res/values-no-rNO/strings.xml @@ -645,7 +645,6 @@ App trenger tillatelse til å bruke Varslinger for å vise meldinger App trenger tilgang til Posisjon for å søke etter Bluetooth og Wifi enheter App trenger tilgang til Lagring for lagre logg filer og eksportere innstillinger - Appen trenger bluetooth tillatelse Forespørsel Åpne meny Lukk meny diff --git a/app/src/main/res/values-pl-rPL/strings.xml b/app/src/main/res/values-pl-rPL/strings.xml index 716f005083..f91047c74f 100644 --- a/app/src/main/res/values-pl-rPL/strings.xml +++ b/app/src/main/res/values-pl-rPL/strings.xml @@ -244,6 +244,7 @@ Oprogramowanie Wear (Smartwatch) Prześlij ponownie wszystkie dane Otwórz ustawienia dla Wear + Dawka bazowa Wartość bazy poniżej minimum. Nie ustawiono profilu! BG: Ostatnia BG: @@ -631,7 +632,6 @@ Aplikacja wymaga uprawnienia systemowego okna dla powiadomień Aplikacja wymaga dostępu do lokalizacji dla zarządzania bluetoothem i identyfikacją Wi-Fi Aplikacja wymaga zgody na zapis do pamięci, aby móc przechować pliki logów i eksportować ustawienia - Aplikacja wymaga uprawnienia Bluetooth Żądanie Otwórz menu Zamknij menu @@ -667,6 +667,7 @@ Leczenie (insulina: %1$.2f, węglowodany: %2$d, czas:%3$s) nie mogą być dodane. Sprawdź i dodaj ręcznie rekord w razie potrzeby. eWęgle: %1$d g (%2$d h), Opóźnienie: %3$d m Brak dostępnych danych autosens + Log files Ustawienia logów Przywróć ustawienia domyślne Usterka NSClient. Spróbuj zrestartować NS i NSClient. @@ -748,6 +749,8 @@ Nazwa profilu zawiera kropki.\nTo nie jest obsługiwane przez NS.\nProfil nie zostanie przesyłany do NS. Dolna wartość zakresu docelowego (tylko do wyświetlania) Górna wartość zakresu docelowego (tylko do wyświetlania) + Czas + Waga ID: Wyślij Najczęściej używany profil: @@ -797,6 +800,7 @@ Na każdym telefonie śledzącym zainstalować aplikację uwierzytelniania obsługującą tokeny TOTP RFC 6238 Popularne darmowe aplikacje:\n • Authy\n • Google Authenticator\n • LastPass Authenticator\n • FreeOTP Authenticator Resetowanie uwierzytelniania powoduje, że wszystkie już ustawione uwierzytelnienia stają się niepoprawne (przestają działać). Trzeba będzie je jeszcze raz skonfigurować! Prognozy poziomu + Zabiegi Krzywa odchylenie Autoryzacja nie powiodła się Cała insulina @@ -896,6 +900,7 @@ Usuń wybrane pozycje Czy na pewno chcesz usunąć %1$d pozycji + Brak wpisów Wybrany %1$d Sortuj Zaloguj się diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 1049c0380e..b435fbeb69 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -631,7 +631,6 @@ Aplicação precisa de permissão de janela do sistema para notificações Aplicação necessita de permissão de localização para pesquisa Bluetooth e identificação Wi-Fi A aplicação precisa da permissão de armazenamento para poder armazenar ficheiros de registo e exportar definições - Aplicação precisa de permissão Bluetooth Pedido Abrir a navegação Fechar a navegação diff --git a/app/src/main/res/values-ro-rRO/strings.xml b/app/src/main/res/values-ro-rRO/strings.xml index 2d55df640a..44c5283a22 100644 --- a/app/src/main/res/values-ro-rRO/strings.xml +++ b/app/src/main/res/values-ro-rRO/strings.xml @@ -631,7 +631,6 @@ Aplicația are nevoie de permisiune la fereastra sistemului pentru a afișa notificări Aplicația are nevoie sa acceseze locația pentru scanare Bluetooth și identificare WiFi Aplicația are nevoie de permisiunea de a accesa unitatea de stocare pentru a scrie fișierele registru și pentru a exporta setările - Aplicația are nevoie de permisiune Bluetooth Cerință Afișare navigație Închidere navigație diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index fa3d099a67..76c70619d1 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -645,7 +645,6 @@ Приложению требуется разрешение системного окна для уведомлений Приложению требуется разрешение на доступ к местоположению для сканирования BT и идентификации WiFi Приложение требует разрешения на доступ к записи в память, чтобы хранить файлы журналов и настройки экспорта - Приложению требуется разрешение Bluetooth Запрос Показать панель навигации Cкрыть панель навигации diff --git a/app/src/main/res/values-sk-rSK/strings.xml b/app/src/main/res/values-sk-rSK/strings.xml index c77651b5d5..5173d5ea18 100644 --- a/app/src/main/res/values-sk-rSK/strings.xml +++ b/app/src/main/res/values-sk-rSK/strings.xml @@ -645,7 +645,6 @@ Aplikácia vyžaduje pre oznámenia systémové oprávnenie Aplikácia vyžaduje oprávnenie polohy, pre vyhľadávanie BT a identifikáciu WiFi Aby bolo možné nahrávať logy a exportovať nastavenia, je nutné pre aplikáciu povoliť oprávnenie prístupu k úložisku - Aplikácia vyžaduje povolenie bluetooth Požiadavka Otvoriť Menu Zavrieť Menu diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml index a85a2e4cb2..3a6718d5c3 100644 --- a/app/src/main/res/values-sv-rSE/strings.xml +++ b/app/src/main/res/values-sv-rSE/strings.xml @@ -636,7 +636,6 @@ Eversense-appen. Applikationen behöver förhöjd behörighet för aviseringar Appen behöver platsåtkomst för bluetooth- och WiFi-identifiering Applikationen behöver lagringsbehörighet för att kunna lagra loggfiler och exportinställningar - Applikationen behöver bluetooth-behörighet Begäran Öppna menyn Stäng menyn diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index 12b3ce5b18..ee47a75e18 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -646,7 +646,6 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Uygulama, bildirimler için sistem iznine ihtiyaç duyuyor Uygulamanın BT taraması ve WiFi tanımlaması için konum iznine ihtiyacı var Uygulamanın, günlük dosyalarını saklayabilmesi ve ayarları dışa aktarabilmesi için depolama iznine ihtiyacı var - Uygulama bluetooth iznine ihtiyac duyuyor İstek Navigasyonu aç Navigasyonu kapat diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 642148ddb4..47018ea425 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -432,6 +432,7 @@ 启用本地广播。 OpenAPS SMB 动态ISF(胰岛素敏感系数) + 动态ISF的调整因子。设置100%以上用于更积极的校正,100%以下则不那么积极校正。 启用 UAM 启用微型大剂量 使用微型大剂量代替使用临时基础率,更快的干预 @@ -636,7 +637,6 @@ 应用程序需要悬浮窗权限用于发送通知。 应用程序需要定位权限,才能进行蓝牙扫描及WIFI识别。 应用程序需要文件存储权限,才能存储日志文件及导出设置。 - 应用程序需要蓝牙权限。 请求 打开导航栏 关闭导航栏 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7bc428a968..148a476141 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -789,7 +789,6 @@ Application needs system window permission for notifications Application needs location permission for BT scan and WiFi identification Application needs storage permission to be able store log files and export settings - Application needs bluetooth permission Request Open navigation Close navigation diff --git a/app/src/main/res/xml/pref_autotune.xml b/app/src/main/res/xml/pref_autotune.xml index aef72365a0..7cc1d6d488 100644 --- a/app/src/main/res/xml/pref_autotune.xml +++ b/app/src/main/res/xml/pref_autotune.xml @@ -1,6 +1,8 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:validate="http://schemas.android.com/apk/res-auto"> + --> - + android:title="@string/autotune_default_tune_days_title" + android:dialogMessage="@string/autotune_default_tune_days_summary" + android:digits="0123456789" + android:inputType="number" + android:selectAllOnFocus="true" + android:singleLine="true" + validate:maxNumber="30" + validate:minNumber="1" + validate:testType="numericRange" /> { val s = ArrayList() - (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter?.bondedDevices?.forEach { s.add(it.name) } + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { + (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter?.bondedDevices?.forEach { s.add(it.name) } + } else { + ToastUtils.errorToast(context, context.getString(R.string.needconnectpermission)) + } return s } private fun eventExists(): Boolean { - automationPlugin.btConnects.forEach { + ArrayList(automationPlugin.btConnects).forEach { if (btDevice.value == it.deviceName) { if (comparator.value == ComparatorConnect.Compare.ON_CONNECT && it.state == EventBTChange.Change.CONNECT) return true if (comparator.value == ComparatorConnect.Compare.ON_DISCONNECT && it.state == EventBTChange.Change.DISCONNECT) return true diff --git a/automation/src/main/res/values-it-rIT/strings.xml b/automation/src/main/res/values-it-rIT/strings.xml index 926f76ebc6..e341ede3d4 100644 --- a/automation/src/main/res/values-it-rIT/strings.xml +++ b/automation/src/main/res/values-it-rIT/strings.xml @@ -123,4 +123,5 @@ Esegui automazioni Aggiungi regola Rimuovi/ordina + Interrompere l\'elaborazione diff --git a/automation/src/main/res/values-lt-rLT/strings.xml b/automation/src/main/res/values-lt-rLT/strings.xml index acd9f4fba0..c4d36915e2 100644 --- a/automation/src/main/res/values-lt-rLT/strings.xml +++ b/automation/src/main/res/values-lt-rLT/strings.xml @@ -112,4 +112,5 @@ Automatizuotas įvykis Pertvarkyti Vartotojo veiksmas + Rūšiuoti diff --git a/build.gradle b/build.gradle index 8feda7ccf3..5aafa2b9ae 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' - classpath 'com.google.gms:google-services:4.3.10' + classpath 'com.google.gms:google-services:4.3.13' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1' // NOTE: Do not place your application dependencies here; they belong @@ -63,7 +63,7 @@ buildscript { } plugins { - id "io.gitlab.arturbosch.detekt" version "1.20.0" + id "io.gitlab.arturbosch.detekt" version "1.21.0" id "org.jlleitschuh.gradle.ktlint" version "10.3.0" id 'org.barfuin.gradle.jacocolog' version '2.0.0' id 'org.jetbrains.kotlin.android' version '1.7.10' apply false diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml index 0f37944ddb..083c7f30cf 100644 --- a/core/src/main/AndroidManifest.xml +++ b/core/src/main/AndroidManifest.xml @@ -8,6 +8,8 @@ + + = Build.VERSION_CODES.S) { - if (ContextCompat.checkSelfPermission(context, "android.permission.BLUETOOTH_CONNECT") != PackageManager.PERMISSION_GRANTED || - ContextCompat.checkSelfPermission(context, "android.permission.BLUETOOTH_SCAN") != PackageManager.PERMISSION_GRANTED + if (ContextCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED || + ContextCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED ) { - //ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT), PERMISSION_REQUEST_BLUETOOTH) - ActivityCompat.requestPermissions(activity, arrayOf("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT"), PERMISSION_REQUEST_BLUETOOTH) + ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT), PERMISSION_REQUEST_BLUETOOTH) return false } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/BluetoothDevicePreference.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/BluetoothDevicePreference.kt new file mode 100644 index 0000000000..20bbfd38a0 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/BluetoothDevicePreference.kt @@ -0,0 +1,33 @@ +package info.nightscout.androidaps.utils.ui + +import android.Manifest +import kotlin.jvm.JvmOverloads +import android.bluetooth.BluetoothManager +import android.content.Context +import android.content.pm.PackageManager +import android.os.Build +import android.util.AttributeSet +import androidx.core.app.ActivityCompat +import androidx.preference.ListPreference +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.utils.ToastUtils +import java.util.* + +class BluetoothDevicePreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ListPreference(context, attrs) { + + init { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { + val devices = Vector() + (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter?.let { bta -> + for (dev in bta.bondedDevices) + dev.name?.let { name -> devices.add(name) } + } + entries = devices.toTypedArray() + entryValues = devices.toTypedArray() + } else { + entries = emptyArray() + entryValues = emptyArray() + ToastUtils.errorToast(context, context.getString(R.string.needconnectpermission)) + } + } +} \ No newline at end of file diff --git a/core/src/main/res/values-bg-rBG/strings.xml b/core/src/main/res/values-bg-rBG/strings.xml index 183980600d..e6b584986c 100644 --- a/core/src/main/res/values-bg-rBG/strings.xml +++ b/core/src/main/res/values-bg-rBG/strings.xml @@ -289,6 +289,7 @@ SMS Базал + Апликацията изисква разрешение за bluetooth %1$d дeн %1$d дни diff --git a/core/src/main/res/values-ca-rES/strings.xml b/core/src/main/res/values-ca-rES/strings.xml index 1eb5f978ea..6cd9b7b34c 100644 --- a/core/src/main/res/values-ca-rES/strings.xml +++ b/core/src/main/res/values-ca-rES/strings.xml @@ -70,4 +70,5 @@ Basal + L\'aplicació necessita el permís del bluethoot diff --git a/core/src/main/res/values-cs-rCZ/strings.xml b/core/src/main/res/values-cs-rCZ/strings.xml index b0570bbe77..81d72c8309 100644 --- a/core/src/main/res/values-cs-rCZ/strings.xml +++ b/core/src/main/res/values-cs-rCZ/strings.xml @@ -489,6 +489,7 @@ Autotune spuštěno, a profil automaticky přepnut Chyba při posledním spuštění Autotune Byla zjištěna jiná běžící úloha Autotune, spuštění zrušeno + Aplikace potřebuje oprávnění bluetooth %1$d den %1$d dnů diff --git a/core/src/main/res/values-da-rDK/strings.xml b/core/src/main/res/values-da-rDK/strings.xml index d446162c2f..013f43fc61 100644 --- a/core/src/main/res/values-da-rDK/strings.xml +++ b/core/src/main/res/values-da-rDK/strings.xml @@ -482,6 +482,7 @@ Autotune kørt uden profilskift Autotune kørt, profilen er automatisk skiftet Fejl under sidste Autotune kørsel + Applikationen kræver tilladelse til bluetooth %1$d dag %1$d dage diff --git a/core/src/main/res/values-de-rDE/strings.xml b/core/src/main/res/values-de-rDE/strings.xml index 5b12029067..400da03d56 100644 --- a/core/src/main/res/values-de-rDE/strings.xml +++ b/core/src/main/res/values-de-rDE/strings.xml @@ -433,6 +433,7 @@ %1$d ausgewählt Sortieren + App benötigt Bluetooth-Berechtigung %1$d Tag %1$d Tage diff --git a/core/src/main/res/values-es-rES/strings.xml b/core/src/main/res/values-es-rES/strings.xml index 24f6b404b5..502b29f99b 100644 --- a/core/src/main/res/values-es-rES/strings.xml +++ b/core/src/main/res/values-es-rES/strings.xml @@ -489,6 +489,7 @@ Autotune ejecutado y perfil cambiado automáticamente Error durante la última ejecución de Autotune Se ha detectado otra ejecución de Autotune, ejecución cancelada + La aplicación necesita permiso de bluetooth %1$d día %1$d días diff --git a/core/src/main/res/values-it-rIT/strings.xml b/core/src/main/res/values-it-rIT/strings.xml index 0f86119b89..752b4f9264 100644 --- a/core/src/main/res/values-it-rIT/strings.xml +++ b/core/src/main/res/values-it-rIT/strings.xml @@ -488,6 +488,8 @@ Autotune eseguito senza cambio profilo Autotune eseguito e profilo cambiato automaticamente Errore durante l\'ultima esecuzione di Autotune + È stata rilevata un\'altra esecuzione di Autotune, esecuzione annullata + L\'applicazione richiede l\'autorizzazione bluetooth %1$d giorno %1$d giorni diff --git a/core/src/main/res/values-iw-rIL/strings.xml b/core/src/main/res/values-iw-rIL/strings.xml index 20cb735c6e..c837a798e3 100644 --- a/core/src/main/res/values-iw-rIL/strings.xml +++ b/core/src/main/res/values-iw-rIL/strings.xml @@ -489,6 +489,7 @@ כוונון אוטומטי הופעל והפרופיל הוחלף אוטומטית שגיאה במהלך הכיוונון האוטומטי האחרון נמצאה הפעלה נוספת של הכוונון האוטומטי ברקע, ההפעלה מבוטלת + האפליקציה צריכה הרשאה לבלוטות\' %1$d יום %1$d ימים diff --git a/core/src/main/res/values-lt-rLT/strings.xml b/core/src/main/res/values-lt-rLT/strings.xml index c834cbf768..7a1c1ae6e6 100644 --- a/core/src/main/res/values-lt-rLT/strings.xml +++ b/core/src/main/res/values-lt-rLT/strings.xml @@ -422,6 +422,7 @@ Insight Mygtukas Naujinti Valandinė bazė + Programai reikalinga Bluetooth prieigos teisė %1$d d. %1$d d. diff --git a/core/src/main/res/values-night/styles.xml b/core/src/main/res/values-night/styles.xml index 7e98c75fcd..3a9fe781b5 100644 --- a/core/src/main/res/values-night/styles.xml +++ b/core/src/main/res/values-night/styles.xml @@ -246,6 +246,14 @@ @color/white @color/white + + @style/CommonSpinnerItemStyle + + + + + + + diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/BluetoothDevicePreference.kt b/danar/src/main/java/info/nightscout/androidaps/danar/BluetoothDevicePreference.kt deleted file mode 100644 index 41b090bc72..0000000000 --- a/danar/src/main/java/info/nightscout/androidaps/danar/BluetoothDevicePreference.kt +++ /dev/null @@ -1,22 +0,0 @@ -package info.nightscout.androidaps.danar - -import kotlin.jvm.JvmOverloads -import android.bluetooth.BluetoothAdapter -import android.bluetooth.BluetoothDevice -import android.bluetooth.BluetoothManager -import android.content.Context -import android.util.AttributeSet -import androidx.preference.ListPreference -import java.util.* - -class BluetoothDevicePreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ListPreference(context, attrs) { - init { - val entries = Vector() - (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter?.let { bta -> - for (dev in bta.bondedDevices) - dev.name?.let { name -> entries.add(name) } - } - setEntries(entries.toTypedArray()) - entryValues = entries.toTypedArray() - } -} \ No newline at end of file diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java index 2e0b01350c..3425dd25ad 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java @@ -1,14 +1,19 @@ package info.nightscout.androidaps.danar.services; +import android.Manifest; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothSocket; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.IBinder; import android.os.SystemClock; +import androidx.core.app.ActivityCompat; + import java.io.IOException; import java.util.Set; import java.util.UUID; @@ -41,8 +46,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.interfaces.Profile; import info.nightscout.androidaps.interfaces.PumpSync; -import info.nightscout.shared.logging.AAPSLogger; -import info.nightscout.shared.logging.LTag; +import info.nightscout.androidaps.interfaces.ResourceHelper; import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; @@ -50,8 +54,9 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.ToastUtils; -import info.nightscout.androidaps.interfaces.ResourceHelper; import info.nightscout.androidaps.utils.rx.AapsSchedulers; +import info.nightscout.shared.logging.AAPSLogger; +import info.nightscout.shared.logging.LTag; import info.nightscout.shared.sharedPreferences.SP; import io.reactivex.rxjava3.disposables.CompositeDisposable; @@ -191,30 +196,32 @@ public abstract class AbstractDanaRExecutionService extends DaggerService { protected void getBTSocketForSelectedPump() { mDevName = sp.getString(R.string.key_danar_bt_name, ""); - BluetoothAdapter bluetoothAdapter = ((BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { + BluetoothAdapter bluetoothAdapter = ((BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); - if (bluetoothAdapter != null) { - Set bondedDevices = bluetoothAdapter.getBondedDevices(); + if (bluetoothAdapter != null) { + Set bondedDevices = bluetoothAdapter.getBondedDevices(); - if (bondedDevices != null) - for (BluetoothDevice device : bondedDevices) { - if (mDevName.equals(device.getName())) { - mBTDevice = device; - try { - mRfcommSocket = mBTDevice.createRfcommSocketToServiceRecord(SPP_UUID); - } catch (IOException e) { - aapsLogger.error("Error creating socket: ", e); + if (bondedDevices != null) + for (BluetoothDevice device : bondedDevices) { + if (mDevName.equals(device.getName())) { + mBTDevice = device; + try { + mRfcommSocket = mBTDevice.createRfcommSocketToServiceRecord(SPP_UUID); + } catch (IOException e) { + aapsLogger.error("Error creating socket: ", e); + } + break; } - break; } - } + } else { + ToastUtils.INSTANCE.showToastInUiThread(context.getApplicationContext(), rh.gs(R.string.nobtadapter)); + } + if (mBTDevice == null) { + ToastUtils.INSTANCE.showToastInUiThread(context.getApplicationContext(), rh.gs(R.string.devicenotfound)); + } } else { - ToastUtils.INSTANCE.showToastInUiThread(context.getApplicationContext(), - rh.gs(R.string.nobtadapter)); - } - if (mBTDevice == null) { - ToastUtils.INSTANCE.showToastInUiThread(context.getApplicationContext(), - rh.gs(R.string.devicenotfound)); + ToastUtils.INSTANCE.errorToast(context, context.getString(R.string.needconnectpermission)); } } diff --git a/danar/src/main/res/xml/pref_danar.xml b/danar/src/main/res/xml/pref_danar.xml index c7d45b8f12..98b1f51b37 100644 --- a/danar/src/main/res/xml/pref_danar.xml +++ b/danar/src/main/res/xml/pref_danar.xml @@ -8,7 +8,7 @@ android:title="@string/danar_pump_settings" app:initialExpandedChildrenCount="0"> - diff --git a/danar/src/main/res/xml/pref_danarkorean.xml b/danar/src/main/res/xml/pref_danarkorean.xml index 96479baf58..5b3372e2ed 100644 --- a/danar/src/main/res/xml/pref_danarkorean.xml +++ b/danar/src/main/res/xml/pref_danarkorean.xml @@ -8,7 +8,7 @@ android:title="@string/danar_pump_settings" app:initialExpandedChildrenCount="0"> - diff --git a/danar/src/main/res/xml/pref_danarv2.xml b/danar/src/main/res/xml/pref_danarv2.xml index f18ed77e4a..f16c06afb6 100644 --- a/danar/src/main/res/xml/pref_danarv2.xml +++ b/danar/src/main/res/xml/pref_danarv2.xml @@ -8,7 +8,7 @@ android:title="@string/danar_pump_settings" app:initialExpandedChildrenCount="0"> - diff --git a/danars/src/main/AndroidManifest.xml b/danars/src/main/AndroidManifest.xml index c3ef8bc727..108cb94048 100644 --- a/danars/src/main/AndroidManifest.xml +++ b/danars/src/main/AndroidManifest.xml @@ -5,6 +5,8 @@ + + = Build.VERSION_CODES.S && + ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED + ) { + ToastUtils.errorToast(context, context.getString(info.nightscout.androidaps.core.R.string.needconnectpermission)) + aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from") + return false + } aapsLogger.debug(LTag.PUMPBTCOMM, "Initializing BLEComm.") if (bluetoothAdapter == null) { aapsLogger.error("Unable to obtain a BluetoothAdapter.") @@ -107,8 +119,10 @@ class BLEComm @Inject internal constructor( return false } if (device.bondState == BluetoothDevice.BOND_NONE) { - device.createBond() - SystemClock.sleep(10000) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { + device.createBond() + SystemClock.sleep(10000) + } return false } isConnected = false @@ -131,6 +145,12 @@ class BLEComm @Inject internal constructor( @Synchronized fun disconnect(from: String) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED + ) { + aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from") + return + } aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from") if (!encryptedDataRead && encryptedCommandSent && encryption == EncryptionType.ENCRYPTION_BLE5) { @@ -191,6 +211,7 @@ class BLEComm @Inject internal constructor( } } + @SuppressLint("MissingPermission") @Synchronized fun close() { /* if (!encryptedDataRead && !encryptedCommandSent) { @@ -268,6 +289,7 @@ class BLEComm @Inject internal constructor( } } + @SuppressLint("MissingPermission") @Synchronized private fun setCharacteristicNotification(characteristic: BluetoothGattCharacteristic?, enabled: Boolean) { aapsLogger.debug(LTag.PUMPBTCOMM, "setCharacteristicNotification") @@ -287,6 +309,7 @@ class BLEComm @Inject internal constructor( } } + @SuppressLint("MissingPermission") @Synchronized private fun writeCharacteristicNoResponse(characteristic: BluetoothGattCharacteristic, data: ByteArray) { Thread(Runnable { @@ -346,6 +369,7 @@ class BLEComm @Inject internal constructor( } } + @SuppressLint("MissingPermission") @Synchronized private fun onConnectionStateChangeSynchronized(gatt: BluetoothGatt, newState: Int) { aapsLogger.debug(LTag.PUMPBTCOMM, "onConnectionStateChange") @@ -559,7 +583,7 @@ class BLEComm @Inject internal constructor( sp.putString(rh.gs(R.string.key_dana_ble5_pairingkey) + danaRSPlugin.mDeviceName, pairingKey) val storedPairingKey = sp.getString(rh.gs(R.string.key_dana_ble5_pairingkey) + danaRSPlugin.mDeviceName, "") - if (storedPairingKey.isNullOrBlank()) { + if (storedPairingKey.isBlank()) { removeBond() disconnect("Non existing pairing key") } diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt index fcb383fa8c..897723f2ec 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt @@ -19,7 +19,9 @@ class DiaconnG8Pump @Inject constructor( private val aapsLogger: AAPSLogger, private val dateUtil: DateUtil ) { - + //var bleResultInfo: Pair = Pair(null, false) + var bolusConfirmMessage: Byte = 0 + var isReadyToBolus: Boolean = false var maxBolusePerDay: Double = 0.0 var pumpIncarnationNum: Int = 65536 var isPumpVersionGe2_63: Boolean = false // is pumpVersion higher then 2.63 diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8BLEScanActivity.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8BLEScanActivity.kt index 52165d828d..05fbebeaf1 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8BLEScanActivity.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8BLEScanActivity.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.diaconn.activities +import android.Manifest import android.annotation.SuppressLint import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothDevice @@ -11,6 +12,8 @@ import android.bluetooth.le.ScanResult import android.bluetooth.le.ScanSettings import android.content.Context import android.content.pm.ActivityInfo +import android.content.pm.PackageManager +import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper @@ -19,12 +22,13 @@ import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.TextView +import androidx.core.app.ActivityCompat import info.nightscout.androidaps.activities.NoSplashAppCompatActivity -import info.nightscout.androidaps.diaconn.events.EventDiaconnG8DeviceChange import info.nightscout.androidaps.diaconn.R import info.nightscout.androidaps.diaconn.databinding.DiaconnG8BlescannerActivityBinding -import info.nightscout.androidaps.plugins.bus.RxBus +import info.nightscout.androidaps.diaconn.events.EventDiaconnG8DeviceChange import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck +import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.shared.sharedPreferences.SP import java.util.* import javax.inject.Inject @@ -61,18 +65,25 @@ class DiaconnG8BLEScanActivity : NoSplashAppCompatActivity() { override fun onResume() { super.onResume() - bluetoothAdapter?.let { bluetoothAdapter -> - if (!bluetoothAdapter.isEnabled) bluetoothAdapter.enable() - bluetoothLeScanner = bluetoothAdapter.bluetoothLeScanner - startScan() + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED) { + bluetoothAdapter?.let { bluetoothAdapter -> + if (!bluetoothAdapter.isEnabled) bluetoothAdapter.enable() + bluetoothLeScanner = bluetoothAdapter.bluetoothLeScanner + startScan() + } + } else { + ToastUtils.errorToast(context, context.getString(info.nightscout.androidaps.core.R.string.needconnectpermission)) } } override fun onPause() { super.onPause() - stopScan() + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED) { + stopScan() + } } + @SuppressLint("MissingPermission") private fun startScan() = try { val filters: MutableList = ArrayList() @@ -86,16 +97,23 @@ class DiaconnG8BLEScanActivity : NoSplashAppCompatActivity() { .build() bluetoothLeScanner?.startScan(filters, settings, mBleScanCallback) - } catch (e: IllegalStateException) { + } catch (ignored: IllegalStateException) { } // ignore BT not on + @SuppressLint("MissingPermission") private fun stopScan() = try { bluetoothLeScanner?.stopScan(mBleScanCallback) - } catch (e: IllegalStateException) { + } catch (ignored: IllegalStateException) { } // ignore BT not on private fun addBleDevice(device: BluetoothDevice?) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED + ) { + ToastUtils.errorToast(context, context.getString(info.nightscout.androidaps.core.R.string.needconnectpermission)) + return + } if (device == null || device.name == null || device.name == "") { return } @@ -145,6 +163,7 @@ class DiaconnG8BLEScanActivity : NoSplashAppCompatActivity() { v.setOnClickListener(this@ViewHolder) } + @SuppressLint("MissingPermission") override fun onClick(v: View) { sp.putString(R.string.key_diaconn_g8_address, item.device.address) sp.putString(R.string.key_diaconn_g8_name, name.text.toString()) @@ -153,6 +172,7 @@ class DiaconnG8BLEScanActivity : NoSplashAppCompatActivity() { finish() } + @SuppressLint("MissingPermission") fun setData(data: BluetoothDeviceItem) { var tTitle = data.device.name if (tTitle == null || tTitle == "") { @@ -168,6 +188,7 @@ class DiaconnG8BLEScanActivity : NoSplashAppCompatActivity() { // inner class BluetoothDeviceItem internal constructor(val device: BluetoothDevice) { + override fun equals(other: Any?): Boolean { if (other !is BluetoothDeviceItem) { return false diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt index 49d315f341..a1e62c4d5d 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt @@ -152,12 +152,7 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { commandQueue.setUserOptions(object : Callback() { override fun run() { if (!result.success) { - val i = Intent(context, ErrorHelperActivity::class.java) - i.putExtra("soundid", R.raw.boluserror) - i.putExtra("status", result.comment) - i.putExtra("title", rh.gs(R.string.pumperror)) - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - context.startActivity(i) + ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.pumperror), R.raw.boluserror) } } }) diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8PacketModule.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8PacketModule.kt index 86a27374ce..49ec0d9f30 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8PacketModule.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8PacketModule.kt @@ -77,6 +77,8 @@ abstract class DiaconnG8PacketModule { @ContributesAndroidInjector abstract fun contributesLanguageInquireResponsePacket(): LanguageInquireResponsePacket @ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquirePacket(): BigAPSMainInfoInquirePacket @ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquireResponsePacket(): BigAPSMainInfoInquireResponsePacket + @ContributesAndroidInjector abstract fun contributesSerialNumInquirePacket(): SerialNumInquirePacket + @ContributesAndroidInjector abstract fun contributesSerialNumInquireResponsePacket(): SerialNumInquireResponsePacket } diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt index d45f174bf3..9f41cfde1b 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt @@ -35,6 +35,10 @@ class AppConfirmSettingResponsePacket( failed = true return } + // The bolus progress diallog opens only when the confirm result is successfull + if(diaconnG8Pump.bolusConfirmMessage == 0x07.toByte()) { + diaconnG8Pump.isReadyToBolus = true + } } override fun getFriendlyName(): String { diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8ResponseMessageHashTable.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8ResponseMessageHashTable.kt index 7248d73530..e401d465a8 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8ResponseMessageHashTable.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8ResponseMessageHashTable.kt @@ -25,7 +25,6 @@ class DiaconnG8ResponseMessageHashTable @Inject constructor(val injector: HasAnd put(SneckLimitInquireResponsePacket(injector)) put(BasalLimitInquireResponsePacket(injector)) put(TempBasalInquireResponsePacket(injector)) - put(TimeInquirePacket(injector)) put(TimeInquireResponsePacket(injector)) put(TimeReportPacket(injector)) put(LogStatusInquireResponsePacket(injector)) @@ -34,6 +33,8 @@ class DiaconnG8ResponseMessageHashTable @Inject constructor(val injector: HasAnd put(SoundInquireResponsePacket(injector)) put(DisplayTimeInquireResponsePacket(injector)) put(LanguageInquireResponsePacket(injector)) + put(SerialNumInquireResponsePacket(injector)) + // Report Packet put(BasalPauseReportPacket(injector)) diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SerialNumInquirePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SerialNumInquirePacket.kt new file mode 100644 index 0000000000..0284c35029 --- /dev/null +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SerialNumInquirePacket.kt @@ -0,0 +1,29 @@ +package info.nightscout.androidaps.diaconn.packet + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.diaconn.DiaconnG8Pump +import info.nightscout.shared.logging.LTag +import javax.inject.Inject + +/** + + * SerialNumInquirePacket + */ +class SerialNumInquirePacket( + injector: HasAndroidInjector +) : DiaconnG8Packet(injector ) { + @Inject lateinit var diaconnG8Pump: DiaconnG8Pump + init { + msgType = 0x6E + aapsLogger.debug(LTag.PUMPCOMM, "SeialNumInquirePacket init") + } + + override fun encode(msgSeq:Int): ByteArray { + val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END) + return suffixEncode(buffer) + } + + override fun getFriendlyName(): String { + return "PUMP_SERIAL_NUM_INQUIRE" + } +} \ No newline at end of file diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SerialNumInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SerialNumInquireResponsePacket.kt new file mode 100644 index 0000000000..76306e54fa --- /dev/null +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SerialNumInquireResponsePacket.kt @@ -0,0 +1,69 @@ +package info.nightscout.androidaps.diaconn.packet + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.diaconn.DiaconnG8Pump +import info.nightscout.androidaps.diaconn.R +import info.nightscout.androidaps.interfaces.ResourceHelper +import info.nightscout.shared.logging.LTag +import info.nightscout.shared.sharedPreferences.SP +import javax.inject.Inject + +/** + * SerialNumInquireResponsePacket + */ +class SerialNumInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8Packet(injector ) { + + @Inject lateinit var diaconnG8Pump: DiaconnG8Pump + @Inject lateinit var sp: SP + @Inject lateinit var rh: ResourceHelper + + + init { + msgType = 0xAE.toByte() + aapsLogger.debug(LTag.PUMPCOMM, "SerialNumInquireResponsePacket init") + } + + override fun handleMessage(data: ByteArray?) { + val result = defect(data) + if (result != 0) { + aapsLogger.debug(LTag.PUMPCOMM, "SerialNumInquireResponsePacket Got some Error") + failed = true + return + } else failed = false + + val bufferData = prefixDecode(data) + val result2 = getByteToInt(bufferData) + if(!isSuccInquireResponseResult(result2)) { + failed = true + return + } + + diaconnG8Pump.country = getByteToInt(bufferData).toChar().toString().toInt() // ASCII + diaconnG8Pump.productType = getByteToInt(bufferData).toChar().toString().toInt() // ASCII + diaconnG8Pump.makeYear = getByteToInt(bufferData) + diaconnG8Pump.makeMonth = getByteToInt(bufferData) + diaconnG8Pump.makeDay = getByteToInt(bufferData) + diaconnG8Pump.lotNo = getByteToInt(bufferData)// LOT NO + diaconnG8Pump.serialNo = getShortToInt(bufferData) + diaconnG8Pump.majorVersion = getByteToInt(bufferData) + diaconnG8Pump.minorVersion = getByteToInt(bufferData) + + + aapsLogger.debug(LTag.PUMPCOMM, "Result --> ${diaconnG8Pump.result}") + aapsLogger.debug(LTag.PUMPCOMM, "country --> ${diaconnG8Pump.country}") + aapsLogger.debug(LTag.PUMPCOMM, "productType --> ${diaconnG8Pump.productType}") + aapsLogger.debug(LTag.PUMPCOMM, "makeYear --> ${diaconnG8Pump.makeYear}") + aapsLogger.debug(LTag.PUMPCOMM, "makeMonth --> ${diaconnG8Pump.makeMonth}") + aapsLogger.debug(LTag.PUMPCOMM, "makeDay --> ${diaconnG8Pump.makeDay}") + aapsLogger.debug(LTag.PUMPCOMM, "lotNo --> ${diaconnG8Pump.lotNo}") + aapsLogger.debug(LTag.PUMPCOMM, "serialNo --> ${diaconnG8Pump.serialNo}") + aapsLogger.debug(LTag.PUMPCOMM, "majorVersion --> ${diaconnG8Pump.majorVersion}") + aapsLogger.debug(LTag.PUMPCOMM, "minorVersion --> ${diaconnG8Pump.minorVersion}") + + sp.putString(rh.gs(R.string.pumpversion), diaconnG8Pump.majorVersion.toString() + "." + diaconnG8Pump.minorVersion.toString()) + } + + override fun getFriendlyName(): String { + return "PUMP_SERIAL_NUM_INQUIRE_RESPONSE" + } +} \ No newline at end of file diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeInquireResponsePacket.kt index 6b7882196c..a2f88429b5 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeInquireResponsePacket.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeInquireResponsePacket.kt @@ -15,24 +15,30 @@ class TimeInquireResponsePacket( @Inject lateinit var diaconnG8Pump: DiaconnG8Pump init { - msgType = 0x50.toByte() + msgType = 0x8F.toByte() aapsLogger.debug(LTag.PUMPCOMM, "TimeInquireResponsePacket init") } override fun handleMessage(data: ByteArray?) { - val result = defect(data) - if (result != 0) { + val defectCheck = defect(data) + if (defectCheck != 0) { aapsLogger.debug(LTag.PUMPCOMM, "TimeInquireResponsePacket Got some Error") failed = true return } else failed = false val bufferData = prefixDecode(data) - val result2 = getByteToInt(bufferData) - if(!isSuccInquireResponseResult(result2)) { + val result = getByteToInt(bufferData) + if(!isSuccInquireResponseResult(result)) { failed = true return } + diaconnG8Pump.year = getByteToInt(bufferData) + 2000 // 년 (18~99) + diaconnG8Pump.month = getByteToInt(bufferData) // 월 (1~12) + diaconnG8Pump.day = getByteToInt(bufferData) // 일 (1~31) + diaconnG8Pump.hour = getByteToInt(bufferData) // 시 (0~23) + diaconnG8Pump.minute = getByteToInt(bufferData) // 분 (0~59) + diaconnG8Pump.second = getByteToInt(bufferData) // 초 (0~59) } override fun getFriendlyName(): String { diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt index be2969ea4b..723d50752b 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt @@ -1,9 +1,13 @@ package info.nightscout.androidaps.diaconn.service +import android.Manifest +import android.annotation.SuppressLint import android.bluetooth.* import android.content.Context -import android.content.Intent +import android.content.pm.PackageManager +import android.os.Build import android.os.SystemClock +import androidx.core.app.ActivityCompat import dagger.android.HasAndroidInjector import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.diaconn.DiaconnG8Pump @@ -12,10 +16,11 @@ import info.nightscout.androidaps.diaconn.packet.* import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.extensions.notify import info.nightscout.androidaps.extensions.waitMillis +import info.nightscout.androidaps.interfaces.ResourceHelper +import info.nightscout.androidaps.plugins.bus.RxBus +import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBus -import info.nightscout.androidaps.interfaces.ResourceHelper import java.util.* import java.util.concurrent.ScheduledFuture import javax.inject.Inject @@ -31,9 +36,10 @@ class BLECommonService @Inject internal constructor( private val diaconnG8ResponseMessageHashTable: DiaconnG8ResponseMessageHashTable, private val diaconnG8SettingResponseMessageHashTable: DiaconnG8SettingResponseMessageHashTable, private val diaconnG8Pump: DiaconnG8Pump, -){ +) { companion object { + private const val WRITE_DELAY_MILLIS: Long = 50 private const val INDICATION_UUID = "6e400003-b5a3-f393-e0a9-e50e24dcca9e" private const val WRITE_UUID = "6e400002-b5a3-f393-e0a9-e50e24dcca9e" @@ -53,7 +59,7 @@ class BLECommonService @Inject internal constructor( private var uartIndicate: BluetoothGattCharacteristic? = null private var uartWrite: BluetoothGattCharacteristic? = null - private var mSequence : Int = 0 + private var mSequence: Int = 0 private fun getMsgSequence(): Int { val seq = mSequence % 255 @@ -66,6 +72,13 @@ class BLECommonService @Inject internal constructor( @Synchronized fun connect(from: String, address: String?): Boolean { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED + ) { + ToastUtils.errorToast(context, context.getString(info.nightscout.androidaps.core.R.string.needconnectpermission)) + aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from") + return false + } aapsLogger.debug(LTag.PUMPBTCOMM, "Initializing Bluetooth ") if (bluetoothAdapter == null) { aapsLogger.error("Unable to obtain a BluetoothAdapter.") @@ -98,6 +111,12 @@ class BLECommonService @Inject internal constructor( @Synchronized fun disconnect(from: String) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED + ) { + aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from") + return + } aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from") // cancel previous scheduled disconnection to prevent closing upcoming connection @@ -117,6 +136,7 @@ class BLECommonService @Inject internal constructor( SystemClock.sleep(2000) } + @SuppressLint("MissingPermission") @Synchronized fun close() { aapsLogger.debug(LTag.PUMPBTCOMM, "BluetoothAdapter close") @@ -133,13 +153,16 @@ class BLECommonService @Inject internal constructor( aapsLogger.debug(LTag.PUMPBTCOMM, "onServicesDiscovered") if (status == BluetoothGatt.GATT_SUCCESS) { findCharacteristic() + SystemClock.sleep(1600) + isConnected = true + isConnecting = false } } override fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic) { aapsLogger.debug(LTag.PUMPBTCOMM, "(응답) onCharacteristicChanged: " + DiaconnG8Packet.toHex(characteristic.value)) // 대량로그응답 처리. - if(characteristic.value[1] == 0xb2.toByte()) { + if (characteristic.value[1] == 0xb2.toByte()) { aapsLogger.debug(LTag.PUMPBTCOMM, "(대량 로그 처리 응답) onCharacteristicChanged: " + DiaconnG8Packet.toHex(characteristic.value)) val message = BigLogInquireResponsePacket(injector) message.handleMessage(characteristic.value) @@ -156,6 +179,7 @@ class BLECommonService @Inject internal constructor( } } + @SuppressLint("MissingPermission") @Synchronized private fun writeCharacteristicNoResponse(characteristic: BluetoothGattCharacteristic, data: ByteArray) { Thread(Runnable { @@ -194,6 +218,7 @@ class BLECommonService @Inject internal constructor( return bluetoothGatt?.services } + @SuppressLint("MissingPermission") @Synchronized private fun findCharacteristic() { val gattServices = getSupportedGattServices() ?: return @@ -206,6 +231,7 @@ class BLECommonService @Inject internal constructor( uartIndicate = gattCharacteristic //setCharacteristicNotification(uartIndicate, true) bluetoothGatt?.setCharacteristicNotification(uartIndicate, true) + // nRF Connect 참고하여 추가함 val descriptor: BluetoothGattDescriptor = uartIndicate!!.getDescriptor(UUID.fromString(CHARACTERISTIC_CONFIG_UUID)) descriptor.value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE @@ -218,13 +244,12 @@ class BLECommonService @Inject internal constructor( } } + @SuppressLint("MissingPermission") @Synchronized private fun onConnectionStateChangeSynchronized(gatt: BluetoothGatt, newState: Int) { aapsLogger.debug(LTag.PUMPBTCOMM, "onConnectionStateChange newState : $newState") if (newState == BluetoothProfile.STATE_CONNECTED) { gatt.discoverServices() - isConnected = true - isConnecting = false rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { close() @@ -250,7 +275,7 @@ class BLECommonService @Inject internal constructor( writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) // 요청 큐에 요청할 바이트 정보 담기. synchronized(mSendQueue) { - if(mSendQueue.size > 10) mSendQueue.clear() + if (mSendQueue.size > 10) mSendQueue.clear() mSendQueue.add(bytes) } aapsLogger.debug(LTag.PUMPBTCOMM, "sendMessage() after mSendQueue.size :: ${mSendQueue.size}") @@ -268,6 +293,7 @@ class BLECommonService @Inject internal constructor( // process common packet response private fun processResponseMessage(data: ByteArray) { isConnected = true + isConnecting = false //요청정보 val originalMessageSeq = processedMessage?.getSeq(processedMessageByte) @@ -281,44 +307,29 @@ class BLECommonService @Inject internal constructor( aapsLogger.debug(LTag.PUMPBTCOMM, "receivedCommand :: $receivedCommand") // 응답메시지가 조회응답인지. 설정응답인지 구분해야됨. - var message:DiaconnG8Packet? = null + var message: DiaconnG8Packet? = null // 요청시퀀스와 응답의 시퀀스가 동일한 경우에만 처리. // 펌프로부터 받은 보고응답의 경우 처리 - if(receivedType == 3) { + if (receivedType == 3) { message = diaconnG8ResponseMessageHashTable.findMessage(receivedCommand) // injection Blocked Report - if(message is InjectionBlockReportPacket ) { + if (message is InjectionBlockReportPacket) { message.handleMessage(data) diaconnG8Pump.bolusBlocked = true - val i = Intent(context, ErrorHelperActivity::class.java) - i.putExtra("soundid", R.raw.boluserror) - i.putExtra("status", rh.gs(R.string.injectionblocked)) - i.putExtra("title", rh.gs(R.string.injectionblocked)) - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - context.startActivity(i) + ErrorHelperActivity.runAlarm(context, rh.gs(R.string.injectionblocked), rh.gs(R.string.injectionblocked), R.raw.boluserror) return } // battery warning report - if(message is BatteryWarningReportPacket ) { + if (message is BatteryWarningReportPacket) { message.handleMessage(data) - val i = Intent(context, ErrorHelperActivity::class.java) - i.putExtra("soundid", R.raw.boluserror) - i.putExtra("status", rh.gs(R.string.needbatteryreplace)) - i.putExtra("title", rh.gs(R.string.batterywarning)) - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - context.startActivity(i) + ErrorHelperActivity.runAlarm(context, rh.gs(R.string.needbatteryreplace), rh.gs(R.string.batterywarning), R.raw.boluserror) return } // insulin lack warning report - if(message is InsulinLackReportPacket ) { + if (message is InsulinLackReportPacket) { message.handleMessage(data) - val i = Intent(context, ErrorHelperActivity::class.java) - i.putExtra("soundid", R.raw.boluserror) - i.putExtra("status", rh.gs(R.string.needinsullinreplace)) - i.putExtra("title", rh.gs(R.string.insulinlackwarning)) - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - context.startActivity(i) + ErrorHelperActivity.runAlarm(context, rh.gs(R.string.needinsullinreplace), rh.gs(R.string.insulinlackwarning), R.raw.boluserror) return } @@ -327,7 +338,7 @@ class BLECommonService @Inject internal constructor( synchronized(mSendQueue) { val sendQueueSize = mSendQueue.size if (sendQueueSize > 0) { - for (i in sendQueueSize-1 downTo 0 ) { + for (i in sendQueueSize - 1 downTo 0) { val sendQueueSeq = DiaconnG8Packet(injector).getSeq(mSendQueue[i]) val sendQueueType = DiaconnG8Packet(injector).getType(mSendQueue[i]) if (sendQueueSeq == receivedSeq) { diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt index 85e84d4b29..a2c0e2e4de 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt @@ -136,13 +136,14 @@ class DiaconnG8Service : DaggerService() { } private fun sendMessage(message: DiaconnG8Packet) { - bleCommonService.sendMessage(message, 2000) + bleCommonService.sendMessage(message, 5000) } fun readPumpStatus() { try { val pump = activePlugin.activePump rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpsettings))) + sendMessage(SerialNumInquirePacket(injector)) val pumpFirmwareVersion = sp.getString(rh.gs(R.string.pumpversion), "") @@ -170,6 +171,7 @@ class DiaconnG8Service : DaggerService() { // 시간 설정 rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumptime))) + sendMessage(TimeInquirePacket(injector)) var timeDiff = (diaconnG8Pump.getPumpTime() - System.currentTimeMillis()) / 1000L if (diaconnG8Pump.getPumpTime() == 0L) { // initial handshake was not successful @@ -239,14 +241,12 @@ class DiaconnG8Service : DaggerService() { } fun loadHistory(): PumpEnactResult { - if (!diaconnG8Plugin.isInitialized()) { val result = PumpEnactResult(injector).success(false) result.comment = "pump not initialized" return result } sendMessage(LogStatusInquirePacket(injector)) - // pump version check if (diaconnG8Pump.isPumpVersionGe2_63) { sendMessage(IncarnationInquirePacket(injector)) @@ -257,7 +257,7 @@ class DiaconnG8Service : DaggerService() { var apsWrappingCount = -1 // get saved last loginfo val diaconnHistoryRecord = diaconnHistoryRecordDao.getLastRecord(diaconnG8Pump.pumpUid) - aapsLogger.error(LTag.PUMPCOMM, "diaconnHistoryRecord :: $diaconnHistoryRecord") + aapsLogger.debug(LTag.PUMPCOMM, "diaconnHistoryRecord :: $diaconnHistoryRecord") if(diaconnHistoryRecord != null) { apsLastLogNum = diaconnHistoryRecord.lognum @@ -306,7 +306,6 @@ class DiaconnG8Service : DaggerService() { result.success(true) diaconnG8Pump.lastConnection = System.currentTimeMillis() } - // upload pump log to Diaconn Cloud if (sp.getBoolean(R.string.key_diaconn_g8_cloudsend, true)) { SystemClock.sleep(1000) @@ -399,13 +398,6 @@ class DiaconnG8Service : DaggerService() { fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean { if (!isConnected) return false if (BolusProgressDialog.stopPressed) return false - - // Only Carbs - if (carbs > 0 && insulin == 0.0) { - pumpSync.syncCarbsWithTimestamp(carbTime, carbs.toDouble(), null, PumpType.DIACONN_G8, diaconnG8Pump.serialNo.toString()) - return true - } - rxBus.send(EventPumpStatusChanged(rh.gs(R.string.startingbolus))) // bolus speed setting @@ -435,7 +427,7 @@ class DiaconnG8Service : DaggerService() { val bolusStart = System.currentTimeMillis() if (insulin > 0) { if (!diaconnG8Pump.bolusStopped) { - sendMessage(start) + sendMessage(start, 100) // otp process if (!processConfirm(start.msgType)) return false } else { @@ -460,26 +452,29 @@ class DiaconnG8Service : DaggerService() { } val bolusDurationInMSec = (insulin * speed * 1000).toLong() - val expectedEnd = bolusStart + bolusDurationInMSec + 7500L + val expectedEnd = bolusStart + bolusDurationInMSec + 3500L val totalwaitTime = (expectedEnd - System.currentTimeMillis()) / 1000 - while (!diaconnG8Pump.bolusDone) { - val waitTime = (expectedEnd - System.currentTimeMillis()) / 1000 - bolusingEvent.status = rh.gs(R.string.waitingforestimatedbolusend, if (waitTime < 0) 0 else waitTime) - var progressPecent = 0 - if (totalwaitTime > waitTime) { - progressPecent = ((totalwaitTime - waitTime) * 100 / totalwaitTime).toInt() + if(diaconnG8Pump.isReadyToBolus) { + while (!diaconnG8Pump.bolusDone) { + val waitTime = (expectedEnd - System.currentTimeMillis()) / 1000 + bolusingEvent.status = String.format(rh.gs(R.string.waitingforestimatedbolusend), if (waitTime < 0) 0 else waitTime) + var progressPecent = 0 + if (totalwaitTime > waitTime) { + progressPecent = ((totalwaitTime - waitTime) * 100 / totalwaitTime).toInt() + } + bolusingEvent.percent = min(progressPecent, 100) + rxBus.send(bolusingEvent) + SystemClock.sleep(200) } - bolusingEvent.percent = min(progressPecent, 100) - rxBus.send(bolusingEvent) - SystemClock.sleep(200) } + diaconnG8Pump.isReadyToBolus = false // do not call loadHistory() directly, reconnection may be needed commandQueue.loadEvents(object : Callback() { override fun run() { // reread bolus status rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingbolusstatus))) - sendMessage(InjectionSnackInquirePacket(injector), 1000) // last bolus + sendMessage(InjectionSnackInquirePacket(injector), 2000) // last bolus // 볼러스 결과 보고패킷에서 처리함. bolusingEvent.percent = 100 rxBus.send(EventPumpStatusChanged(rh.gs(R.string.disconnecting))) @@ -492,7 +487,7 @@ class DiaconnG8Service : DaggerService() { val stop = InjectionCancelSettingPacket(injector, 0x07.toByte()) diaconnG8Pump.bolusStopForced = true if (isConnected) { - sendMessage(stop) + sendMessage(stop, 100) // otp process if (!processConfirm(stop.msgType)) return while (!diaconnG8Pump.bolusStopped) { @@ -513,7 +508,7 @@ class DiaconnG8Service : DaggerService() { rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal))) val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio) // tempbasal stop - sendMessage(msgPacket) + sendMessage(msgPacket, 100) // otp process if (!processConfirm(msgPacket.msgType)) return false diaconnG8Pump.tempBasalStart = dateUtil.now() @@ -521,7 +516,7 @@ class DiaconnG8Service : DaggerService() { rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal))) val tbInjectRate = ((absoluteRate * 100) + 1000).toInt() val msgTBR = TempBasalSettingPacket(injector, 1, ((durationInHours * 60) / 15).toInt(), tbInjectRate) - sendMessage(msgTBR) + sendMessage(msgTBR, 100) // otp process if (!processConfirm(msgTBR.msgType)) return false // pump tempbasal status inquire @@ -545,7 +540,7 @@ class DiaconnG8Service : DaggerService() { rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal))) val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio) // tempbasal stop - sendMessage(msgPacket) + sendMessage(msgPacket, 100) // otp process if (!processConfirm(msgPacket.msgType)) return false SystemClock.sleep(500) @@ -553,7 +548,7 @@ class DiaconnG8Service : DaggerService() { rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal))) val tbInjectRate = absoluteRate * 100 + 1000 val msgTBR = TempBasalSettingPacket(injector, 1, 2, tbInjectRate.toInt()) - sendMessage(msgTBR) + sendMessage(msgTBR, 100) // otp process if (!processConfirm(msgTBR.msgType)) return false sendMessage(TempBasalInquirePacket(injector)) @@ -577,7 +572,7 @@ class DiaconnG8Service : DaggerService() { diaconnG8Pump.tbInjectRateRatio ) // tempbasal stop - sendMessage(msgPacket) + sendMessage(msgPacket, 500) // otp process if (!processConfirm(msgPacket.msgType)) return false SystemClock.sleep(500) @@ -593,7 +588,7 @@ class DiaconnG8Service : DaggerService() { fun extendedBolus(insulin: Double, durationInMinutes: Int): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingextendedbolus))) - aapsLogger.error(LTag.PUMPCOMM, "insulin: $insulin durationInMinutes: $durationInMinutes") + aapsLogger.debug(LTag.PUMPCOMM, "insulin: $insulin durationInMinutes: $durationInMinutes") val msgExtended = InjectionExtendedBolusSettingPacket(injector, (insulin * 100).toInt(), durationInMinutes, dateUtil.now()) sendMessage(msgExtended) @@ -672,6 +667,7 @@ class DiaconnG8Service : DaggerService() { (basalList[23] * 100).toInt() ) // setting basal pattern 1,2,3,4 + sendMessage(SerialNumInquirePacket(injector), 2000) sendMessage(requestReqPacket1, 500) sendMessage(requestReqPacket2, 500) sendMessage(requestReqPacket3, 500) @@ -694,22 +690,22 @@ class DiaconnG8Service : DaggerService() { private fun processConfirm(msgType: Byte): Boolean { // pump confirm + var loopCnt = 0 + // waiting 2 seconds for otp + while(loopCnt < 20) { + if (diaconnG8Pump.otpNumber == 0) { + SystemClock.sleep(100) + aapsLogger.error(LTag.PUMPCOMM, "OTP waiting 100ms $loopCnt / 20") + } + loopCnt++ + } + // after 2 second if (diaconnG8Pump.otpNumber == 0) { aapsLogger.error(LTag.PUMPCOMM, "otp is not received yet") - - // Comments are made as dialogs are exposed twice each in the event of an error. - // Thread { - // val i = Intent(context, ErrorHelperActivity::class.java) - // i.putExtra("soundid", R.raw.boluserror) - // i.putExtra("status", rh.gs(R.string.diaconn_g8_errotpreceivedyet)) - // i.putExtra("title", rh.gs(R.string.pumperror)) - // i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - // context.startActivity(i) - // }.start() - return false } - sendMessage(AppConfirmSettingPacket(injector, msgType, diaconnG8Pump.otpNumber)) + diaconnG8Pump.bolusConfirmMessage = msgType + sendMessage(AppConfirmSettingPacket(injector, msgType, diaconnG8Pump.otpNumber), 2000) diaconnG8Pump.otpNumber = 0 return true } diff --git a/diaconn/src/main/res/values/strings.xml b/diaconn/src/main/res/values/strings.xml index f74b46b0af..ea014d7ef3 100644 --- a/diaconn/src/main/res/values/strings.xml +++ b/diaconn/src/main/res/values/strings.xml @@ -169,5 +169,5 @@ Tempbasal stop is rejected when tempbasal is not running Send pump logs to the Diaconn Cloud. Diaconn Cloud Sync - diaconn_g8_appuid + diaconn_g8_appuid diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java index 114dbdbe62..760852ff1c 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java @@ -1,16 +1,20 @@ package info.nightscout.androidaps.plugins.pump.insight.connection_service; +import android.Manifest; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothSocket; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Binder; +import android.os.Build; import android.os.IBinder; import android.os.PowerManager; import androidx.annotation.Nullable; +import androidx.core.app.ActivityCompat; import org.spongycastle.crypto.InvalidCipherTextException; @@ -23,8 +27,6 @@ import javax.inject.Inject; import dagger.android.DaggerService; import info.nightscout.androidaps.insight.R; -import info.nightscout.shared.logging.AAPSLogger; -import info.nightscout.shared.logging.LTag; import info.nightscout.androidaps.plugins.pump.insight.app_layer.AppLayerMessage; import info.nightscout.androidaps.plugins.pump.insight.app_layer.ReadParameterBlockMessage; import info.nightscout.androidaps.plugins.pump.insight.app_layer.configuration.CloseConfigurationWriteSessionMessage; @@ -87,6 +89,8 @@ import info.nightscout.androidaps.plugins.pump.insight.utils.PairingDataStorage; import info.nightscout.androidaps.plugins.pump.insight.utils.crypto.Cryptograph; import info.nightscout.androidaps.plugins.pump.insight.utils.crypto.DerivedKeys; import info.nightscout.androidaps.plugins.pump.insight.utils.crypto.KeyPair; +import info.nightscout.shared.logging.AAPSLogger; +import info.nightscout.shared.logging.LTag; import info.nightscout.shared.sharedPreferences.SP; public class InsightConnectionService extends DaggerService implements ConnectionEstablisher.Callback, InputStreamReader.Callback, OutputStreamWriter.Callback { @@ -108,7 +112,7 @@ public class InsightConnectionService extends DaggerService implements Connectio private DelayedActionThread disconnectTimer; private DelayedActionThread recoveryTimer; private DelayedActionThread timeoutTimer; - private BluetoothAdapter bluetoothAdapter; + @Nullable private BluetoothAdapter bluetoothAdapter; private BluetoothDevice bluetoothDevice; private BluetoothSocket bluetoothSocket; private ConnectionEstablisher connectionEstablisher; @@ -258,7 +262,9 @@ public class InsightConnectionService extends DaggerService implements Connectio @Override public synchronized void onCreate() { super.onCreate(); - bluetoothAdapter = ((BluetoothManager)getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { + bluetoothAdapter = ((BluetoothManager) getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); + } pairingDataStorage = new PairingDataStorage(this); state = pairingDataStorage.isPaired() ? InsightState.DISCONNECTED : InsightState.NOT_PAIRED; wakeLock = ((PowerManager) getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:InsightConnectionService"); @@ -426,6 +432,7 @@ public class InsightConnectionService extends DaggerService implements Connectio } private synchronized void connect() { + if (bluetoothAdapter == null) return; if (bluetoothDevice == null) bluetoothDevice = bluetoothAdapter.getRemoteDevice(pairingDataStorage.getMacAddress()); setState(InsightState.CONNECTING); diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt index dd43c9bf3f..551a06f862 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt @@ -341,6 +341,7 @@ class MedtronicPumpPlugin @Inject constructor( val refreshTypesNeededToReschedule: MutableSet = mutableSetOf() for ((key, value) in statusRefresh) { if (value > 0 && System.currentTimeMillis() > value) { + @Suppress("WHEN_ENUM_CAN_BE_NULL_IN_JAVA") when (key) { MedtronicStatusRefreshType.PumpHistory -> { readPumpHistory() diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt index e88d3de97f..8d86bce696 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt @@ -18,20 +18,17 @@ object MedtronicConst { val BolusDelay = R.string.key_medtronic_bolus_delay val Encoding = R.string.key_medtronic_encoding val BatteryType = R.string.key_medtronic_battery_type - val BolusDebugEnabled = R.string.key_medtronic_bolus_debug } object Statistics { - const val StatsPrefix = "medtronic_" + private const val StatsPrefix = "medtronic_" const val FirstPumpStart = Prefix + "first_pump_use" const val LastGoodPumpCommunicationTime = Prefix + "lastGoodPumpCommunicationTime" - const val LastGoodPumpFrequency = Prefix + "LastGoodPumpFrequency" const val TBRsSet = StatsPrefix + "tbrs_set" const val StandardBoluses = StatsPrefix + "std_boluses_delivered" const val SMBBoluses = StatsPrefix + "smb_boluses_delivered" const val LastPumpHistoryEntry = StatsPrefix + "pump_history_entry" const val LastPrime = StatsPrefix + "last_sent_prime" const val LastRewind = StatsPrefix + "last_sent_rewind" - const val InternalTemporaryDatabase = StatsPrefix + "temporary_entries" } } \ No newline at end of file diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java index f4c1bb19c7..f1c8882213 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java @@ -46,6 +46,7 @@ import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; +import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.schedule.BasalSchedule; import info.nightscout.shared.logging.AAPSLogger; import info.nightscout.shared.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBus; @@ -628,8 +629,9 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley if (!podStateManager.isPodRunning()) { return 0.0d; } - - return podStateManager.getBasalSchedule().rateAt(TimeUtil.toDuration(DateTime.now())); + BasalSchedule schedule = podStateManager.getBasalSchedule(); + if (schedule != null) return schedule.rateAt(TimeUtil.toDuration(DateTime.now())); + else return 0; } @Override diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/ui/PumpBLEConfigActivity.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/ui/PumpBLEConfigActivity.kt index 6333af2cc2..db19107d75 100755 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/ui/PumpBLEConfigActivity.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/ui/PumpBLEConfigActivity.kt @@ -133,7 +133,7 @@ class PumpBLEConfigActivity : DaggerAppCompatActivity() { aapsLogger.debug(TAG, "Device can be detected near, so trying to remove bond if possible.") bleSelector.removeDevice(bluetoothDevice!!) } else { - val remoteDevice = bluetoothAdapter!!.getRemoteDevice(deviceAddress) + val remoteDevice = bluetoothAdapter?.getRemoteDevice(deviceAddress) if (remoteDevice != null) { bleSelector.removeDevice(remoteDevice) } @@ -184,7 +184,7 @@ class PumpBLEConfigActivity : DaggerAppCompatActivity() { } private fun prepareForScanning() { - bleScanner = bluetoothAdapter!!.bluetoothLeScanner + bleScanner = bluetoothAdapter?.bluetoothLeScanner settings = bleSelector.getScanSettings() filters = bleSelector.getScanFilters() } @@ -243,7 +243,7 @@ class PumpBLEConfigActivity : DaggerAppCompatActivity() { binding.pumpBleConfigButtonScanStop.visibility = View.VISIBLE } scanning = true - bleScanner!!.startScan(filters, settings, bleScanCallback) + bleScanner?.startScan(filters, settings, bleScanCallback) aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start") bleSelector.onStartLeDeviceScan(this@PumpBLEConfigActivity) } @@ -251,7 +251,7 @@ class PumpBLEConfigActivity : DaggerAppCompatActivity() { private fun stopLeDeviceScan(manualStop: Boolean) { if (scanning) { scanning = false - bleScanner!!.stopScan(bleScanCallback) + bleScanner?.stopScan(bleScanCallback) aapsLogger.debug(LTag.PUMPBTCOMM, "stopLeDeviceScan: Scanning Stop") bleSelector.onStopLeDeviceScan(this@PumpBLEConfigActivity) handler.removeCallbacks(stopScanAfterTimeoutRunnable) @@ -320,8 +320,8 @@ class PumpBLEConfigActivity : DaggerAppCompatActivity() { if (currentlySelectedAddress == device.address) { deviceName += " (" + resources.getString(R.string.ble_config_scan_selected) + ")" } - holder.deviceName!!.text = deviceName - holder.deviceAddress!!.text = device.address + holder.deviceName?.text = deviceName + holder.deviceAddress?.text = device.address return v!! } } diff --git a/pump-common/src/main/res/layout/pump_history_activity.xml b/pump-common/src/main/res/layout/pump_history_activity.xml index e5f3c4a1c7..0202071a6f 100755 --- a/pump-common/src/main/res/layout/pump_history_activity.xml +++ b/pump-common/src/main/res/layout/pump_history_activity.xml @@ -29,7 +29,7 @@ android:textAppearance="?android:attr/textAppearanceSmall" /> + Operasie nog nie ondersteun deur pomp. diff --git a/pump-common/src/main/res/values-bg-rBG/strings.xml b/pump-common/src/main/res/values-bg-rBG/strings.xml index 33c77af761..6d8edea0a3 100644 --- a/pump-common/src/main/res/values-bg-rBG/strings.xml +++ b/pump-common/src/main/res/values-bg-rBG/strings.xml @@ -1,11 +1,39 @@ + Помпата не поддържа тази операция. + Операцията не се поддържа от помпата (ВСЕ ОЩЕ). + ОК + Събуждане + Грешка в комуникацията + Изтече времето за връзка + Помпата е недостъпна + Грешна конфигурация + Активна + Спинка си + Базали + Конфигурации + Известия + Статистика + Неизвестни + Всички + Болуси + Пълнене + Аларми + Кръвна захар + + %1$d ден + %1$d дни + + + %1$d часа + %1$d часа + diff --git a/pump-common/src/main/res/values-ca-rES/strings.xml b/pump-common/src/main/res/values-ca-rES/strings.xml index 33c77af761..9c30e430ff 100644 --- a/pump-common/src/main/res/values-ca-rES/strings.xml +++ b/pump-common/src/main/res/values-ca-rES/strings.xml @@ -1,11 +1,37 @@ + Operació no compatible amb la bomba i/o controlador. + Operació no compatible ENCARA amb la bomba. + Iniciant + Error de comunicació + Temps d\'espera excedit en la comunicació + Bomba no accessible + Configuració no vàlida + Activa + En suspens + Basals + Configuracions + Avisos + Estadístiques + Desconeguts + Tots + Bolus + Encebaments + Alarmes + + %1$d dia + %1$d dies + + + %1$d hora + %1$d hores + diff --git a/pump-common/src/main/res/values-da-rDK/strings.xml b/pump-common/src/main/res/values-da-rDK/strings.xml index 33c77af761..cdd499a65b 100644 --- a/pump-common/src/main/res/values-da-rDK/strings.xml +++ b/pump-common/src/main/res/values-da-rDK/strings.xml @@ -8,4 +8,12 @@ + + %1$d dag + %1$d dage + + + %1$d time + %1$d timer + diff --git a/pump-common/src/main/res/values-de-rDE/strings.xml b/pump-common/src/main/res/values-de-rDE/strings.xml index 33c77af761..7c01b0163d 100644 --- a/pump-common/src/main/res/values-de-rDE/strings.xml +++ b/pump-common/src/main/res/values-de-rDE/strings.xml @@ -1,11 +1,39 @@ + Aktion von Pumpe und/oder Treiber nicht unterstützt. + Operation NOCH NICHT von Pumpe unterstützt. + OK + Aufwecken + Fehler bei der Kommunikation + Zeitüberschreitung bei Kommunikation + Pumpe nicht erreichbar + Ungültige Einstellung + Aktiv + Schlafen + Basal + Konfigurationen + Benachrichtigungen + Statistiken + Unbekannte + Alle + Boli + Füllen + Alarme + Glukose + + %1$d Tag + %1$d Tage + + + %1$d Stunde + %1$d Stunden + diff --git a/pump-common/src/main/res/values-el-rGR/strings.xml b/pump-common/src/main/res/values-el-rGR/strings.xml index 33c77af761..11a7c88fb4 100644 --- a/pump-common/src/main/res/values-el-rGR/strings.xml +++ b/pump-common/src/main/res/values-el-rGR/strings.xml @@ -1,6 +1,7 @@ + Η λειτουργία δεν υποστηρίζεται ΑΚΟΜΑ από την αντλία. diff --git a/pump-common/src/main/res/values-es-rES/strings.xml b/pump-common/src/main/res/values-es-rES/strings.xml index b138c249cc..24850a5c07 100644 --- a/pump-common/src/main/res/values-es-rES/strings.xml +++ b/pump-common/src/main/res/values-es-rES/strings.xml @@ -4,6 +4,7 @@ Operación no soportada por la bomba y/o por el controlador. Operación no soportada todavía por la bomba. OK + Número de serie de la bomba Nunca contactado En fase de inicio @@ -13,6 +14,13 @@ Configuración inválida Activo Suspendida + No Inicializado + Inicializado + Encriptando comunicación + Preparado + Ocupado + Suspendido + Ejecutando comando Basales Configuraciones @@ -24,9 +32,59 @@ Cebado Alarmas Glucosa + Base + Otro + Todos los Eventos + Eventos (sin estadísticas) + Hoy + Última hora + Últimas 3 horas + Últimas 6 horas + Últimas 12 horas + Últimos 2 días + Últimos 4 días + Última semana + Último mes + Escanear + Parar + Seleccionado + Escaneando + Escaneo finalizado + Error escaneando: %1$d + Nunca + Eliminar + Bluetooth desactivado + No hay adaptador Bluetooth + Bomba configurada no encontrada + Bomba inalcanzable + Error al conectar al dispositivo BLE + Encriptación fallida + Encontrada bomba no vinculada + La configuración de perfiles basales no está habilitada en la bomba. Habilítalo en la bomba. + El perfil basal establecido en la bomba es incorrecto (debe ser %s). + EL TBR establecido en la bomba es incorrecto (debe ser %s). + El máximo bolo establecido en la bomba es incorrecto (debe ser %1$.2f), + La basal máxima establecida en la bomba es incorrecta (debe ser %1$.2f). + Tipo: + + %1$d día + %1$d días + + + %1$d hora + %1$d horas + + + Hace %1$d hora + Hace %1$d horas + + + Hace %1$d día + Hace %1$d días + diff --git a/pump-common/src/main/res/values-fr-rFR/strings.xml b/pump-common/src/main/res/values-fr-rFR/strings.xml index 557d7cb0aa..5a8c14e3e7 100644 --- a/pump-common/src/main/res/values-fr-rFR/strings.xml +++ b/pump-common/src/main/res/values-fr-rFR/strings.xml @@ -4,6 +4,7 @@ Opération non prise en charge par la pompe et/ou le pilote. Opération PAS ENCORE supportée par la pompe. OK + Numéro de série de la pompe Jamais contacté Réveil en cours @@ -13,6 +14,13 @@ Configuration invalide Actif En veille + Non initialisé + Initialisé + Cryptage de la communication + Prêt + Occupé + Suspendu + Exécution de la commande Basales Configurations @@ -24,9 +32,59 @@ Amorcer Alarmes Glycémie + Base + Autre + Tous les événements + Événements (sans stat) + Aujourd’hui + Dernière heure + 3 dernières heures + 6 dernières heures + 12 dernières heures + 2 derniers jours + 4 derniers jours + Dernière semaine + Mois dernier + Scanner + Arrêter + Sélectionné + Recherche en cours + Recherche terminée + Erreur de scan : %1$d + Jamais + Supprimer + Bluetooth désactivé + Aucun adaptateur Bluetooth + Pompe configurée introuvable + Pompe hors de portée + Échec de la connexion à l’appareil BLE + Echec du cryptage + Pas de pompe appairée trouvée + Le réglage des profils de basal n\'est pas activé sur la pompe. Activez-le sur la pompe. + Le profil Basal défini sur la pompe est incorrect (doit être %s). + Mauvais type DBT (TBR) réglé sur la pompe (doit être %s). + Mauvais paramètre Max Bolus sur la pompe (doit être %1$.2f). + Mauvais paramètre Max Basal sur la pompe (doit être %1$.2f). + Type : + + %1$d jour + %1$d jours + + + %1$d heure + %1$d heures + + + Il y a %1$d heure + Il y a %1$d heures + + + Il y a %1$d jour + Il y a %1$d jours + diff --git a/pump-common/src/main/res/values-ga-rIE/strings.xml b/pump-common/src/main/res/values-ga-rIE/strings.xml index 33c77af761..6bf78d23ab 100644 --- a/pump-common/src/main/res/values-ga-rIE/strings.xml +++ b/pump-common/src/main/res/values-ga-rIE/strings.xml @@ -1,8 +1,15 @@ + Ceart go leor + Gníomhach + Bunaidhi + Ar fad + Bólasi + Aláraim + Glúcóis diff --git a/pump-common/src/main/res/values-hu-rHU/strings.xml b/pump-common/src/main/res/values-hu-rHU/strings.xml index 33c77af761..9453621bea 100644 --- a/pump-common/src/main/res/values-hu-rHU/strings.xml +++ b/pump-common/src/main/res/values-hu-rHU/strings.xml @@ -8,4 +8,12 @@ + + %1$d nap + %1$d nap + + + %1$d óra + %1$d óra + diff --git a/pump-common/src/main/res/values-it-rIT/strings.xml b/pump-common/src/main/res/values-it-rIT/strings.xml index 2ba2c4ef21..010278c8ce 100644 --- a/pump-common/src/main/res/values-it-rIT/strings.xml +++ b/pump-common/src/main/res/values-it-rIT/strings.xml @@ -4,6 +4,7 @@ Operazione non supportata dal micro e/o dal driver. Operazione NON ANCORA supportata dal micro. OK + Numero seriale micro Mai connesso Risveglio @@ -13,6 +14,13 @@ Configurazione non valida Attivo In sospensione + Non inizializzato + Inizializzato + Comunicazione crittata + Pronto + Occupato + Sospeso + Eseguzione comando Basali Configurazioni @@ -24,9 +32,59 @@ Caricamento Allarmi Glicemia + Base + Altro + Tutti gli eventi + Eventi (no stat) + Oggi + Ultima ora + Ultime 3 ore + Ultime 6 ore + Ultime 12 ore + Ultimi 2 giorni + Ultimi 4 giorni + Ultima settimana + Ultimo mese + Scansione + Stop + Selezionato + Scansione + Scansione terminata + Errore scansione: %1$d + Mai + Rimuovi + Bluetooth disabilitato + Nessun trasmettitore bluetooth + Micro configurato non trovato + Micro irraggiungibile + Impossibile connettersi al dispositivo BLE + Crittografia fallita + Trovato micro non collegato + L\'impostazione di modelli/profili basali non è abilitata sul micro. Abilitarla. + Il profilo basale impostato sul micro non è corretto (deve essere %s). + Il tipo di TBR impostato sul micro è errato (deve essere %s). + Il bolo massimo impostato sul micro è errato (deve essere %1$.2f). + La basale massima impostata sul micro è errata (deve essere %1$.2f). + Tipo: + + %1$d giorno + %1$d giorni + + + %1$d ora + %1$d ore + + + %1$d ora fa + %1$d ore fa + + + %1$d giorno fa + %1$d giorni fa + diff --git a/pump-common/src/main/res/values-iw-rIL/strings.xml b/pump-common/src/main/res/values-iw-rIL/strings.xml index da2dfd704a..5142e46ea1 100644 --- a/pump-common/src/main/res/values-iw-rIL/strings.xml +++ b/pump-common/src/main/res/values-iw-rIL/strings.xml @@ -4,6 +4,7 @@ הפעולה לא נתמכת ע\"י המשאבה ו\\או מנהל ההתקן. הפעולה עוד לא נתמכת על ידי המשאבה. אישור + המספר הסידורי של המשאבה מעולם לא נוצר קשר מתעורר @@ -13,6 +14,13 @@ תצורה לא חוקית פעיל שינה + לא מאותחל + מאותחל + מצפין תקשורת + מוכן + עסוק + מושהה + מבצע פקודה בזאלים תצורות @@ -24,9 +32,67 @@ תיחול התראות גלוקוז + בסיס + אחר + כל האירועים + אירועים(ללא סטטיסטיקה) + היום + בשעה האחרונה + ב-3 השעות האחרונות + ב-6 השעות האחרונות + ב-12 השעות האחרונות + ביומיים אחרונים + ב-4 הימים האחרונים + בשבוע שעבר + בחודש שעבר + סריקה + עצור + נבחר + סורק + הסריקה הושלמה + שגיאת סריקה: %1$d + אף פעם + הסרה + בלוטות\' כבוי + אין מתאם בלוטות\' + לא נמצאה משאבה מוגדרת + המשאבה אינה זמינה + נכשל החיבור למכשיר בלוטות\' + ההצפנה נכשלה + נמצאה משאבה שאינה מצומדת + הגדרת פרופילי הבזאלי\\תבניות אינה מאופשרת במשאבה. הפעילו אותן בגוף המשאבה. + הפרופיל הבזאלי שהוגדר במשאבה שגוי (חייב להיות %s). + סוג הבזאלי הזמני שהוגדר במשאבה שגוי (חייב להיות %s). + מינון הבולוס המרבי המוגדר במשאבה אינו נכון (חייב להיות %1$.2f). + המינון הבזאלי המרבי המוגדר במשאבה אינו נכון (חייב להיות %1$.2f). + סוג: + + יום %1$d + יומיים + %1$d ימים + %1$d ימים + + + שעה + שעתיים + %1$d שעות + %1$d שעות + + + לפני שעה + לפני שעתיים + לפני %1$d שעות + לפני %1$d שעות + + + לפני יום אחד + לפני יומיים + לפני %1$d ימים + לפני %1$d ימים + diff --git a/pump-common/src/main/res/values-ko-rKR/strings.xml b/pump-common/src/main/res/values-ko-rKR/strings.xml index 33c77af761..e247034563 100644 --- a/pump-common/src/main/res/values-ko-rKR/strings.xml +++ b/pump-common/src/main/res/values-ko-rKR/strings.xml @@ -1,6 +1,7 @@ + 펌프에서 지원되지 않는 작동. @@ -8,4 +9,10 @@ + + %1$d 일 + + + %1$d 시간 + diff --git a/pump-common/src/main/res/values-lt-rLT/strings.xml b/pump-common/src/main/res/values-lt-rLT/strings.xml index 33c77af761..84e1d1c00b 100644 --- a/pump-common/src/main/res/values-lt-rLT/strings.xml +++ b/pump-common/src/main/res/values-lt-rLT/strings.xml @@ -1,11 +1,43 @@ + Pompa ir/ar jos valdiklis nepalaiko operacijos. + Pompa dar nepalaiko operacijos. + Gerai + Pažadinimas + Ryšio klaida + Ryšiui skirtas laikas baigėsi + Pompa nepasiekiama + Neteisinga konfigūracija + Aktyvi + Užmigusi + Bazė + Nustatymai + Pranešimai + Statistika + Nežinoma + Visi + Bolusai + Užpildyti sistemą + Aliarmai + Gliukozė + + %1$d d. + %1$d d. + %1$d d. + %1$d d. + + + %1$d val. + %1$d val. + %1$d val. + %1$d val. + diff --git a/pump-common/src/main/res/values-no-rNO/strings.xml b/pump-common/src/main/res/values-no-rNO/strings.xml index 23b42b2961..560538d7cb 100644 --- a/pump-common/src/main/res/values-no-rNO/strings.xml +++ b/pump-common/src/main/res/values-no-rNO/strings.xml @@ -4,6 +4,7 @@ Operasjonen støttes ikke av pumpen og/eller driveren. Operasjonen støttes ikke av pumpen ennå. OK + Pumpens serienummer Aldri kontaktet Våkner opp @@ -13,6 +14,13 @@ Ugyldig oppsett av pumpe Aktiv Hvilemodus + Pumpen er ikke startet + Pumpen er startet + Krypterer kommunikasjon + Klar + Opptatt + Pauset + Utfører kommando Basaldoser Konfigurasjoner @@ -24,9 +32,59 @@ Prime Alarmer Blodsukker + Utgangspunkt + Annet + Alle hendelser + Hendelser (ingen stat.) + I dag + Siste time + Siste 3 timer + Siste 6 timer + Siste 12 timer + Siste 2 dager + Siste 4 dager + Siste uke + Siste måned + Søk + Stopp + Valgt + Søker + Søk fullført + Søk feilet: %1$d + Aldri + Fjern + Bluetooth deaktivert + Ingen Bluetooth adapter + Konfigurert pumpe ikke funnet + Pumpe utilgjengelig + Kunne ikke koble til Bluetooth-enhet + Kryptering feilet + Fant pumpe som ikke er tilkoblet + Basal-profil/program er ikke aktivert på pumpen. Aktiver det på pumpen. + Basal-profil som er satt på pumpen er feil (må være %s). + Feil TBR-type er valgt på pumpen (må være %s). + Feil maks-bolus er satt på pumpen (må være %1$.2f). + Feil maks-basal er satt på pumpen (må være %1$.2f). + Type: + + %1$d dag + %1$d dager + + + %1$d time + %1$d timer + + + %1$d time siden + %1$d timer siden + + + %1$d dag siden + %1$d dager siden + diff --git a/pump-common/src/main/res/values-pl-rPL/strings.xml b/pump-common/src/main/res/values-pl-rPL/strings.xml index 33c77af761..b306d45c6e 100644 --- a/pump-common/src/main/res/values-pl-rPL/strings.xml +++ b/pump-common/src/main/res/values-pl-rPL/strings.xml @@ -3,9 +3,22 @@ + Napełnianie + + %1$d dzień + %1$d dni + %1$d dni + %1$d dni + + + %1$d godzina + %1$d godziny + %1$d godzin + %1$d godzin + diff --git a/pump-common/src/main/res/values-pt-rBR/strings.xml b/pump-common/src/main/res/values-pt-rBR/strings.xml index 33c77af761..770dc80acb 100644 --- a/pump-common/src/main/res/values-pt-rBR/strings.xml +++ b/pump-common/src/main/res/values-pt-rBR/strings.xml @@ -1,6 +1,7 @@ + Operação não suportada ainda pela Bomba. diff --git a/pump-common/src/main/res/values-pt-rPT/strings.xml b/pump-common/src/main/res/values-pt-rPT/strings.xml index 33c77af761..77bc7ca340 100644 --- a/pump-common/src/main/res/values-pt-rPT/strings.xml +++ b/pump-common/src/main/res/values-pt-rPT/strings.xml @@ -1,11 +1,39 @@ + Operação não suportada pela Bomba e/ou Controlador. + Operação não suportada ainda pela Bomba. + OK + A acordar + Erro com comunicação + Tempo limite para comunicação + Bomba inacessível + Configuração inválida + Activo + A dormir + Basais + Configurações + Notificações + Estatísticas + Desconhecido + Tudo + Bólus + Purgar + Alarmes + Glucose + + %1$d dia + %1$d dias + + + %1$d hora + %1$d horas + diff --git a/pump-common/src/main/res/values-ro-rRO/strings.xml b/pump-common/src/main/res/values-ro-rRO/strings.xml index 33c77af761..5ef0652d1d 100644 --- a/pump-common/src/main/res/values-ro-rRO/strings.xml +++ b/pump-common/src/main/res/values-ro-rRO/strings.xml @@ -1,11 +1,41 @@ + Operațiunea nu este suportată de către pompă și/sau driver. + Operațiunea nu este ÎNCĂ suportată de către pompă. + OK + Se pornește + Eroare de comunicație + Comunicația nu a reușit la timp + Pompă indisponibilă + Configurație invalidă + Activă + În repaus + Bazale + Configurații + Notificări + Statistici + Necunoscute + Toate + Bolusuri + Amorsare + Alarme + Glicemie + + %1$d zi + %1$d zile + %1$d zile + + + %1$d oră + %1$d ore + %1$d ore + diff --git a/pump-common/src/main/res/values-ru-rRU/strings.xml b/pump-common/src/main/res/values-ru-rRU/strings.xml index 40bedc7d07..37c54b6fa4 100644 --- a/pump-common/src/main/res/values-ru-rRU/strings.xml +++ b/pump-common/src/main/res/values-ru-rRU/strings.xml @@ -4,6 +4,7 @@ Операция не поддерживается помпой и/или драйвером. Операция ЕЩЕ не поддерживается помпой. OK + Серийный номер помпы Никогда не подключалась Пробуждение @@ -13,6 +14,13 @@ Недопустимая конфигурация Работает Спящий режим + Нет инициализации + Инициализировано + Шифрование коммуникации + Помпа готова + Обработка + Помпа остановлена + Выполнение команды Базалы Конфигурации @@ -24,9 +32,67 @@ Заполнение Оповещения Гликемия + База + Другое + Все события + События (без статистики) + Сегодня + За прошедший час + За прошедшие 3 часа + За прошедшие 6 часов + За прошедшие 12 часов + За прошедшие 2 дня + За прошедшие 4 дня + За прошедшую неделю + За прошлый месяц + Сканирование + Прервать + Выбрано + Сканирование + Сканирование завершено + Ошибка сканирования: %1$d + Не было + Удалить + Bluetooth выключен + Адаптер Bluetooth не найден + Сконфигурированная помпа не найдена + Помпа недоступна + Не удалось подключиться к устройству BLE + Ошибка шифрования + Найдена несопряженная помпа + Базальные профили/настройки шаблонов не активированы в помпе. Включите их на помпе. + Базальный профиль на помпе неверен (должен быть %s). + Неверный тип временной скорости базала TBR на помпе (должен быть %s). + На помпе задан неверный макс болюс (должен быть %1$.2f). + На помпе задан неверный макс базал (должен быть %1$.2f). + Тип: + + %1$d день + %1$d дня + %1$d дней + %1$d дн + + + %1$d час + %1$d часа + %1$d часов + %1$d ч + + + %1$d час назад + %1$d часа назад + %1$d часов назад + %1$d ч назад + + + %1$d день назад + %1$d дня назад + %1$d дней назад + %1$d дн назад + diff --git a/pump-common/src/main/res/values-sk-rSK/strings.xml b/pump-common/src/main/res/values-sk-rSK/strings.xml index 2c707642f5..f0498d6f86 100644 --- a/pump-common/src/main/res/values-sk-rSK/strings.xml +++ b/pump-common/src/main/res/values-sk-rSK/strings.xml @@ -29,4 +29,16 @@ + + %1$d deň + %1$d dní + %1$d dní + %1$d dní + + + %1$d hodina + %1$d hodín + %1$d hodín + %1$d hodín + diff --git a/pump-common/src/main/res/values-sv-rSE/strings.xml b/pump-common/src/main/res/values-sv-rSE/strings.xml index 33c77af761..22fbdda8af 100644 --- a/pump-common/src/main/res/values-sv-rSE/strings.xml +++ b/pump-common/src/main/res/values-sv-rSE/strings.xml @@ -1,11 +1,39 @@ + Operation stöds inte av pumpen/pumpdrivrutinen. + Operationen stöds inte av pumpen ännu. + OK + Väcker + Kommunikationsfel + Kommunikationstimeout + Pumpen kan inte nås + Felaktig konfiguration + Aktiv + Sover + Basaldoser + Konfigurationer + Notiser + Statistik + Okända + Alla + Bolusar + Förfyllningar + Larm + Glukos + + %1$d dag + %1$d dagar + + + %1$d tim + %1$d tim + diff --git a/pump-common/src/main/res/values/styles.xml b/pump-common/src/main/res/values/styles.xml deleted file mode 100644 index cb12b773ce..0000000000 --- a/pump-common/src/main/res/values/styles.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt index 61be9e9b16..0dbbd0302b 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.common.dialog +import android.Manifest import android.annotation.SuppressLint import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothDevice @@ -10,6 +11,8 @@ import android.bluetooth.le.ScanFilter import android.bluetooth.le.ScanResult import android.bluetooth.le.ScanSettings import android.content.Context +import android.content.pm.PackageManager +import android.os.Build import android.os.Bundle import android.os.Handler import android.os.HandlerThread @@ -22,8 +25,10 @@ import android.widget.AdapterView.OnItemClickListener import android.widget.BaseAdapter import android.widget.TextView import android.widget.Toast +import androidx.core.app.ActivityCompat import dagger.android.support.DaggerAppCompatActivity import info.nightscout.androidaps.interfaces.ActivePlugin +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst @@ -32,7 +37,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.Gatt import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.databinding.RileyLinkBleConfigActivityBinding import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice import info.nightscout.androidaps.utils.alertDialogs.OKDialog -import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP @@ -225,16 +229,20 @@ class RileyLinkBLEConfigActivity : DaggerAppCompatActivity() { binding.rileyLinkBleConfigButtonScanStop.visibility = View.VISIBLE } scanning = true - bleScanner?.startScan(filters, settings, bleScanCallback) - aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start") - Toast.makeText(this@RileyLinkBLEConfigActivity, R.string.riley_link_ble_config_scan_scanning, Toast.LENGTH_SHORT).show() + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED) { + bleScanner?.startScan(filters, settings, bleScanCallback) + aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start") + Toast.makeText(this@RileyLinkBLEConfigActivity, R.string.riley_link_ble_config_scan_scanning, Toast.LENGTH_SHORT).show() + } } private fun stopLeDeviceScan() { if (scanning) { scanning = false if (bluetoothAdapter?.isEnabled == true && bluetoothAdapter?.state == BluetoothAdapter.STATE_ON) - bleScanner?.stopScan(bleScanCallback) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED) { + bleScanner?.stopScan(bleScanCallback) + } aapsLogger.debug(LTag.PUMPBTCOMM, "stopLeDeviceScan: Scanning Stop") Toast.makeText(this, R.string.riley_link_ble_config_scan_finished, Toast.LENGTH_SHORT).show() handler.removeCallbacks(stopScanAfterTimeoutRunnable) @@ -268,7 +276,7 @@ class RileyLinkBLEConfigActivity : DaggerAppCompatActivity() { override fun getItem(i: Int): Any = leDevices[i] override fun getItemId(i: Int): Long = i.toLong() - @SuppressLint("InflateParams") + @SuppressLint("InflateParams", "MissingPermission") override fun getView(i: Int, v: View?, viewGroup: ViewGroup): View { var view = v val viewHolder: ViewHolder diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt index d7efd6ca73..9e5e10cd79 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt @@ -7,6 +7,7 @@ import android.content.Intent import dagger.android.DaggerService import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePlugin +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager @@ -17,8 +18,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLink import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice -import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP @@ -85,8 +84,6 @@ abstract class RileyLinkService : DaggerService() { } abstract val deviceCommunicationManager: RileyLinkCommunicationManager<*> - val rileyLinkServiceState: RileyLinkServiceState? - get() = rileyLinkServiceData.rileyLinkServiceState // Here is where the wake-lock begins: // We've received a service startCommand, we grab the lock. @@ -94,7 +91,7 @@ abstract class RileyLinkService : DaggerService() { fun bluetoothInit(): Boolean { aapsLogger.debug(LTag.PUMPBTCOMM, "bluetoothInit: attempting to get an adapter") - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.BluetoothInitializing + rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothInitializing) if (bluetoothAdapter == null) { aapsLogger.error("Unable to obtain a BluetoothAdapter.") rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.NoBluetoothAdapter) @@ -103,7 +100,7 @@ abstract class RileyLinkService : DaggerService() { aapsLogger.error("Bluetooth is not enabled.") rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled) } else { - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.BluetoothReady + rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothReady) return true } } @@ -112,7 +109,7 @@ abstract class RileyLinkService : DaggerService() { // returns true if our Rileylink configuration changed fun reconfigureRileyLink(deviceAddress: String): Boolean { - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.RileyLinkInitializing + rileyLinkServiceData.setServiceState(RileyLinkServiceState.RileyLinkInitializing) return if (rileyLinkBLE.isConnected) { if (deviceAddress == rileyLinkServiceData.rileyLinkAddress) { aapsLogger.info(LTag.PUMPBTCOMM, "No change to RL address. Not reconnecting.") @@ -141,7 +138,7 @@ abstract class RileyLinkService : DaggerService() { // FIXME: This needs to be run in a session so that is incorruptible, has a separate thread, etc. fun doTuneUpDevice() { - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.TuneUpDevice + rileyLinkServiceData.setServiceState(RileyLinkServiceState.TuneUpDevice) setPumpDeviceState(PumpDeviceState.Sleeping) val lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency ?: sp.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0) val newFrequency = deviceCommunicationManager.tuneForDevice() @@ -157,7 +154,7 @@ abstract class RileyLinkService : DaggerService() { rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed) } else { deviceCommunicationManager.clearNotConnectedCount() - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.PumpConnectorReady + rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorReady) } } @@ -168,7 +165,7 @@ abstract class RileyLinkService : DaggerService() { rileyLinkServiceData.rileyLinkAddress = null rileyLinkServiceData.rileyLinkName = null } - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.BluetoothReady + rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothReady) } fun changeRileyLinkEncoding(encodingType: RileyLinkEncodingType?) { diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.kt index 047467fd7f..39dcf629bb 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.kt +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.kt @@ -27,6 +27,7 @@ class RileyLinkServiceData @Inject constructor() { var tuneUpDone = false var rileyLinkError: RileyLinkError? = null var rileyLinkServiceState: RileyLinkServiceState = RileyLinkServiceState.NotStarted + private set var lastServiceStateChange = 0L private set @@ -62,11 +63,11 @@ class RileyLinkServiceData @Inject constructor() { } @Synchronized - fun setServiceState(newState: RileyLinkServiceState, errorCode: RileyLinkError) { + fun setServiceState(newState: RileyLinkServiceState, errorCode: RileyLinkError? = null) { rileyLinkServiceState = newState lastServiceStateChange = System.currentTimeMillis() rileyLinkError = errorCode - aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "RileyLink State Changed: $newState - Error State: ${errorCode.name}")) + aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "RileyLink State Changed: $newState - Error State: ${errorCode?.name}")) rileyLinkUtil.rileyLinkHistory.add(RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice)) rxBus.send(EventRileyLinkDeviceStatusChange(targetDevice!!, newState, errorCode)) } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.kt index 935aff66bc..cc7f946d74 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.kt +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.kt @@ -39,10 +39,10 @@ class InitializePumpManagerTask(injector: HasAndroidInjector, private val contex val rileyLinkCommunicationManager = pumpDevice?.rileyLinkService?.deviceCommunicationManager if (activePlugin.activePump.manufacturer() === ManufacturerType.Medtronic) { if (lastGoodFrequency > 0.0 && rileyLinkCommunicationManager?.isValidFrequency(lastGoodFrequency) == true) { - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.RileyLinkReady + rileyLinkServiceData.setServiceState(RileyLinkServiceState.RileyLinkReady) aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to $lastGoodFrequency MHz") rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency) - if (rileyLinkCommunicationManager.tryToConnectToDevice()) rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.PumpConnectorReady + if (rileyLinkCommunicationManager.tryToConnectToDevice()) rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorReady) else { rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.NoContactWithDevice) rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context) @@ -54,11 +54,11 @@ class InitializePumpManagerTask(injector: HasAndroidInjector, private val contex lastGoodFrequency = (lastGoodFrequency * 1000.0).roundToLong() / 1000.0 rileyLinkServiceData.lastGoodFrequency = lastGoodFrequency } - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.RileyLinkReady + rileyLinkServiceData.setServiceState(RileyLinkServiceState.RileyLinkReady) rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod // TODO shouldn't be needed aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to $lastGoodFrequency MHz") rileyLinkCommunicationManager?.setRadioFrequencyForPump(lastGoodFrequency) - rileyLinkServiceData.rileyLinkServiceState = RileyLinkServiceState.PumpConnectorReady + rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorReady) } } } \ No newline at end of file diff --git a/rileylink/src/main/res/values-zh-rCN/strings.xml b/rileylink/src/main/res/values-zh-rCN/strings.xml index 894c82586d..bf830c54b6 100644 --- a/rileylink/src/main/res/values-zh-rCN/strings.xml +++ b/rileylink/src/main/res/values-zh-rCN/strings.xml @@ -25,7 +25,7 @@ 地址: 名称: 电池电量: - %1$d % + %1$d%% 连接状态: 连接错误: 设备