diff --git a/app-common/src/main/java/eu/darken/capod/monitor/core/PodMonitor.kt b/app-common/src/main/java/eu/darken/capod/monitor/core/PodMonitor.kt index 1ddf0d4f..dc92fa5e 100644 --- a/app-common/src/main/java/eu/darken/capod/monitor/core/PodMonitor.kt +++ b/app-common/src/main/java/eu/darken/capod/monitor/core/PodMonitor.kt @@ -198,7 +198,7 @@ class PodMonitor @Inject constructor( } private fun determineMainDevice(pods: List): PodDevice? { - val identityKey = generalSettings.mainDeviceIdentityKey.value + val identityKey = generalSettings.mainDeviceIdentityKey.value?.takeIf { it.isNotEmpty() } if (identityKey != null) { val irkHit = pods.filterIsInstance().firstOrNull { it.flags.isIRKMatch } log(TAG) { "IRK is configured, main device irkHit=$irkHit" } diff --git a/app-common/src/main/java/eu/darken/capod/pods/core/apple/AppleFactory.kt b/app-common/src/main/java/eu/darken/capod/pods/core/apple/AppleFactory.kt index ef7546fe..6692c8a8 100644 --- a/app-common/src/main/java/eu/darken/capod/pods/core/apple/AppleFactory.kt +++ b/app-common/src/main/java/eu/darken/capod/pods/core/apple/AppleFactory.kt @@ -71,7 +71,7 @@ class AppleFactory @Inject constructor( if (!isIrkMatch) return@run null if (proximityMessage.data.size != ProximityPairing.PAIRING_MESSAGE_LENGTH) return@run null - val encKey = generalSettings.mainDeviceEncryptionKey.value + val encKey = generalSettings.mainDeviceEncryptionKey.value?.takeIf { it.isNotEmpty() } if (encKey == null) return@run null val encrypted = proximityMessage.data.takeLast(16).toUByteArray().toByteArray() diff --git a/app/src/main/java/eu/darken/capod/main/ui/settings/general/GeneralSettingsFragment.kt b/app/src/main/java/eu/darken/capod/main/ui/settings/general/GeneralSettingsFragment.kt index 4b628ca4..40c9b383 100644 --- a/app/src/main/java/eu/darken/capod/main/ui/settings/general/GeneralSettingsFragment.kt +++ b/app/src/main/java/eu/darken/capod/main/ui/settings/general/GeneralSettingsFragment.kt @@ -55,7 +55,9 @@ class GeneralSettingsFragment : PreferenceFragment3() { AirPodKeyInputDialog(requireContext()).create( mode = AirPodKeyInputDialog.Mode.IRK, current = generalSettings.mainDeviceIdentityKey.value?.toHex() ?: "", - onKey = { generalSettings.mainDeviceIdentityKey.value = it.fromHex() }, + onKey = { raw -> + generalSettings.mainDeviceIdentityKey.value = raw.fromHex().takeIf { it.isNotEmpty() } + }, onGuide = { webpageTool.open("https://github.com/d4rken-org/capod/wiki/airpod-Keys") } ).show() true @@ -64,7 +66,9 @@ class GeneralSettingsFragment : PreferenceFragment3() { AirPodKeyInputDialog(requireContext()).create( mode = AirPodKeyInputDialog.Mode.ENC, current = generalSettings.mainDeviceEncryptionKey.value?.toHex() ?: "", - onKey = { generalSettings.mainDeviceEncryptionKey.value = it.fromHex() }, + onKey = { raw -> + generalSettings.mainDeviceEncryptionKey.value = raw.fromHex().takeIf { it.isNotEmpty() } + }, onGuide = { webpageTool.open("https://github.com/d4rken-org/capod/wiki/airpod-Keys") } ).show() true