From 03bb4254c890aff859fea4b0f2459410d5aac949 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Thu, 23 May 2024 12:35:11 +0200 Subject: [PATCH 1/2] Dependencies updated --- .../android/dfu/app/MainActivity.kt | 2 +- gradle/wrapper/gradle-wrapper.properties | 37 ++----------------- profile/main/build.gradle.kts | 1 - settings.gradle.kts | 2 +- 4 files changed, 5 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/no/nordicsemi/android/dfu/app/MainActivity.kt b/app/src/main/java/no/nordicsemi/android/dfu/app/MainActivity.kt index a97b347b..1a787f0c 100644 --- a/app/src/main/java/no/nordicsemi/android/dfu/app/MainActivity.kt +++ b/app/src/main/java/no/nordicsemi/android/dfu/app/MainActivity.kt @@ -67,7 +67,7 @@ class MainActivity : NordicActivity() { } } - override fun onNewIntent(intent: Intent?) { + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) if (linkHandler.handleDeepLink(intent)) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index adbca553..96372939 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,37 +1,6 @@ -# -# 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 Jun 20 12:44:30 CEST 2022 +#Thu May 23 11:56:27 CEST 2024 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/profile/main/build.gradle.kts b/profile/main/build.gradle.kts index 152dafca..c3cbbc49 100644 --- a/profile/main/build.gradle.kts +++ b/profile/main/build.gradle.kts @@ -20,7 +20,6 @@ dependencies { implementation(libs.nordic.core) implementation(libs.nordic.theme) implementation(libs.nordic.logger) - implementation(libs.nordic.uilogger) implementation(libs.nordic.analytics) implementation(libs.nordic.permissions.ble) implementation(libs.nordic.navigation) diff --git a/settings.gradle.kts b/settings.gradle.kts index 23df3f40..a88630a7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,7 +16,7 @@ dependencyResolutionManagement { } versionCatalogs { create("libs") { - from("no.nordicsemi.android.gradle:version-catalog:1.11.3") + from("no.nordicsemi.android.gradle:version-catalog:1.11.8") } } } From 436e968e1ef29fe41fdda0850cd472af6c182528 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Thu, 23 May 2024 12:35:58 +0200 Subject: [PATCH 2/2] Migrating logger to the new :logger module in Commons --- .../dfu/profile/main/data/DFUManager.kt | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/profile/main/src/main/java/no/nordicsemi/android/dfu/profile/main/data/DFUManager.kt b/profile/main/src/main/java/no/nordicsemi/android/dfu/profile/main/data/DFUManager.kt index 6e9e3cb6..2b5d1ee5 100644 --- a/profile/main/src/main/java/no/nordicsemi/android/dfu/profile/main/data/DFUManager.kt +++ b/profile/main/src/main/java/no/nordicsemi/android/dfu/profile/main/data/DFUManager.kt @@ -32,44 +32,32 @@ package no.nordicsemi.android.dfu.profile.main.data import android.content.Context -import android.util.Log import dagger.hilt.android.qualifiers.ApplicationContext -import no.nordicsemi.android.common.logger.BleLoggerAndLauncher -import no.nordicsemi.android.common.logger.DefaultBleLogger import no.nordicsemi.android.common.logger.LoggerLauncher -import no.nordicsemi.android.dfu.DfuBaseService import no.nordicsemi.android.dfu.DfuServiceController import no.nordicsemi.android.dfu.DfuServiceInitiator import no.nordicsemi.android.dfu.DfuServiceListenerHelper import no.nordicsemi.android.dfu.profile.main.repository.DFUService import no.nordicsemi.android.dfu.profile.scanner.data.DfuTarget import no.nordicsemi.android.dfu.settings.domain.DFUSettings +import no.nordicsemi.android.log.LogSession +import no.nordicsemi.android.log.Logger import javax.inject.Inject internal class DFUManager @Inject constructor( @ApplicationContext private val context: Context, ) { - private var logger: BleLoggerAndLauncher? = null + private var session: LogSession? = null fun install( file: ZipFile, target: DfuTarget, settings: DFUSettings ): DfuServiceController { - logger = DefaultBleLogger - .create(context, null, target.address, target.name) - .also { + session = Logger.newSession(context, target.address, target.name) + ?.also { session -> DfuServiceListenerHelper.registerLogListener(context) { _, level, message -> - // Convert nRF Logger log level to Android log priority, used by the BleLogger. - val priority = when (level) { - DfuBaseService.LOG_LEVEL_DEBUG -> Log.DEBUG - DfuBaseService.LOG_LEVEL_VERBOSE -> Log.VERBOSE - DfuBaseService.LOG_LEVEL_INFO -> Log.INFO - DfuBaseService.LOG_LEVEL_WARNING -> Log.WARN - DfuBaseService.LOG_LEVEL_ERROR -> Log.ERROR - else -> level - } - it.log(priority, message) + Logger.log(session, level, message) } } @@ -101,12 +89,6 @@ internal class DFUManager @Inject constructor( } fun openLogger() { - logger?.launch() ?: context.packageManager - .getLaunchIntentForPackage("no.nordicsemi.android.log") - ?.let { launchIntent -> - context.startActivity(launchIntent) - } ?: run { - LoggerLauncher.launch(context) - } + LoggerLauncher.launch(context, session) } }