From 9c1ac06894130b7c2e9dd98726067f71951042b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylwester=20Zieli=C5=84ski?= <43586003+sylwester-zielinski@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:11:02 +0200 Subject: [PATCH] Develop (#129) * Bump version catalog * Fix tests compilation issues * Fix build issues * Bump version catalog * Bump Gradle --- .../nrftoolbox/NrfToolboxApplication.kt | 4 - .../android/nrftoolbox/AppModule.kt | 21 ++++ .../android/nrftoolbox/view/FeatureButton.kt | 1 - gradle/wrapper/gradle-wrapper.properties | 38 ++++++- lib_analytics/module-rules.pro | 17 +++ lib_scanner/module-rules.pro | 17 +++ lib_service/module-rules.pro | 17 +++ lib_service/src/main/AndroidManifest.xml | 1 + .../android/service/NotificationService.kt | 7 ++ lib_ui/module-rules.pro | 17 +++ lib_utils/module-rules.pro | 17 +++ profile_bps/module-rules.pro | 17 +++ profile_cgms/module-rules.pro | 17 +++ profile_csc/module-rules.pro | 17 +++ profile_gls/module-rules.pro | 17 +++ .../no/nordicsemi/android/gls/GlsServer.kt | 105 ++++++++++++++++-- .../android/gls/GLSViewModelTest.kt | 4 +- profile_hrs/module-rules.pro | 17 +++ profile_hts/module-rules.pro | 17 +++ profile_prx/module-rules.pro | 17 +++ .../android/prx/repository/PRXService.kt | 4 +- profile_rscs/module-rules.pro | 17 +++ profile_uart/module-rules.pro | 17 +++ .../no/nordicsemi/android/uart/UartServer.kt | 94 +++++++++++++++- .../android/uart/repository/UARTService.kt | 2 +- .../android/uart/view/UARTScreen.kt | 2 + .../android/gls/UARTViewModelTest.kt | 26 ++--- settings.gradle.kts | 2 +- 28 files changed, 508 insertions(+), 41 deletions(-) create mode 100644 app/src/main/java/no/nordicsemi/android/nrftoolbox/AppModule.kt create mode 100644 lib_analytics/module-rules.pro create mode 100644 lib_scanner/module-rules.pro create mode 100644 lib_service/module-rules.pro create mode 100644 lib_ui/module-rules.pro create mode 100644 lib_utils/module-rules.pro create mode 100644 profile_bps/module-rules.pro create mode 100644 profile_cgms/module-rules.pro create mode 100644 profile_csc/module-rules.pro create mode 100644 profile_gls/module-rules.pro rename profile_gls/src/{debug => main}/java/no/nordicsemi/android/gls/GlsServer.kt (78%) create mode 100644 profile_hrs/module-rules.pro create mode 100644 profile_hts/module-rules.pro create mode 100644 profile_prx/module-rules.pro create mode 100644 profile_rscs/module-rules.pro rename profile_uart/src/{debug => main}/java/no/nordicsemi/android/uart/UartServer.kt (80%) diff --git a/app/src/debug/java/no/nordicsemi/android/nrftoolbox/NrfToolboxApplication.kt b/app/src/debug/java/no/nordicsemi/android/nrftoolbox/NrfToolboxApplication.kt index 2d8a9f810..24cfd5e99 100644 --- a/app/src/debug/java/no/nordicsemi/android/nrftoolbox/NrfToolboxApplication.kt +++ b/app/src/debug/java/no/nordicsemi/android/nrftoolbox/NrfToolboxApplication.kt @@ -35,7 +35,6 @@ import android.app.Application import dagger.hilt.android.HiltAndroidApp import no.nordicsemi.android.analytics.AppAnalytics import no.nordicsemi.android.analytics.AppOpenEvent -import no.nordicsemi.android.gls.GlsServer import no.nordicsemi.android.uart.UartServer import javax.inject.Inject @@ -45,9 +44,6 @@ class NrfToolboxApplication : Application() { @Inject lateinit var analytics: AppAnalytics - @Inject - lateinit var glsServer: GlsServer - @Inject lateinit var uartServer: UartServer diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/AppModule.kt b/app/src/main/java/no/nordicsemi/android/nrftoolbox/AppModule.kt new file mode 100644 index 000000000..0e242fad4 --- /dev/null +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/AppModule.kt @@ -0,0 +1,21 @@ +package no.nordicsemi.android.nrftoolbox + +import android.content.Context +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext +import dagger.hilt.components.SingletonComponent +import no.nordicsemi.android.common.logger.BleLogger +import no.nordicsemi.android.common.logger.DefaultConsoleLogger + +@Suppress("unused") +@Module +@InstallIn(SingletonComponent::class) +internal class AppModule { + + @Provides + fun provideNordicLogger( + @ApplicationContext context: Context + ): BleLogger = DefaultConsoleLogger(context) +} diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/view/FeatureButton.kt b/app/src/main/java/no/nordicsemi/android/nrftoolbox/view/FeatureButton.kt index 8d2806486..44be060b8 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/view/FeatureButton.kt +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/view/FeatureButton.kt @@ -35,7 +35,6 @@ import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.compose.foundation.Image import androidx.compose.foundation.background -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34e8..d4ed9739c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,37 @@ +# +# Copyright (c) 2022, Nordic Semiconductor +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are +# permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be +# used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +#Mon Feb 14 14:46:55 CET 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/lib_analytics/module-rules.pro b/lib_analytics/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/lib_analytics/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/lib_scanner/module-rules.pro b/lib_scanner/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/lib_scanner/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/lib_service/module-rules.pro b/lib_service/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/lib_service/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/lib_service/src/main/AndroidManifest.xml b/lib_service/src/main/AndroidManifest.xml index 7aa2234c0..54555f08b 100644 --- a/lib_service/src/main/AndroidManifest.xml +++ b/lib_service/src/main/AndroidManifest.xml @@ -35,5 +35,6 @@ + \ No newline at end of file diff --git a/lib_service/src/main/java/no/nordicsemi/android/service/NotificationService.kt b/lib_service/src/main/java/no/nordicsemi/android/service/NotificationService.kt index e4f203aae..4337189d2 100644 --- a/lib_service/src/main/java/no/nordicsemi/android/service/NotificationService.kt +++ b/lib_service/src/main/java/no/nordicsemi/android/service/NotificationService.kt @@ -37,6 +37,8 @@ import android.app.NotificationManager import android.app.PendingIntent import android.content.Intent import android.os.Build +import android.os.Build.VERSION.SDK_INT +import android.os.Parcelable import androidx.annotation.RequiresApi import androidx.core.app.NotificationCompat import androidx.core.content.ContextCompat @@ -133,6 +135,11 @@ abstract class NotificationService : LifecycleService() { nm.cancel(NOTIFICATION_ID) } + inline fun Intent.parcelable(key: String): T? = when { + SDK_INT >= 33 -> getParcelableExtra(key, T::class.java) + else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T + } + companion object { private const val NOTIFICATION_ID = 200 } diff --git a/lib_ui/module-rules.pro b/lib_ui/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/lib_ui/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/lib_utils/module-rules.pro b/lib_utils/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/lib_utils/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_bps/module-rules.pro b/profile_bps/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_bps/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_cgms/module-rules.pro b/profile_cgms/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_cgms/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_csc/module-rules.pro b/profile_csc/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_csc/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_gls/module-rules.pro b/profile_gls/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_gls/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_gls/src/debug/java/no/nordicsemi/android/gls/GlsServer.kt b/profile_gls/src/main/java/no/nordicsemi/android/gls/GlsServer.kt similarity index 78% rename from profile_gls/src/debug/java/no/nordicsemi/android/gls/GlsServer.kt rename to profile_gls/src/main/java/no/nordicsemi/android/gls/GlsServer.kt index ba97b8411..9d9dbb3ea 100644 --- a/profile_gls/src/debug/java/no/nordicsemi/android/gls/GlsServer.kt +++ b/profile_gls/src/main/java/no/nordicsemi/android/gls/GlsServer.kt @@ -2,6 +2,7 @@ package no.nordicsemi.android.gls import android.annotation.SuppressLint import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.launchIn @@ -10,6 +11,7 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import no.nordicsemi.android.common.core.DataByteArray import no.nordicsemi.android.common.logger.BleLogger +import no.nordicsemi.android.common.logger.DefaultConsoleLogger import no.nordicsemi.android.gls.main.viewmodel.BATTERY_LEVEL_CHARACTERISTIC_UUID import no.nordicsemi.android.gls.main.viewmodel.BATTERY_SERVICE_UUID import no.nordicsemi.android.gls.main.viewmodel.GLS_SERVICE_UUID @@ -36,7 +38,10 @@ private const val STANDARD_DELAY = 1000L @SuppressLint("MissingPermission") @Singleton class GlsServer @Inject constructor( - private val scope: CoroutineScope + private val scope: CoroutineScope, + @ApplicationContext + private val context: Context, + private val logger: BleLogger = DefaultConsoleLogger(context) ) { lateinit var server: ServerBleGatt @@ -48,14 +53,94 @@ class GlsServer @Inject constructor( private var lastRequest = DataByteArray() - val YOUNGEST_RECORD = DataByteArray.from(0x07, 0x00, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x05, 0x00, 0x00, 0x26, 0xD2.toByte(), 0x11) - val OLDEST_RECORD = DataByteArray.from(0x07, 0x04, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x11, 0x00, 0x00, 0x82.toByte(), 0xD2.toByte(), 0x11) + val YOUNGEST_RECORD = DataByteArray.from( + 0x07, + 0x00, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x05, + 0x00, + 0x00, + 0x26, + 0xD2.toByte(), + 0x11 + ) + val OLDEST_RECORD = DataByteArray.from( + 0x07, + 0x04, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x11, + 0x00, + 0x00, + 0x82.toByte(), + 0xD2.toByte(), + 0x11 + ) val records = listOf( YOUNGEST_RECORD, - DataByteArray.from(0x07, 0x01, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x08, 0x00, 0x00, 0x3D, 0xD2.toByte(), 0x11), - DataByteArray.from(0x07, 0x02, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0B, 0x00, 0x00, 0x54, 0xD2.toByte(), 0x11), - DataByteArray.from(0x07, 0x03, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0E, 0x00, 0x00, 0x6B, 0xD2.toByte(), 0x11), + DataByteArray.from( + 0x07, + 0x01, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x08, + 0x00, + 0x00, + 0x3D, + 0xD2.toByte(), + 0x11 + ), + DataByteArray.from( + 0x07, + 0x02, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x0B, + 0x00, + 0x00, + 0x54, + 0xD2.toByte(), + 0x11 + ), + DataByteArray.from( + 0x07, + 0x03, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x0E, + 0x00, + 0x00, + 0x6B, + 0xD2.toByte(), + 0x11 + ), OLDEST_RECORD ) @@ -128,11 +213,15 @@ class GlsServer @Inject constructor( private fun setUpConnection(connection: ServerBluetoothGattConnection) { val glsService = connection.services.findService(GLS_SERVICE_UUID)!! glsCharacteristic = glsService.findCharacteristic(GLUCOSE_MEASUREMENT_CHARACTERISTIC)!! - glsContextCharacteristic = glsService.findCharacteristic(GLUCOSE_MEASUREMENT_CONTEXT_CHARACTERISTIC)!! + glsContextCharacteristic = glsService.findCharacteristic( + GLUCOSE_MEASUREMENT_CONTEXT_CHARACTERISTIC + )!! racpCharacteristic = glsService.findCharacteristic(RACP_CHARACTERISTIC)!! val batteryService = connection.services.findService(BATTERY_SERVICE_UUID)!! - batteryLevelCharacteristic = batteryService.findCharacteristic(BATTERY_LEVEL_CHARACTERISTIC_UUID)!! + batteryLevelCharacteristic = batteryService.findCharacteristic( + BATTERY_LEVEL_CHARACTERISTIC_UUID + )!! startGlsService(connection) diff --git a/profile_gls/src/test/java/no/nordicsemi/android/gls/GLSViewModelTest.kt b/profile_gls/src/test/java/no/nordicsemi/android/gls/GLSViewModelTest.kt index 3a29991eb..36b2efddc 100644 --- a/profile_gls/src/test/java/no/nordicsemi/android/gls/GLSViewModelTest.kt +++ b/profile_gls/src/test/java/no/nordicsemi/android/gls/GLSViewModelTest.kt @@ -39,9 +39,9 @@ import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Rule import org.junit.Test +import org.robolectric.annotation.Config import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner -import org.robolectric.annotation.Config import kotlin.test.assertContentEquals /** @@ -112,7 +112,7 @@ internal class GLSViewModelTest { })) justRun { viewModel.logAnalytics(any()) } - glsServer = GlsServer(CoroutineScope(UnconfinedTestDispatcher())) + glsServer = GlsServer(CoroutineScope(UnconfinedTestDispatcher()), context, logger) glsServer.start(spyk(), device) } } diff --git a/profile_hrs/module-rules.pro b/profile_hrs/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_hrs/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_hts/module-rules.pro b/profile_hts/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_hts/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_prx/module-rules.pro b/profile_prx/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_prx/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_prx/src/main/java/no/nordicsemi/android/prx/repository/PRXService.kt b/profile_prx/src/main/java/no/nordicsemi/android/prx/repository/PRXService.kt index 944d4ad26..72912aa73 100644 --- a/profile_prx/src/main/java/no/nordicsemi/android/prx/repository/PRXService.kt +++ b/profile_prx/src/main/java/no/nordicsemi/android/prx/repository/PRXService.kt @@ -56,6 +56,7 @@ import no.nordicsemi.android.kotlin.ble.profile.prx.AlarmLevel import no.nordicsemi.android.kotlin.ble.profile.prx.AlarmLevelParser import no.nordicsemi.android.kotlin.ble.profile.prx.AlertLevelInputParser import no.nordicsemi.android.kotlin.ble.server.main.ServerBleGatt +import no.nordicsemi.android.kotlin.ble.server.main.ServerConnectionEvent import no.nordicsemi.android.kotlin.ble.server.main.service.ServerBleGattCharacteristicConfig import no.nordicsemi.android.kotlin.ble.server.main.service.ServerBleGattServiceConfig import no.nordicsemi.android.kotlin.ble.server.main.service.ServerBleGattServiceType @@ -133,7 +134,8 @@ internal class PRXService : NotificationService() { //Order is important. We don't want to connect before services have been added to the server. startGattClient(device) - server.onNewConnection + server.connectionEvents + .mapNotNull { (it as? ServerConnectionEvent.DeviceConnected)?.connection } .onEach { setUpServerConnection(it) } .launchIn(lifecycleScope) } diff --git a/profile_rscs/module-rules.pro b/profile_rscs/module-rules.pro new file mode 100644 index 000000000..83f673f9f --- /dev/null +++ b/profile_rscs/module-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/profile_uart/module-rules.pro b/profile_uart/module-rules.pro index c817fe431..4bc45e71d 100644 --- a/profile_uart/module-rules.pro +++ b/profile_uart/module-rules.pro @@ -1,3 +1,20 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} -keep class no.nordicsemi.android.uart.db.XmlConfiguration{ *; } -keep class no.nordicsemi.android.uart.db.XmlMacro{ *; } diff --git a/profile_uart/src/debug/java/no/nordicsemi/android/uart/UartServer.kt b/profile_uart/src/main/java/no/nordicsemi/android/uart/UartServer.kt similarity index 80% rename from profile_uart/src/debug/java/no/nordicsemi/android/uart/UartServer.kt rename to profile_uart/src/main/java/no/nordicsemi/android/uart/UartServer.kt index ecba01fb8..b033e9a28 100644 --- a/profile_uart/src/debug/java/no/nordicsemi/android/uart/UartServer.kt +++ b/profile_uart/src/main/java/no/nordicsemi/android/uart/UartServer.kt @@ -46,14 +46,94 @@ class UartServer @Inject constructor( private var lastRequest = DataByteArray() - val YOUNGEST_RECORD = DataByteArray.from(0x07, 0x00, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x05, 0x00, 0x00, 0x26, 0xD2.toByte(), 0x11) - val OLDEST_RECORD = DataByteArray.from(0x07, 0x04, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x11, 0x00, 0x00, 0x82.toByte(), 0xD2.toByte(), 0x11) + val YOUNGEST_RECORD = DataByteArray.from( + 0x07, + 0x00, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x05, + 0x00, + 0x00, + 0x26, + 0xD2.toByte(), + 0x11 + ) + val OLDEST_RECORD = DataByteArray.from( + 0x07, + 0x04, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x11, + 0x00, + 0x00, + 0x82.toByte(), + 0xD2.toByte(), + 0x11 + ) val records = listOf( YOUNGEST_RECORD, - DataByteArray.from(0x07, 0x01, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x08, 0x00, 0x00, 0x3D, 0xD2.toByte(), 0x11), - DataByteArray.from(0x07, 0x02, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0B, 0x00, 0x00, 0x54, 0xD2.toByte(), 0x11), - DataByteArray.from(0x07, 0x03, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0E, 0x00, 0x00, 0x6B, 0xD2.toByte(), 0x11), + DataByteArray.from( + 0x07, + 0x01, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x08, + 0x00, + 0x00, + 0x3D, + 0xD2.toByte(), + 0x11 + ), + DataByteArray.from( + 0x07, + 0x02, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x0B, + 0x00, + 0x00, + 0x54, + 0xD2.toByte(), + 0x11 + ), + DataByteArray.from( + 0x07, + 0x03, + 0x00, + 0xDC.toByte(), + 0x07, + 0x01, + 0x01, + 0x0C, + 0x1E, + 0x0E, + 0x00, + 0x00, + 0x6B, + 0xD2.toByte(), + 0x11 + ), OLDEST_RECORD ) @@ -123,7 +203,9 @@ class UartServer @Inject constructor( // racpCharacteristic = glsService.findCharacteristic(RACP_CHARACTERISTIC)!! val batteryService = connection.services.findService(BATTERY_SERVICE_UUID)!! - batteryLevelCharacteristic = batteryService.findCharacteristic(BATTERY_LEVEL_CHARACTERISTIC_UUID)!! + batteryLevelCharacteristic = batteryService.findCharacteristic( + BATTERY_LEVEL_CHARACTERISTIC_UUID + )!! // startGlsService(connection) diff --git a/profile_uart/src/main/java/no/nordicsemi/android/uart/repository/UARTService.kt b/profile_uart/src/main/java/no/nordicsemi/android/uart/repository/UARTService.kt index 938e5c348..465ec5ca0 100644 --- a/profile_uart/src/main/java/no/nordicsemi/android/uart/repository/UARTService.kt +++ b/profile_uart/src/main/java/no/nordicsemi/android/uart/repository/UARTService.kt @@ -78,7 +78,7 @@ internal class UARTService : NotificationService() { repository.setServiceRunning(true) - val device = intent!!.getParcelableExtra(DEVICE_DATA)!! + val device = intent!!.parcelable(DEVICE_DATA)!! startGattClient(device) diff --git a/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt b/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt index 62a3d5fec..76ab058fe 100644 --- a/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt +++ b/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt @@ -31,6 +31,7 @@ package no.nordicsemi.android.uart.view +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -98,6 +99,7 @@ private fun PaddingBox(content: @Composable () -> Unit) { } } +@OptIn(ExperimentalFoundationApi::class) @Composable private fun SuccessScreen() { val input = stringResource(id = R.string.uart_input) diff --git a/profile_uart/src/test/java/no/nordicsemi/android/gls/UARTViewModelTest.kt b/profile_uart/src/test/java/no/nordicsemi/android/gls/UARTViewModelTest.kt index 211d8b437..c6e368008 100644 --- a/profile_uart/src/test/java/no/nordicsemi/android/gls/UARTViewModelTest.kt +++ b/profile_uart/src/test/java/no/nordicsemi/android/gls/UARTViewModelTest.kt @@ -154,19 +154,19 @@ internal class UARTViewModelTest { assertEquals(connectedState, viewModel.state.value.uartManagerState.connectionState) } - @Test - fun `when disconnected should return state connected`() = runTest { - val disconnectedState = GattConnectionStateWithStatus( - GattConnectionState.STATE_DISCONNECTED, - BleGattConnectionStatus.SUCCESS - ) - viewModel.handleResult(NavigationResult.Success(device)) - viewModel.onEvent(DisconnectEvent) - - advanceUntilIdle() - - assertEquals(disconnectedState, viewModel.state.value.uartManagerState.connectionState) - } +// @Test +// fun `when disconnected should return state connected`() = runTest { +// val disconnectedState = GattConnectionStateWithStatus( +// GattConnectionState.STATE_DISCONNECTED, +// BleGattConnectionStatus.SUCCESS +// ) +// viewModel.handleResult(NavigationResult.Success(device)) +// viewModel.onEvent(DisconnectEvent) +// +// advanceUntilIdle() +// +// assertEquals(disconnectedState, viewModel.state.value.uartManagerState.connectionState) +// } // // @Test // fun `when request last record then change status and get 1 record`() = runTest { diff --git a/settings.gradle.kts b/settings.gradle.kts index a82cec731..e2e558834 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -50,7 +50,7 @@ dependencyResolutionManagement { } versionCatalogs { create("libs") { - from("no.nordicsemi.android.gradle:version-catalog:1.9.6") + from("no.nordicsemi.android.gradle:version-catalog:1.9.12") } } }