passpoint-r2: change the return type of getAllMatchingWifiConfigs
This change is required to show the signal level associated with service name on UI for installed passpoint profile as picking strongest one up from matching scanResults. In order to get a map that consists of WifiConfiguration and a list of ScanResults, three steps are required. 1) Gets a map that consists of FQDN(Fully Qualified Domain Name) of a matching Passpoint profile and a list of ScanResults. 2) Gets a list of WifiConfigurations for Passpoint profiles matched a provided list of FQDN. 3) Creates a new map that consists of WifiConfiguration and a list of ScanResult. Bug: 119514793 Test: ./frameworks/base/wifi/tests/runtests.sh Test: tested with R1 AP for installing profile and R2 AP for connection Change-Id: I0d56dbdddae4e365b909b9c8f3eff3b0121dc5de Signed-off-by: Ecco Park <eccopark@google.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user