Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Oreo 8.0+ Disable Network Permissions Problems

I'm building a Cordova app that needs to access WiFi on Android and disable the currently connected network in order to prevent automatic disconnection from the network i'm having it connect to (since there is no internet).

The problem is that when testing on Android Oreo 8.0+ I am getting this error in adb logcat and I can't figure out what I need to do to fix this:

E/WifiConfigManager: UID 10315 does not have permission to update configuration "Test SSID"WPA_PSK
E/WifiStateMachine: Failed to disable network

These are the perms listed in manifest:

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
<uses-permission android:name="android.permission.INTERNET" />

The OVERRIDE_WIFI_CONFIG perm I found on this post, but that doesn't seem to help in my specific situation: Changing Android hotspot settings

I found this specific error located in this file: https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/master/service/java/com/android/server/wifi/WifiConfigManager.java#984

Which calls canModifyNetwork which I found here: https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/master/service/java/com/android/server/wifi/WifiConfigManager.java#651

Can anybody more experienced with Android help me to resolve this issue, and what needs to be done in order to allow my app to disable networks?

Does this mean that apps are not allowed to disable a network if it wasn't created by the app?? Please help I don't know where to go from here!

I did find this post as well, which references 6.0, but is this true that we're basically completely locked out of disabling networks we didn't create? Android 6.0 Cannot add WifiConfiguration if there is already another WifiConfiguration for that SSID

like image 560
sMyles Avatar asked Jan 17 '18 18:01

sMyles


Video Answer


1 Answers

I am not able to answer your question per se, but I can answer this

Does this mean that apps are not allowed to disable a network if it wasn't created by the app?

That's correct, as according the documentation of the method disableNetwork:

Disable a configured network. The specified network will not be a candidate for associating. This may result in the asynchronous delivery of state change events. Applications are not allowed to disable networks created by other applications.

So if the user has already connected to this network using the Android system, in Oreo you won't be able to disable the network. Though the method disableNetwork returns true or false in the case of success or failure

like image 57
Omar Hezi Avatar answered Sep 20 '22 14:09

Omar Hezi