summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-09-12 11:33:15 -0700
committerOscar Shu <xshu@google.com>2019-10-15 00:29:04 +0000
commit4892c0b7b6b65584ce7574bf18053ecbba79e024 (patch)
treeda415a462aedd1a3b03a195c4c2b386637a0761c /service
parent7957387b5d459386191cf45ca90e45446ed13f93 (diff)
[MAC rand] Avoid null Object of mac address
Bug: 140309663 Test: unit tests Merged-In: I914a2678e62f1e2ef6dc1b358a76a306b9cc0cc4 Change-Id: Ibf281c5e25c21c17652d718c346c8b560aedcc72 (cherry picked from commit I914a2678e62f1e2ef6dc1b358a76a306b9cc0cc4)
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index b80371285..fa2f4a980 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -3380,12 +3380,14 @@ public class ClientModeImpl extends StateMachine {
Log.e(TAG, "No config to change MAC address to");
return;
}
- MacAddress currentMac = MacAddress.fromString(mWifiNative.getMacAddress(mInterfaceName));
+ String currentMacString = mWifiNative.getMacAddress(mInterfaceName);
+ MacAddress currentMac = currentMacString == null ? null :
+ MacAddress.fromString(currentMacString);
MacAddress newMac = config.getOrCreateRandomizedMacAddress();
mWifiConfigManager.setNetworkRandomizedMacAddress(config.networkId, newMac);
if (!WifiConfiguration.isValidMacAddressForRandomization(newMac)) {
Log.wtf(TAG, "Config generated an invalid MAC address");
- } else if (currentMac.equals(newMac)) {
+ } else if (newMac.equals(currentMac)) {
Log.d(TAG, "No changes in MAC address");
} else {
mWifiMetrics.logStaEvent(StaEvent.TYPE_MAC_CHANGE, config);
@@ -3393,7 +3395,7 @@ public class ClientModeImpl extends StateMachine {
mWifiNative.setMacAddress(mInterfaceName, newMac);
Log.d(TAG, "ConnectedMacRandomization SSID(" + config.getPrintableSsid()
+ "). setMacAddress(" + newMac.toString() + ") from "
- + currentMac.toString() + " = " + setMacSuccess);
+ + currentMacString + " = " + setMacSuccess);
}
}