Default Randomized MAC Address to 0:0:0:0:0:0 in WifiConfig
Set the default value of Randomized MAC address as 0:0:0:0:0:0 instead of null. Making this change to simplify storing randomized address to XML for permanent storage. Without this change, will need to manually check if the value is null during MacAddress<->XML conversion. Bug: 72753415 Test: Unittest. Change-Id: I6edf486360e267acec9f8a343386444be2ea99fa
This commit is contained in:
@@ -917,6 +917,9 @@ public class WifiConfiguration implements Parcelable {
|
||||
* Does not guarantee that the returned address is valid for use.
|
||||
*/
|
||||
public MacAddress getRandomizedMacAddress() {
|
||||
if (mRandomizedMacAddress == null) {
|
||||
mRandomizedMacAddress = MacAddress.ALL_ZEROS_ADDRESS;
|
||||
}
|
||||
return mRandomizedMacAddress;
|
||||
}
|
||||
|
||||
@@ -1617,6 +1620,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
creatorUid = -1;
|
||||
shared = true;
|
||||
dtimInterval = 0;
|
||||
mRandomizedMacAddress = MacAddress.ALL_ZEROS_ADDRESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -176,6 +176,8 @@ public class WifiConfigurationTest {
|
||||
@Test
|
||||
public void testGetOrCreateRandomizedMacAddress_SavesAndReturnsSameAddress() {
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
assertEquals(MacAddress.ALL_ZEROS_ADDRESS, config.getRandomizedMacAddress());
|
||||
|
||||
MacAddress firstMacAddress = config.getOrCreateRandomizedMacAddress();
|
||||
MacAddress secondMacAddress = config.getOrCreateRandomizedMacAddress();
|
||||
|
||||
@@ -185,6 +187,8 @@ public class WifiConfigurationTest {
|
||||
@Test
|
||||
public void testSetRandomizedMacAddress_ChangesSavedAddress() {
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
assertEquals(MacAddress.ALL_ZEROS_ADDRESS, config.getRandomizedMacAddress());
|
||||
|
||||
MacAddress macToChangeInto = MacAddress.createRandomUnicastAddress();
|
||||
config.setRandomizedMacAddress(macToChangeInto);
|
||||
MacAddress macAfterChange = config.getOrCreateRandomizedMacAddress();
|
||||
|
||||
Reference in New Issue
Block a user