From 1c45bf09d1cf8b513b93c0b56a453299add14ff2 Mon Sep 17 00:00:00 2001 From: Sylwester Zielinski Date: Wed, 3 May 2023 15:31:17 +0200 Subject: [PATCH] Add catch to discoverServices --- .../java/no/nordicsemi/android/bps/viewmodel/BPSViewModel.kt | 1 + .../java/no/nordicsemi/android/cgms/repository/CGMService.kt | 2 ++ .../java/no/nordicsemi/android/csc/repository/CSCService.kt | 2 ++ .../main/java/no/nordicsemi/android/hrs/service/HRSService.kt | 2 ++ .../java/no/nordicsemi/android/hts/repository/HTSService.kt | 2 ++ .../java/no/nordicsemi/android/prx/repository/PRXService.kt | 2 ++ .../java/no/nordicsemi/android/rscs/repository/RSCSService.kt | 2 ++ .../java/no/nordicsemi/android/uart/repository/UARTService.kt | 2 ++ 8 files changed, 15 insertions(+) diff --git a/profile_bps/src/main/java/no/nordicsemi/android/bps/viewmodel/BPSViewModel.kt b/profile_bps/src/main/java/no/nordicsemi/android/bps/viewmodel/BPSViewModel.kt index cd4f6b70..d6c38aa9 100644 --- a/profile_bps/src/main/java/no/nordicsemi/android/bps/viewmodel/BPSViewModel.kt +++ b/profile_bps/src/main/java/no/nordicsemi/android/bps/viewmodel/BPSViewModel.kt @@ -139,6 +139,7 @@ internal class BPSViewModel @Inject constructor( client.discoverServices() .filterNotNull() .onEach { configureGatt(it) } + .catch { it.printStackTrace() } .launchIn(viewModelScope) } diff --git a/profile_cgms/src/main/java/no/nordicsemi/android/cgms/repository/CGMService.kt b/profile_cgms/src/main/java/no/nordicsemi/android/cgms/repository/CGMService.kt index 03cb77c4..901d6513 100644 --- a/profile_cgms/src/main/java/no/nordicsemi/android/cgms/repository/CGMService.kt +++ b/profile_cgms/src/main/java/no/nordicsemi/android/cgms/repository/CGMService.kt @@ -35,6 +35,7 @@ import android.annotation.SuppressLint import android.content.Intent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.mapNotNull @@ -155,6 +156,7 @@ internal class CGMService : NotificationService() { client.discoverServices() .filterNotNull() .onEach { configureGatt(it) } + .catch { it.printStackTrace() } .launchIn(lifecycleScope) } diff --git a/profile_csc/src/main/java/no/nordicsemi/android/csc/repository/CSCService.kt b/profile_csc/src/main/java/no/nordicsemi/android/csc/repository/CSCService.kt index 608e2c82..7717a4c5 100644 --- a/profile_csc/src/main/java/no/nordicsemi/android/csc/repository/CSCService.kt +++ b/profile_csc/src/main/java/no/nordicsemi/android/csc/repository/CSCService.kt @@ -35,6 +35,7 @@ import android.annotation.SuppressLint import android.content.Intent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.mapNotNull @@ -111,6 +112,7 @@ internal class CSCService : NotificationService() { client.discoverServices() .filterNotNull() .onEach { configureGatt(it) } + .catch { it.printStackTrace() } .launchIn(lifecycleScope) } diff --git a/profile_hrs/src/main/java/no/nordicsemi/android/hrs/service/HRSService.kt b/profile_hrs/src/main/java/no/nordicsemi/android/hrs/service/HRSService.kt index dac43536..8a4dc101 100644 --- a/profile_hrs/src/main/java/no/nordicsemi/android/hrs/service/HRSService.kt +++ b/profile_hrs/src/main/java/no/nordicsemi/android/hrs/service/HRSService.kt @@ -35,6 +35,7 @@ import android.annotation.SuppressLint import android.content.Intent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.mapNotNull @@ -115,6 +116,7 @@ internal class HRSService : NotificationService() { client.discoverServices() .filterNotNull() .onEach { configureGatt(it) } + .catch { it.printStackTrace() } .launchIn(lifecycleScope) } diff --git a/profile_hts/src/main/java/no/nordicsemi/android/hts/repository/HTSService.kt b/profile_hts/src/main/java/no/nordicsemi/android/hts/repository/HTSService.kt index a4c3f8bb..266e51da 100644 --- a/profile_hts/src/main/java/no/nordicsemi/android/hts/repository/HTSService.kt +++ b/profile_hts/src/main/java/no/nordicsemi/android/hts/repository/HTSService.kt @@ -35,6 +35,7 @@ import android.annotation.SuppressLint import android.content.Intent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.mapNotNull @@ -113,6 +114,7 @@ internal class HTSService : NotificationService() { client.discoverServices() .filterNotNull() .onEach { configureGatt(it) } + .catch { it.printStackTrace() } .launchIn(lifecycleScope) } 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 58c57bac..7c47810f 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 @@ -35,6 +35,7 @@ import android.annotation.SuppressLint import android.content.Intent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.mapNotNull @@ -184,6 +185,7 @@ internal class PRXService : NotificationService() { client.discoverServices() .filterNotNull() .onEach { configureGatt(it) } + .catch { it.printStackTrace() } .launchIn(lifecycleScope) repository.remoteAlarmLevel diff --git a/profile_rscs/src/main/java/no/nordicsemi/android/rscs/repository/RSCSService.kt b/profile_rscs/src/main/java/no/nordicsemi/android/rscs/repository/RSCSService.kt index a8fd3054..0cb8c76a 100644 --- a/profile_rscs/src/main/java/no/nordicsemi/android/rscs/repository/RSCSService.kt +++ b/profile_rscs/src/main/java/no/nordicsemi/android/rscs/repository/RSCSService.kt @@ -35,6 +35,7 @@ import android.annotation.SuppressLint import android.content.Intent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.mapNotNull @@ -111,6 +112,7 @@ internal class RSCSService : NotificationService() { client.discoverServices() .filterNotNull() .onEach { configureGatt(it) } + .catch { it.printStackTrace() } .launchIn(lifecycleScope) } 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 89ef3f86..9efd9614 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 @@ -35,6 +35,7 @@ import android.annotation.SuppressLint import android.content.Intent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.mapNotNull @@ -117,6 +118,7 @@ internal class UARTService : NotificationService() { client.discoverServices() .filterNotNull() .onEach { configureGatt(it, logger) } + .catch { it.printStackTrace() } .launchIn(lifecycleScope) }