[Replicant] [PATCH v2] Fix "RepWifi connection not correctly reported to userspace apps" Issue #1792.

Fil fil.bergamo at riseup.net
Wed Aug 16 10:31:54 UTC 2017


Fil wrote:
> Wolfgang Wiedmeyer wrote:
> > 
> >  Wouldn't it be possible to e.g. read the property
> > dhcp.wlan0.gateway and check if it's empty or not?
> For sure, but I currently lack a way of doing it, without using shell
> commands. See above; same reasoning.
> I'm investigating android.net.DhcpInfo class, to see if it's usable in
> this context. I'll get back to you if I get to get something out of it.
> 
Unfortunately, no luck on that side; android.net.DhcpInfo heavily relies
on the native WiFi state, and as such it gives no accurate info on the
connection established "manually" via wpa_supplicant.
Indeed, reading system properties *IS* doable without shell commands,
taking advantage of the android.os.SystemProperties class.
*But* the only seemingly-reliable property to check for effective
connection seems to be "dhcp.wlan0.reason" which I found to be pretty
reactive to connection changes, and is set to "BOUND" only when there is
an actual WiFi connection working.
Conversely, the value of "dhcp.wlan0.gateway" is totally unreliable, as
it persists even when no connection is in place, reporting the last used
gateway.
I grepped for other system properties that could come in handy; found
none.

I believe we have three possible choices here:

1) leave my first solution as it is, only relying on the IP address.
False positives are still possible, but unlikely to happen.

2) introduce an additional check based on "dhcp.wlan0.reason".
This one would work for wifi only, not for reverse tethering.

3) introduce a two-step check on "dhcp.wlan0.gateway":
3A) retrieve the last known gateway from the sysprop.
3B) make sure it is effectively in use by pinging it.
I would not recommend this, as the java method InetAddress.isReachable()
is known to perform badly, and ping would need a shell command (possibly
root).

That said, I wait for suggestions on which path to undertake.

Regards,

Fil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/replicant/attachments/20170816/041c9440/attachment.asc>


More information about the Replicant mailing list