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

Commit 6e711c80 authored by Quang Luong's avatar Quang Luong
Browse files

Removed duplicate Passpoint entries in saved networks page

The AccessPoint constructor for PasspointConfigurations was not
setting the AccessPoint key. This caused the Saved Networks Page to
not be able to correctly reference the entries for saved Passpoint
networks, causing entries to not disappear after clicking "forget",
or creating duplicate entries whenever the activity was resumed.
Fixing the key updating/getting for PasspointConfigurations solves
this issue.

Bug: 118705403
Test: atest AccessPointTest
Change-Id: I0e49192ef5efa72fd490e4a0ac987e1c0682e3f3
parent f554792c
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
    public AccessPoint(Context context, WifiConfiguration config) {
        mContext = context;
        loadConfig(config);
        updateKey();
    }

    /**
@@ -317,6 +318,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
        mContext = context;
        mFqdn = config.getHomeSp().getFqdn();
        mProviderFriendlyName = config.getHomeSp().getFriendlyName();
        updateKey();
    }

    /**
@@ -355,7 +357,6 @@ public class AccessPoint implements Comparable<AccessPoint> {
        security = getSecurity(config);
        networkId = config.networkId;
        mConfig = config;
        updateKey();
    }

    /** Updates {@link #mKey} and should only called upon object creation/initialization. */
@@ -363,6 +364,8 @@ public class AccessPoint implements Comparable<AccessPoint> {
        // TODO(sghuman): Consolidate Key logic on ScanResultMatchInfo
        if (isPasspoint()) {
            mKey = getKey(mConfig);
        } else if (isPasspointConfig()) {
            mKey = getKey(mFqdn);
        } else if (isOsuProvider()) {
            mKey = getKey(mOsuProvider);
        } else { // Non-Passpoint AP
@@ -618,14 +621,21 @@ public class AccessPoint implements Comparable<AccessPoint> {
     */
    public static String getKey(WifiConfiguration config) {
        if (config.isPasspoint()) {
            return new StringBuilder()
                    .append(KEY_PREFIX_FQDN)
                    .append(config.FQDN).toString();
            return getKey(config.FQDN);
        } else {
            return getKey(removeDoubleQuotes(config.SSID), config.BSSID, getSecurity(config));
        }
    }

    /**
     * Returns the AccessPoint key corresponding to a Passpoint network by its FQDN.
     */
    public static String getKey(String fqdn) {
        return new StringBuilder()
                .append(KEY_PREFIX_FQDN)
                .append(fqdn).toString();
    }

    /**
     * Returns the AccessPoint key corresponding to the OsuProvider.
     */
+8 −0
Original line number Diff line number Diff line
@@ -1250,6 +1250,14 @@ public class AccessPointTest {
        AccessPoint passpointAp = new AccessPoint(mContext, spyConfig, mScanResults, null);
        assertThat(passpointAp.getKey()).isEqualTo(AccessPoint.getKey(spyConfig));

        PasspointConfiguration passpointConfig = new PasspointConfiguration();
        HomeSp homeSp = new HomeSp();
        homeSp.setFqdn("fqdn");
        homeSp.setFriendlyName("Test Provider");
        passpointConfig.setHomeSp(homeSp);
        AccessPoint passpointConfigAp = new AccessPoint(mContext, passpointConfig);
        assertThat(passpointConfigAp.getKey()).isEqualTo(AccessPoint.getKey("fqdn"));

        OsuProvider provider = createOsuProvider();
        AccessPoint osuAp = new AccessPoint(mContext, provider, mScanResults);
        assertThat(osuAp.getKey()).isEqualTo(AccessPoint.getKey(provider));