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

Commit 0b0f32ae authored by Ecco Park's avatar Ecco Park Committed by Android (Google) Code Review
Browse files

Merge "passpoint-r2: change the return type of getAllMatchingWifiConfigs"

parents 534d43ea 05df45db
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -3895,7 +3895,6 @@ package android.net.wifi {
    method public void disable(int, android.net.wifi.WifiManager.ActionListener);
    method public void disableEphemeralNetwork(java.lang.String);
    method public void forget(int, android.net.wifi.WifiManager.ActionListener);
    method public java.util.List<android.net.wifi.WifiConfiguration> getAllMatchingWifiConfigs(java.util.List<android.net.wifi.ScanResult>);
    method public java.util.List<android.net.wifi.WifiConfiguration> getPrivilegedConfiguredNetworks();
    method public android.net.wifi.WifiConfiguration getWifiApConfiguration();
    method public int getWifiApState();
+3 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.net.wifi;


import android.content.pm.ParceledListSlice;

import android.net.wifi.hotspot2.OsuProvider;
@@ -63,7 +62,7 @@ interface IWifiManager

    ParceledListSlice getPrivilegedConfiguredNetworks();

    List<WifiConfiguration> getAllMatchingWifiConfigs(in List<ScanResult> scanResult);
    Map getAllMatchingFqdnsForScanResults(in List<ScanResult> scanResult);

    List<OsuProvider> getMatchingOsuProviders(in List<ScanResult> scanResult);

@@ -77,6 +76,8 @@ interface IWifiManager

    List<PasspointConfiguration> getPasspointConfigurations();

    List<WifiConfiguration> getWifiConfigsForPasspointProfiles(in List<String> fqdnList);

    void queryPasspointIcon(long bssid, String fileName);

    int matchProviderWithCurrentNetwork(String fqdn);
+21 −6
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.os.Messenger;
import android.os.RemoteException;
import android.os.WorkSource;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;

import com.android.internal.annotations.GuardedBy;
@@ -1191,25 +1192,39 @@ public class WifiManager {
    }

    /**
     * Returns all matching WifiConfigurations for a given list of ScanResult.
     * Returns a list of all matching WifiConfigurations for a given list of ScanResult.
     *
     * An empty list will be returned when no configurations are installed or if no configurations
     * match the ScanResult.

     *
     * @param scanResults a list of scanResult that represents the BSSID
     * @return A list of {@link WifiConfiguration} that can have duplicate entries.
     * @return List that consists of {@link WifiConfiguration} and corresponding scanResults.
     * @throws UnsupportedOperationException if Passpoint is not enabled on the device.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
    public List<WifiConfiguration> getAllMatchingWifiConfigs(
    public List<Pair<WifiConfiguration, List<ScanResult>>> getAllMatchingWifiConfigs(
            @NonNull List<ScanResult> scanResults) {
        List<Pair<WifiConfiguration, List<ScanResult>>> configs = new ArrayList<>();
        try {
            return mService.getAllMatchingWifiConfigs(scanResults);
            Map<String, List<ScanResult>> results = mService.getAllMatchingFqdnsForScanResults(
                    scanResults);
            if (results.isEmpty()) {
                return configs;
            }
            List<WifiConfiguration> wifiConfigurations =
                    mService.getWifiConfigsForPasspointProfiles(new ArrayList<>(results.keySet()));
            for (WifiConfiguration configuration : wifiConfigurations) {
                List<ScanResult> scanResultList = results.get(configuration.FQDN);
                if (scanResultList != null) {
                    configs.add(Pair.create(configuration, scanResultList));
                }
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }

        return configs;
    }

    /**
+7 −1
Original line number Diff line number Diff line
@@ -106,7 +106,8 @@ public abstract class AbstractWifiService extends IWifiManager.Stub {
    }

    @Override
    public List<WifiConfiguration> getAllMatchingWifiConfigs(List<ScanResult> scanResults) {
    public Map<String, List<ScanResult>> getAllMatchingFqdnsForScanResults(
            List<ScanResult> scanResults) {
        throw new UnsupportedOperationException();
    }

@@ -154,6 +155,11 @@ public abstract class AbstractWifiService extends IWifiManager.Stub {
        throw new UnsupportedOperationException();
    }

    @Override
    public List<WifiConfiguration> getWifiConfigsForPasspointProfiles(List<String> fqdnList) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void queryPasspointIcon(long bssid, String fileName) {
        throw new UnsupportedOperationException();
+11 −3
Original line number Diff line number Diff line
@@ -77,7 +77,9 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Unit tests for {@link android.net.wifi.WifiManager}.
@@ -1274,14 +1276,20 @@ i * Verify that a call to cancel WPS immediately returns a failure.
    }

    /**
     * Check the call to getAllMatchingWifiConfigs calls getAllMatchingWifiConfigs of WifiService
     * with the provided a list of ScanResult.
     * Check the call to getAllMatchingWifiConfigs calls getAllMatchingFqdnsForScanResults and
     * getWifiConfigsForPasspointProfiles of WifiService in order.
     */
    @Test
    public void testGetAllMatchingWifiConfigs() throws Exception {
        Map<String, List<ScanResult>> fqdns = new HashMap<>();
        fqdns.put("www.test.com", new ArrayList<>());
        when(mWifiService.getAllMatchingFqdnsForScanResults(any(List.class))).thenReturn(fqdns);
        InOrder inOrder = inOrder(mWifiService);

        mWifiManager.getAllMatchingWifiConfigs(new ArrayList<>());

        verify(mWifiService).getAllMatchingWifiConfigs(any(List.class));
        inOrder.verify(mWifiService).getAllMatchingFqdnsForScanResults(any(List.class));
        inOrder.verify(mWifiService).getWifiConfigsForPasspointProfiles(any(List.class));
    }

    /**