Skip to content

Commit d74d083

Browse files
authored
Downgrade stopServiceResolution listener-not-registered to a warning (#6880)
1 parent d21c076 commit d74d083

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

app/src/main/kotlin/io/homeassistant/companion/android/onboarding/serverdiscovery/HomeAssistantSearcher.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ internal class HomeAssistantSearcherImpl @Inject constructor(
160160
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
161161
try {
162162
nsdManager.stopServiceResolution(listener)
163+
} catch (e: IllegalArgumentException) {
164+
// On devices with T SDK extension < 22, NsdManager throws when the
165+
// listener is already unregistered (which happens automatically after
166+
// onServiceResolved/onResolveFailed fires). The call is still needed
167+
// for devices where auto-unregistration is not guaranteed, so we keep
168+
// it and just downgrade the expected case to a warning without a stack.
169+
Timber.w("stopServiceResolution: listener already unregistered: ${e.message}")
163170
} catch (e: Exception) {
164171
Timber.e(e, "Failed to stop service resolution")
165172
}

0 commit comments

Comments
 (0)