Android blacklist wifi bssid

1.3k Views Asked by At

I have a problem banning a specific bssid. I can see there is a class called WifiNative that was in api 19 but not able to access it:https://android.googlesource.com/platform/frameworks/base/+/kitkat-release/wifi/java/android/net/wifi/WifiNative.java

Is there any other way anyone knows of to do this? Maybe via JNI? Any android system libraries that can be used? c,c++?

1

There are 1 best solutions below

1
em_ On
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
newWifiInfo = wifiManager.getConnectionInfo();

from there you can get the BSSID by doing

newWifiInfo.getBSSID()

then "blacklist" by turning off the wifi via

wifiManager.setWifiEnabled(false)

Also don't forget your permissions

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>

If you want more control over your wifi state, you can use the following library to "sniff" your connection and other things

https://github.com/pwittchen/ReactiveNetwork