Don't display an invalid Wi-Fi MAC address
Only display the WifiInfo MAC address if it is a valid address. Otherwise, display "Unavailable". The underlying WifiInfo class now has a default value, and a method that can be used to test whether or not the contained address is valid. This change uses this test and avoids having the confusing default address displayed. Bug: 32478606 Test: Manual: Turn off WiFi and reboot -- make sure "Unavailable" is displayed as the Wi-Fi MAC Address as opposed to "02:00:00:00:00:00" Change-Id: I912804eb65735375e0ca3c4618a6399543f33b57
This commit is contained in:
@@ -280,7 +280,8 @@ public class Status extends SettingsPreferenceFragment {
|
||||
|
||||
private void setWifiStatus() {
|
||||
WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
|
||||
String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
|
||||
boolean hasMacAddress = wifiInfo != null && wifiInfo.hasRealMacAddress();
|
||||
String macAddress = hasMacAddress ? wifiInfo.getMacAddress() : null;
|
||||
mWifiMacAddress.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress : mUnavailable);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user