Skip to content

Bind sockets to network

Axel Pirek requested to merge apirek/kdeconnect-android:bind-socket into master

Summary

Fixes a race condition where onNetworkChange was called before the new network became the default and the identity packet would be broadcast to the wrong (e.g. cellular) network.

This uses bindProcessToNetwork as suggested by Albert Vaca. The alternative would be passing the new network to onNetworkChange in the callback, the default network or null on startup, and binding the broadcast socket explicitly.

Edit: We ended up going with the alternative.

The method bindProcessToNetwork was added in API level 23, before that there was setProcessDefaultNetwork. The docs don't say when it throws IllegalStateException.

BUG: https://bugs.kde.org/show_bug.cgi?id=470085

Test Plan

Before:

The identity packet is broadcast on the cellular link after connecting to my wifi network.

After:

The identity packet is broadcast on the wifi link after connecting to my wifi network.

Edited by Albert Vaca Cintora

Merge request reports

Loading