From 9e8ed2974ad4beadbb25d279e34aa4e87dda3fd9 Mon Sep 17 00:00:00 2001 From: NiroDev <23154768+NiroDeveloper@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:58:43 +0200 Subject: [PATCH] Fix false positive error message, if no devices available --- app/build.gradle.kts | 4 ++-- .../niro/cameraremote/bluetooth/BluetoothServiceCallback.kt | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index dd35c2c..3c58463 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -11,8 +11,8 @@ android { applicationId = "dev.niro.cameraremote" minSdk = 28 targetSdk = 34 - versionCode = 1 - versionName = "1.0.0" + versionCode = 2 + versionName = "1.0.1" vectorDrawables { useSupportLibrary = true } diff --git a/app/src/main/java/dev/niro/cameraremote/bluetooth/BluetoothServiceCallback.kt b/app/src/main/java/dev/niro/cameraremote/bluetooth/BluetoothServiceCallback.kt index e9917e1..9e2672b 100644 --- a/app/src/main/java/dev/niro/cameraremote/bluetooth/BluetoothServiceCallback.kt +++ b/app/src/main/java/dev/niro/cameraremote/bluetooth/BluetoothServiceCallback.kt @@ -172,8 +172,10 @@ class BluetoothServiceCallback( val devices = getDevices(BluetoothProfile.STATE_DISCONNECTED) if (devices.isEmpty()) { + val allDevices = getDevices() + // If all devices are in the disconnecting state, show an error. - if (getDevices(BluetoothProfile.STATE_DISCONNECTING).size == getDevices().size) { + if (allDevices.isNotEmpty() && getDevices(BluetoothProfile.STATE_DISCONNECTING).size == allDevices.size) { Log.e(null, "All devices are disconnecting, seems like the app unregistered silently") serviceStateListener.onServiceError(R.string.error_app_register)