1

"02:00:00:00:00:00" does mean that the caller has insufficient permissions to access the BSSID. Why do I have insufficient permission? Whether I input a wrong or the right password it always returns "02:00:00:00:00:00". Even if I wait till the connection is established, it always returns the same value. I also have the permissions set in AndroidManifest.xml:

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

And this Java Code:

WifiConfiguration wifiConfig = new WifiConfiguration();
String ssid = "AndroidAPC572";
wifiConfig.preSharedKey = String.format("\"%s\"", "password");
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
int netId = wifiManager.addNetwork(wifiConfig);
boolean disconnected = wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
boolean reconnected = wifiManager.reconnect();
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
wifiInfo.getBSSID(); //always "02:00:00:00:00:00" / insufficient permission
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Hey Hey
  • 11
  • 3
  • Check out https://stackoverflow.com/questions/21391395/get-ssid-when-wifi-is-connected; I think what applies to SSID also applies to BSSID. – Thomas Mar 08 '20 at 10:30
  • Is it normal that it takes about 10 seconds before I can see at the supplicant state if the authentication was successful? How can I check this faster? If I call supplicant state after 2 seconds its state is FOUR_WAY_HANDSHAKE – Hey Hey Mar 08 '20 at 12:04
  • No idea how common it is, but your code will need to take it into account. You could listen for a `WifiManager.NETWORK_STATE_CHANGED_ACTION` broadcast as shown in the linked question. – Thomas Mar 09 '20 at 09:39

0 Answers0