Currently, I am working on connecting specific WiFi in the source code.
But the problem is, since Android 10, the default setting is to set a random macArress. Yeah i forcibly set the mac adrress to wifi info or I want to turn off random mac adrress option
this is my code
if(BasicInfo.wifiEncryption == BasicInfo.WPA_PSK){ BasicInfo.debug(TAG,"setWiFiConfigForJellyBean :BasicInfo.WPA_PSK"); config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); config.preSharedKey = "\"".concat(BasicInfo.WIFI_PASSWORD).concat("\""); BasicInfo.debug(TAG,"BasicInfo.WPA_PSK Password :" + BasicInfo.WIFI_PASSWORD); }
It's only possible on non Play Store applications.
There is global settings called wifi_connected_mac_randomization_enabled, but
android.permission.WRITE_SETTINGS granted to modify it.Here is an example how you can use it:
public static void setMacRandomization(Context context, boolean enabled){
ContentResolver cr = Objects.requireNonNull(context).getContentResolver();
try {
Settings.Global.putString(cr, "wifi_connected_mac_randomization_enabled", enabled ? "1" : "0");
} catch (Exception e) {
//Missing permission or setting not found on this device or something else
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With