Fix some android device cannot be found
Needs ReviewPublic

Authored by xiaow on Nov 10 2018, 3:38 AM.

Details

Reviewers
nicolasfella
Group Reviewers
KDE Connect
Summary

When using some Android devices (such as my Xiaomi phone), the device cannot be discovered by my computer. I changed the destination address of the device to send the udp packet and changed it to [network address .255] instead of the original 255.255.255.255, which solved the problem.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
xiaow requested review of this revision.Nov 10 2018, 3:38 AM
xiaow created this revision.
nicolasfella requested changes to this revision.Nov 10 2018, 4:51 PM
nicolasfella added a subscriber: nicolasfella.

Thanks for the patch! I noticed some connectivity issues myself so I'm very interested in seeing if this improves the situation for me. I will test it over the next few days.

However, there are some things that need to be improved:

  • This needs the permission ACCESS_WIFI_STATE or else it crashes for me
  • You removed the add-by-IP handling, please add it again
  • Not all broadcast addresses end with .255, for example 192.168.0.1 with netmask 255.255.255.128 has 192.168.0.127 as broadcast address. You should be able to get the broadcast address from the NetworkInterface object (https://stackoverflow.com/a/9912504)
This revision now requires changes to proceed.Nov 10 2018, 4:51 PM
xiaow updated this revision to Diff 45259.Nov 11 2018, 3:17 AM

Improved:

  1. Add
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

to AndroidManifest.xml, I found that I can only upload one diff file, so you have to add it manually.

  1. Added back, but I think that they may be useless.
  2. The code can get the right broadcast address, in my case, it is [network address.255].