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.
This commit is contained in:
darken
2025-06-30 14:12:32 +02:00
committed by Matthias Urhahn
parent b98994f2f1
commit 3c777d377e
@@ -198,9 +198,10 @@ class PodMonitor @Inject constructor(
}
private fun determineMainDevice(pods: List<PodDevice>): PodDevice? {
val irkHit = pods.filterIsInstance<ApplePods>().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<ApplePods>().firstOrNull { it.flags.isIRKMatch }
log(TAG) { "IRK is configured, main device irkHit=$irkHit" }
return irkHit
}