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

Commit 057e7894 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removed duplicate Passpoint entries in saved networks page"

parents ea175efe 6e711c80
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -307,6 +307,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
    public AccessPoint(Context context, WifiConfiguration config) {
    public AccessPoint(Context context, WifiConfiguration config) {
        mContext = context;
        mContext = context;
        loadConfig(config);
        loadConfig(config);
        updateKey();
    }
    }


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


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


    /** Updates {@link #mKey} and should only called upon object creation/initialization. */
    /** 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
        // TODO(sghuman): Consolidate Key logic on ScanResultMatchInfo
        if (isPasspoint()) {
        if (isPasspoint()) {
            mKey = getKey(mConfig);
            mKey = getKey(mConfig);
        } else if (isPasspointConfig()) {
            mKey = getKey(mFqdn);
        } else if (isOsuProvider()) {
        } else if (isOsuProvider()) {
            mKey = getKey(mOsuProvider);
            mKey = getKey(mOsuProvider);
        } else { // Non-Passpoint AP
        } else { // Non-Passpoint AP
@@ -618,14 +621,21 @@ public class AccessPoint implements Comparable<AccessPoint> {
     */
     */
    public static String getKey(WifiConfiguration config) {
    public static String getKey(WifiConfiguration config) {
        if (config.isPasspoint()) {
        if (config.isPasspoint()) {
            return new StringBuilder()
            return getKey(config.FQDN);
                    .append(KEY_PREFIX_FQDN)
                    .append(config.FQDN).toString();
        } else {
        } else {
            return getKey(removeDoubleQuotes(config.SSID), config.BSSID, getSecurity(config));
            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.
     * Returns the AccessPoint key corresponding to the OsuProvider.
     */
     */
+8 −0
Original line number Original line Diff line number Diff line
@@ -1250,6 +1250,14 @@ public class AccessPointTest {
        AccessPoint passpointAp = new AccessPoint(mContext, spyConfig, mScanResults, null);
        AccessPoint passpointAp = new AccessPoint(mContext, spyConfig, mScanResults, null);
        assertThat(passpointAp.getKey()).isEqualTo(AccessPoint.getKey(spyConfig));
        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();
        OsuProvider provider = createOsuProvider();
        AccessPoint osuAp = new AccessPoint(mContext, provider, mScanResults);
        AccessPoint osuAp = new AccessPoint(mContext, provider, mScanResults);
        assertThat(osuAp.getKey()).isEqualTo(AccessPoint.getKey(provider));
        assertThat(osuAp.getKey()).isEqualTo(AccessPoint.getKey(provider));