Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f10fb95 authored by Jong Wook Kim's avatar Jong Wook Kim
Browse files

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
parent 0ab4ea3e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;
    }

    /**
+4 −0
Original line number Diff line number Diff line
@@ -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();