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

Commit e747f596 authored by Quang Luong's avatar Quang Luong
Browse files

Update Passpoint R1 AccessPoint with R2 config

Made sure to update the WifiConfiguration of a Passpoint AccessPoint
to update the friendly name if a user installs an R2 config over an
R1 config.

Bug: 131840803
Test: atest WifiTrackerTest
Change-Id: I39cd5679b65240dabee0f67df866e34d1700c769
parent c1a72db8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1111,7 +1111,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
     * Return true if this AccessPoint represents a Passpoint provider configuration.
     */
    public boolean isPasspointConfig() {
        return mFqdn != null;
        return mFqdn != null && mConfig == null;
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -712,6 +712,7 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
        if (accessPoint == null) {
            accessPoint = new AccessPoint(mContext, config, homeScans, roamingScans);
        } else {
            accessPoint.update(config);
            accessPoint.setScanResultsPasspoint(homeScans, roamingScans);
        }
        return accessPoint;
+27 −4
Original line number Diff line number Diff line
@@ -314,7 +314,8 @@ public class WifiTrackerTest {

    private List<Pair<WifiConfiguration, Map<Integer, List<ScanResult>>>>
            createPasspointMatchingWifiConfigWithScanResults(
            List<ScanResult> homeList, List<ScanResult> roamingList) {
            List<ScanResult> homeList, List<ScanResult> roamingList,
            String fqdn, String friendlyName) {
        List<Pair<WifiConfiguration, Map<Integer, List<ScanResult>>>> matchingList =
                new ArrayList<>();
        Map<Integer, List<ScanResult>> mapping = new HashMap<>();
@@ -326,7 +327,7 @@ public class WifiTrackerTest {
            mapping.put(WifiManager.PASSPOINT_ROAMING_NETWORK, roamingList);
        }

        matchingList.add(new Pair(buildPasspointConfiguration(FQDN_1, PROVIDER_FRIENDLY_NAME_1),
        matchingList.add(new Pair(buildPasspointConfiguration(fqdn, friendlyName),
                mapping));

        return matchingList;
@@ -1077,7 +1078,7 @@ public class WifiTrackerTest {

        List<AccessPoint> passpointAccessPointsFirstUpdate = tracker.updatePasspointAccessPoints(
                createPasspointMatchingWifiConfigWithScanResults(Arrays.asList(result),
                        null), new ArrayList<>());
                        null, FQDN_1, PROVIDER_FRIENDLY_NAME_1), new ArrayList<>());
        List<AccessPoint> cachedAccessPoints = new ArrayList<>(passpointAccessPointsFirstUpdate);

        int prevRssi = result.level;
@@ -1086,7 +1087,7 @@ public class WifiTrackerTest {

        List<AccessPoint> passpointAccessPointsSecondUpdate = tracker.updatePasspointAccessPoints(
                createPasspointMatchingWifiConfigWithScanResults(Arrays.asList(result),
                        null), cachedAccessPoints);
                        null, FQDN_1, PROVIDER_FRIENDLY_NAME_1), cachedAccessPoints);

        // Verify second update AP is the same object as the first update AP
        assertThat(passpointAccessPointsFirstUpdate.get(0))
@@ -1096,6 +1097,28 @@ public class WifiTrackerTest {
                .isEqualTo((prevRssi + newRssi) / 2);
    }

    /**
     * Verifies that the internal WifiConfiguration of a Passpoint AccessPoint is updated
     */
    @Test
    public void updatePasspointAccessPoints_updatesConfig() {
        WifiTracker tracker = createMockedWifiTracker();

        ScanResult result = buildScanResult1();

        List<AccessPoint> passpointAccessPoints = tracker.updatePasspointAccessPoints(
                createPasspointMatchingWifiConfigWithScanResults(Arrays.asList(result),
                        null, FQDN_1, PROVIDER_FRIENDLY_NAME_1), new ArrayList<>());

        AccessPoint ap = passpointAccessPoints.get(0);
        assertEquals(ap.getTitle(), PROVIDER_FRIENDLY_NAME_1);

        tracker.updatePasspointAccessPoints(
                createPasspointMatchingWifiConfigWithScanResults(Arrays.asList(result),
                        null, FQDN_1, PROVIDER_FRIENDLY_NAME_2), passpointAccessPoints);
        assertEquals(ap.getTitle(), PROVIDER_FRIENDLY_NAME_2);
    }

    /**
     * Verifies that updateOsuAccessPoints will only return AccessPoints whose
     * isOsuProvider() evaluates as true.