servalproject / batphone

The Serval Mesh app for Android. EXPERIMENTAL SOFTWARE.
http://www.servalproject.org
GNU General Public License v3.0
398 stars 157 forks source link

Android app stops working, notification disappears, have to toggle "Enable Services" to reconnect #106

Open ohbobva opened 9 years ago

ohbobva commented 9 years ago

Very frequently, it appears the Android service stops. The notification disappears. If I check for connected peers, it says zero (even though there should be one). If I open the "Connect" screen, the "Enable Services" box is still checked. However, I have to toggle the check mark in order in order to start working again. Then, the notification icon returns until the next time this happens.

App Version: 0.92 Nexus 5 Android 5.1

Any thoughts or suggestions?

lakeman commented 9 years ago

That is a bit odd.

We start and stop the notification, and disable access to the network here; https://github.com/servalproject/batphone/blob/0.92/src/org/servalproject/Control.java#L108

Which should be called whenever we hear a broadcast intent related to the wifi network connection.; https://github.com/servalproject/batphone/blob/0.92/src/org/servalproject/batphone/BatPhone.java#L97

Perhaps your wifi supplicant is faltering, and there's a race condition when we check if the network is now usable. So the last message we hear turns everything off instead of on.

In our back end daemon, we've been meaning to swap from preiodically scanning the interface list, to using a net link socket to wait for the OS to push network changes to us. This change would help to save power and make the detection of network changes more reliable.

If I'm right about the above issue, this change in detecting viable network interfaces should make your problem go away as well.

ohbobva commented 9 years ago

I'd like to followup to report that...

On 2 other android devices[1], sometimes, if the device is rebooted, the notification shows up, after reboot, but the service appears to be hung. The Connect screen says, "Starting", and never changes until the "Enable Services" check box is toggled, then everything is fine.

[1] HTC Inspire 4G (Android 2.3.5), and LG Optimus V / VM670 (Android 2.2.2)