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

Commit 19eabbff authored by xshu's avatar xshu
Browse files

Add randomized MAC (last used)

Makes it clear that when a network is disconnected, the randomized MAC
address shown is the last used one. (ie. it could change in the next
connection depending on whether enhanced MAC randomization is active)

Bug: 170166681
Test: Manually verified that the new text is shown for disconnected
networks.

Change-Id: I4aec47b2de68c077e6fdc7efa96d39e6666d4c86
parent ab45ca09
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2268,6 +2268,8 @@
    <string name="wifi_advanced_device_mac_address_title">Device MAC address</string>
    <!-- Wi-Fi settings screen, advanced, title of the item to show the randomized Wi-Fi MAC address. [CHAR LIMIT=50] -->
    <string name="wifi_advanced_randomized_mac_address_title">Randomized MAC address</string>
    <!-- Wi-Fi settings screen, advanced, title of the item to show the randomized Wi-Fi MAC address when disconnected. [CHAR LIMIT=50] -->
    <string name="wifi_advanced_randomized_mac_address_disconnected_title">Randomized MAC address (last used)</string>
    <!-- Title of the screen to adjust IP settings -->
    <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's current IP address. -->
    <string name="wifi_advanced_ip_address_title">IP address</string>
+10 −4
Original line number Diff line number Diff line
@@ -738,10 +738,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
        }

        mMacAddressPref.setVisible(true);

        mMacAddressPref.setTitle((mWifiEntry.getPrivacy() == WifiEntry.PRIVACY_RANDOMIZED_MAC)
                ? R.string.wifi_advanced_randomized_mac_address_title
                : R.string.wifi_advanced_device_mac_address_title);
        mMacAddressPref.setTitle(getMacAddressTitle());

        if (macAddress.equals(WifiInfo.DEFAULT_MAC_ADDRESS)) {
            mMacAddressPref.setSummary(R.string.device_info_not_available);
@@ -750,6 +747,15 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
        }
    }

    private int getMacAddressTitle() {
        if (mWifiEntry.getPrivacy() == WifiEntry.PRIVACY_RANDOMIZED_MAC) {
            return mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
                    ? R.string.wifi_advanced_randomized_mac_address_title
                    : R.string.wifi_advanced_randomized_mac_address_disconnected_title;
        }
        return R.string.wifi_advanced_device_mac_address_title;
    }

    private void updatePreference(Preference pref, String detailText) {
        if (!TextUtils.isEmpty(detailText)) {
            pref.setSummary(detailText);
+18 −1
Original line number Diff line number Diff line
@@ -814,6 +814,22 @@ public class WifiDetailPreferenceController2Test {
        verify(mMockMacAddressPref).setTitle(R.string.wifi_advanced_device_mac_address_title);
    }

    @Test
    public void macAddressPref_shouldVisibleAsRandomizedForConnectedNetwork() {
        setUpForConnectedNetwork();
        setUpSpyController();
        when(mMockWifiEntry.isSaved()).thenReturn(true);
        when(mMockWifiEntry.getPrivacy()).thenReturn(WifiEntry.PRIVACY_RANDOMIZED_MAC);
        when(mMockWifiEntry.getMacAddress()).thenReturn(RANDOMIZED_MAC_ADDRESS);

        displayAndResume();

        verify(mMockMacAddressPref).setVisible(true);
        verify(mMockMacAddressPref).setSummary(RANDOMIZED_MAC_ADDRESS);
        verify(mMockMacAddressPref).setTitle(
                R.string.wifi_advanced_randomized_mac_address_title);
    }

    @Test
    public void macAddressPref_shouldVisibleAsRandomizedForDisconnectedNetwork() {
        setUpForDisconnectedNetwork();
@@ -825,7 +841,8 @@ public class WifiDetailPreferenceController2Test {

        verify(mMockMacAddressPref).setVisible(true);
        verify(mMockMacAddressPref).setSummary(RANDOMIZED_MAC_ADDRESS);
        verify(mMockMacAddressPref).setTitle(R.string.wifi_advanced_randomized_mac_address_title);
        verify(mMockMacAddressPref).setTitle(
                R.string.wifi_advanced_randomized_mac_address_disconnected_title);
    }

    @Test