BramBonne / privacypolice

Source code for Wi-Fi Privacy Police, available on Google Play at https://play.google.com/store/apps/details?id=be.uhasselt.privacypolice
GNU General Public License v2.0
159 stars 17 forks source link

Device does not reconnect to Wi-Fi #19

Closed pushbit closed 9 years ago

pushbit commented 9 years ago

Since upgrading to Android 5.1 (from 4.4, via CyanogenMod 12.1), I have found that my Nexus 5 will not reconnect to the known Wi-Fi when returning into range. The status is, "Wi-Fi connection failure". I must turn Wi-Fi off and then on again to successfully connect. This was working on Android 4.4. I have tested with and without the app installed several times to confirm that the app is causing it.

Taomyn commented 9 years ago

I have this same issue and was going to raise a ticket as well, but here's what I was going to put - maybe it helps to explain the issue further:

Hi,

I'm having issues with the app on all my devices and I thought I should report it.

I have it installed on a Nexus 5 (5.1.1 stock, not rooted), a Nexus 6 (5.1.1 stock, rooted) and a Nexus 9 (5.1.1 stock, rooted, Wifi/4G version). On all three I get an issue where allowed WiFi APs show the message "Connection Failure" and I have manually go to the main WiFi settings, choose the AP and then press "Connect" - and then they connect.

They all suffer the same but are all connecting differently as I'll now explain.

Nexus 5 - my work phone, WiFi is always on. At the office with a hidden SSID it connects fine, but when I return home the connection to my own AP sometimes shows the error.

Nexus 6 - my private phone, WiFi controlled by NFC + Tasker (enables WiFi at home at office, turned off elsewhere) and Bluetooth when connected to my car audio (enables WiFi Hotspot on phone). At the office I connect to a guest network that is not open but is not hidden. The app has it as "allowed". Both at home and at work, when the WiFi is enabled the connection fails with "Connection Failure".

Nexus 9 - my private tablet, only uses WiFi (no SIM card so no 3G/4G), but like my work phone the WiFi is always on. The same thing happens as my phone, at home and at work I get "Connection Failure".

Any idea what could be going wrong? I have pure Android devices all on stock ROMs, albeit two are rooted but one isn't. I'm almost at the point of removing the app as it's inconvenient to have to manually sort WiFi everywhere I go.

Another thing to note is that there is an issue with WiFi and 5.x that TitaniumBackup is having to workaround. When it deals with backing up the WiFi settings and access points before when it did them, WiFI would basically stop working and like Pushbit says in their report, only cycling WiFi fixes it. I myself prevented the issue by excluding WiFi from the backups as Google does this for me anyway, but the last two releases of TiBkp have workarounds now for the problem. Perhaps this will help pinpoint the issue.

BramBonne commented 9 years ago

Hi,

Thanks for your report. It indeed seems that this is a known problem in Android 5.1, even occurring on occasions where the app is not running or interfering with the Wi-Fi stack in any way.

I have looked at the Android source code itself, and it seems that commit 6aa8ae4 merged the wpa_supplicant changes that prevent Android from sending out probe requests for non-hidden networks. In other words, if the 'privacy protection' is your reason to have Wi-Fi PrivacyPolice installed, and you are on an Android version > 5.0, you can safely disable this option without worrying that your network ID gets captured passively. Active protection (using MAC addresses) still requires Wi-Fi PrivacyPolice to be enabled, though.

All this being said, I do not know of a way in which the problem you describe could be solved (let alone if it can be solved by an application). Any suggestions are welcome. I'll also happily review and accept patches.

I hope my explanation was clear. Please let me know if anything is not, and feel free to re-open this issue if you think this is a problem that can be solved from within the app.

Best regards, Bram

pushbit commented 9 years ago

I tried the app again, this time with the 'Privacy protection' option switched off. But the device still will not automatically reconnect to Wi-Fi when returning within range. So I don't think I'll be using the app any more, but thanks for letting us know that Android 5.1 has taken steps towards increasing Wi-Fi privacy.

BramBonne commented 9 years ago

Hi Pushbit,

My explanation might have been a bit confusing, but what I wanted to say was that Android 5.1 seems to have this issue even on devices where Wi-Fi PrivacyPolice is not installed.

Please let me know if uninstalling solved the problem for you.

Best regards, Bram

pushbit commented 9 years ago

Uninstalling does solve the problem for me. Wi-Fi then automatically reconnects when I'm in range. It's only when the app is installed that Wi-Fi stops automatically reconnecting.

BramBonne commented 9 years ago

Thanks for your feedback. This seems to indicate that the issue is indeed with applications interfacing with the Wi-Fi stack (and that it could very well be that the other test subjects had some other application doing this installed on their phones). I'll look into it when I find some time.

herrfeuer commented 9 years ago

I had the same Issues with Android 5.1 (CM Nightlies). Uninstalling helped me too.

paulcgt commented 9 years ago

@Taomyn, you're a gem. After an upgrade to CyanogenMod 5.1 (on my OnePlus 1), the device refused to connect to my known WiFi router.

Turning WiFi off and on would not resolve the problem. For a while shutting down the phone, and then starting it again (ie. not simply rebooting) worked, but this evening that stopped working.

I tried forgetting the network, manually entering network config details, changing the AP channel - none of those resolved the issue.

Finally, I uninstalled TitaniumBackup after reading your post above. After rebooting, my phone now connects and no longer fails to connect after losing the WiFi signal.

Thanks for your comment!

BramBonne commented 9 years ago

Reopening based on comments by @raulsiles in issue #22 .

jamorford commented 9 years ago

Would it be possible to detect when Android flags a network as "Wi-Fi Connection Failure" and remove the flag or explicitly connect with it? If not with the API, with Xposed or Root?

BramBonne commented 9 years ago

I added some extra code to work around Android's hesitation to reconnect, by checking whether the system is reconnecting (after the call to WifiManager.reconnect()), and if not force a reassociation.

Could one of you pull the latest version and check that the issue does not occur on your device anymore? Thanks.

raulsiles commented 9 years ago

Hi Bram, Could you please send me an APK for testing purposes in Android 6.0?

Cheers,

Raul Siles

On 09 Nov 2015, at 11:07, Bram Bonné notifications@github.com wrote:

I added some extra code to work around Android's hesitation to reconnect, by checking whether the system is reconnecting (after the call to WifiManager.reconnect()), and if not force a reassociation.

Could one of you pull the latest version and check that the issue does not occur on your device anymore? Thanks.

— Reply to this email directly or view it on GitHub.

BramBonne commented 9 years ago

Hi Raul,

I went ahead and uploaded the new version to the Play store. Your device should get the upgrade in a few minutes.

jamorford commented 9 years ago

I can confirm version 2.1.1 is now working on Android 5.1.1 also. Thanks!

raulsiles commented 9 years ago

Hi Bram, I can confirm that Wi-Fi Privacy Police version 2.1.1, running in Android 6.0, seems to reconnect back to well-known Wi-Fi networks ;)

BramBonne commented 9 years ago

Wonderful! Thanks for testing! Time to close this issue :-)