'android 10 how to disable Randomized Mac Address in source code

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);

        }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source