You will get the wifi mac address(for some devices such as Xiaomi, this will return the wifi-direct mac address) by using the following code, regardless of whether you used a randomized address when you tried to connect to the wifi or not, and regardless of whether the wifi was turned on or off.
I used a method from the link below, and added a small modification to get the exact address instead of the randomized one:
Getting MAC address in Android 6.0
public static String getMacAddr() {
StringBuilder res1 = new StringBuilder();
try {
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all) {
if (!nif.getName().equalsIgnoreCase("p2p0")) continue;
byte[] macBytes = nif.getHardwareAddress();
if (macBytes == null) {
continue;
}
res1 = new StringBuilder();
for (byte b : macBytes) {
res1.append(String.format("%02X:",b));
}
if (res1.length() > 0) {
res1.deleteCharAt(res1.length() - 1);
}
}
} catch (Exception ex) {
}
return res1.toString();
}