From 3c777d377ee7170ae76dff09e02e600c485bc401 Mon Sep 17 00:00:00 2001 From: darken Date: Mon, 30 Jun 2025 12:43:29 +0200 Subject: [PATCH] Only use IRK match for main device if IRK is configured This commit modifies `PodMonitor.kt` to ensure that the `isIRKMatch` flag is only used to determine the main device if an Identity Resolving Key (IRK) is actually configured in the general settings. If no IRK is set, the main device determination will fall back to other logic, preventing a device from being incorrectly selected as "main" solely based on an IRK match when no specific IRK is being looked for. --- .../main/java/eu/darken/capod/monitor/core/PodMonitor.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 f197988d..1ddf0d4f 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,9 +198,10 @@ class PodMonitor @Inject constructor( } private fun determineMainDevice(pods: List): PodDevice? { - val irkHit = pods.filterIsInstance().firstOrNull { it.flags.isIRKMatch } - if (irkHit != null) { - log(TAG) { "Main device determined via IRK: $irkHit" } + val identityKey = generalSettings.mainDeviceIdentityKey.value + if (identityKey != null) { + val irkHit = pods.filterIsInstance().firstOrNull { it.flags.isIRKMatch } + log(TAG) { "IRK is configured, main device irkHit=$irkHit" } return irkHit }