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

Erratic behaviour on Android Marshmallow (6.0.1) #30

Closed alvarogzp closed 8 years ago

alvarogzp commented 8 years ago

Hello.

First, thanks to the developer(s) for such great app. It makes our devices a little safer.

Here is the problem: I have been using the Google Play version of the app for several months without problem (under Android Lollipop).

Today, I updated my Nexus 6 to Mashmallow, and when I have any of the two main switches of the app enabled and the app is not in the foreground, my device disconnects from WiFi. In Android WiFi settings, it says "Authentication error". When I disable the two switches or the app is in the foreground, the device correctly connects to my WiFi network. I am using my home WiFi network, which is on the list of allowed hotspots.

Do you have any reports of the app failing on Marshmallow?

Please, tell me if you want more info.

polyzen commented 8 years ago

This happens to me as well.

OhSoGood commented 8 years ago

Same for me. Also happen on a Lollipop device

Diapolo commented 8 years ago

I recently upgraded to CM13 and can confirm the reported issues. Currently I'm unable to use the great app because it always disconnects me from WiFi :-/. I'm also willing to help testing or give more information.

renekliment commented 8 years ago

Same here unfortunately :-/ Please have a look into this, I love this app. I'm also willing to help testing.

Diapolo commented 8 years ago

Seems development has halted... :-/.

BramBonne commented 8 years ago

Hi all,

Thank you for your reports! I'm quite busy with other projects now, which is why development has been a bit slow lately.

The good news is that the first setting in PrivacyPolice (which prevents networks from leaking) is now part of Android's code, which means that you're secure by default on that issue.

For the other functionality, it seems that indeed PrivacyPolice is encountering some issues when running on Android 6.0 due to the new Wi-Fi stack. I do welcome anyone to contribute (you can see from past issues that I'm very welcoming about patches as long as they're properly structured). The code should be pretty straightforward to understand, and you may always contact me if something is not immediately clear.

If I find some time, I'll try to look into the issue myself.

polyzen commented 8 years ago

@Brambonne, that is great news. Thank you very much :)

Dyras commented 8 years ago

Marvelous news BramBonne, looking forward to updates! Didn't know the first option is now part of Android so thanks for sharing!

jomo commented 8 years ago

Also running into this issue after updating to Marshmallow when any of PrivacyPolice's options are enabled. I've captured a logcat once with PrivacyPolice disabled and once with Data Protection enabled. The log files are in this gist, maybe anyone can figure something out?

jomo commented 8 years ago

When I disable the two switches or the app is in the foreground, the device correctly connects to my WiFi network.

Interesting find @alvarogzp. I checked again and can confirm this behavior. Most notable change in logcat with the app in foreground is that the scan result list is not empty.

Some changes in Android 6.0 that might cause this:

BramBonne commented 8 years ago

Hi jomo,

Thank you for your thorough research!

You seem to have found the reason why I wasn't able to reproduce the issue on my own devices (even though other people were affected by the same issue): scan results on my phone seem to be populated even when the app is not in the foreground.

Could you tell me which devices and software versions (notably, custom ROMs) you are running? My device is a OnePlus One, with a custom CM13 version running on top.

As for what might be causing this: your guess is as good as mine. I'm pretty sure that Android 6's runtime permissions are not the culprit, as they should only be activated if the app has a targetSdkVersion of 23 or up (the target for PrivacyPolice is still API level 22, or Android 5.1). I don't expect the randomized MAC address to be a problem either, because this would not impact the list of available networks as they are passed on to userspace.

What might be the case is that (some implementations/variations of) Android 6.0 do not pass the scan results to userspace when the application requesting them is not in foreground. Ideally, I'd need to find a device that is affected by this issue so I could test it myself. I'll ask around to see if someone I know has such a device lying around somewhere.

jomo commented 8 years ago

I'm using an LG/Google Nexus 4 'mako' with CM13.0 | 20160316-SNAPSHOT-ZNH0EAO1QE.

Regarding runtime permissions, Google points out:

Even if your app is not targeting Android 6.0 (API level 23), you should test your app under the new permissions model.

Perhaps we need to wait for STATE_SCAN_RESULTS_AVAILABLE?

I don't have much experience with Android development but I can probably try testing some stuff on my device later today.

BramBonne commented 8 years ago

Thanks for the information!

The app actually already waits for STATE_SCAN_RESULTS_AVAILABLE, because ScanResultChecker's onReceive() function is called exactly when this broadcast is received.

If I find the time, I'll try and target API level 23 to make sure runtime permissions are respected.

In meanwhile, feel free to test out some things on your own device. I don't have a Nexus 4 available here at the moment, and a Nexus 5 (completely stock) seems to work fine.

Dyras commented 8 years ago

I have this problem and I have a Moto G 2015 completely stock, if that's helpful at all.

BramBonne commented 8 years ago

I found a friend who seemed to have the same issue. Could any of you test the latest version on the repo? I've also made it available as an apk to test.

ghost commented 8 years ago

@BramBonne Seems the link is broken as github is adding an own link in front. The apk link here works: https://brambonne.com/privacypolice-debug.apk

Currently testing it with CM13 on a Moto G 2015 but the issue is still there. The app needs to be in foreground or the switches needs to be disabled.

I'm not familiar with Android development but could provide more debugging info / logs when needed.

jomo commented 8 years ago

Haven't tested the latest commits or looked at my logs yet, but I found out that the issue is gone when Location is enabled.

On CM13 there's also a "Scanning" option (Location -> menu) which reads "Improve location by allowing system apps and services to detect Wi-Fi networks at any time", however this option doesn't seem to change anything.

BramBonne commented 8 years ago

@jomo it seems like you're on to something. The reason why the issue didn't occur on my phone might be because I have location services enabled all the time. I'll try disabling it to see what happens.

If others want to help test this: please disable your location services, wait until Wi-Fi stops functioning, and send me a logcat.

BramBonne commented 8 years ago

I've put up a new apk for testing here. It should warn you if location access is disabled. Let me know if anything seems off. If not, I'll be releasing this version to app stores soon.

ghost commented 8 years ago

Yes, i have also location services disabled most of the time. So there is no other possibility to run this app now except having location services on all the time?

BramBonne commented 8 years ago

PrivcyPolice (new release) now explicitly asks the user to enable the location, until Google fixes bug 185370. I'm closing this bug, but feel free to re-open if issues persist.

ghost commented 8 years ago

Thanks for the release and the reference to the google bugreport.