Add getMatchingScanResults API to get filtered ScanResults for specified

Susgested network configurations.

Bug: 146669408
Test: atest android.net.wifi

Change-Id: I83caebadcc735db2809f58923ede3331d0ab30b2
This commit is contained in:
Steven Liu
2020-01-17 17:09:12 -08:00
parent c8189371f8
commit 315bb8accb
4 changed files with 42 additions and 0 deletions

View File

@@ -7323,6 +7323,7 @@ package android.net.wifi {
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public String[] getFactoryMacAddresses();
method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public java.util.Map<android.net.wifi.hotspot2.OsuProvider,java.util.List<android.net.wifi.ScanResult>> getMatchingOsuProviders(@Nullable java.util.List<android.net.wifi.ScanResult>);
method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public java.util.Map<android.net.wifi.hotspot2.OsuProvider,android.net.wifi.hotspot2.PasspointConfiguration> getMatchingPasspointConfigsForOsuProviders(@NonNull java.util.Set<android.net.wifi.hotspot2.OsuProvider>);
method @NonNull @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_WIFI_STATE}) public java.util.Map<android.net.wifi.WifiNetworkSuggestion,java.util.List<android.net.wifi.ScanResult>> getMatchingScanResults(@NonNull java.util.List<android.net.wifi.WifiNetworkSuggestion>, @Nullable java.util.List<android.net.wifi.ScanResult>);
method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_WIFI_STATE, android.Manifest.permission.READ_WIFI_CREDENTIAL}) public java.util.List<android.net.wifi.WifiConfiguration> getPrivilegedConfiguredNetworks();
method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public android.net.wifi.SoftApConfiguration getSoftApConfiguration();
method public int getVerboseLoggingLevel();

View File

@@ -260,4 +260,9 @@ interface IWifiManager
boolean setWifiConnectedNetworkScorer(in IBinder binder, in IWifiConnectedNetworkScorer scorer);
void clearWifiConnectedNetworkScorer();
/**
* Return the Map of {@link WifiNetworkSuggestion} and the list of <ScanResult>
*/
Map getMatchingScanResults(in List<WifiNetworkSuggestion> networkSuggestions, in List<ScanResult> scanResults, String callingPackage, String callingFeatureId);
}

View File

@@ -2684,6 +2684,34 @@ public class WifiManager {
}
}
/**
* Return the filtered ScanResults which may be authenticated by the suggested network
* configurations.
* @param networkSuggestions The list of {@link WifiNetworkSuggestion}
* @param scanResults The scan results to be filtered, this is optional, if it is null or
* empty, wifi system would use the recent scan results in the system.
* @return The map of {@link WifiNetworkSuggestion} and the list of {@link ScanResult} which
* may be authenticated by the corresponding network configuration.
* @hide
*/
@SystemApi
@RequiresPermission(allOf = {ACCESS_FINE_LOCATION, ACCESS_WIFI_STATE})
@NonNull
public Map<WifiNetworkSuggestion, List<ScanResult>> getMatchingScanResults(
@NonNull List<WifiNetworkSuggestion> networkSuggestions,
@Nullable List<ScanResult> scanResults) {
if (networkSuggestions == null) {
throw new IllegalArgumentException("networkSuggestions must not be null.");
}
try {
return mService.getMatchingScanResults(
networkSuggestions, scanResults,
mContext.getOpPackageName(), mContext.getFeatureId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Check if scanning is always available.
*

View File

@@ -617,4 +617,12 @@ public class BaseWifiService extends IWifiManager.Stub {
public void clearWifiConnectedNetworkScorer() {
throw new UnsupportedOperationException();
}
@Override
public Map<WifiNetworkSuggestion, List<ScanResult>> getMatchingScanResults(
List<WifiNetworkSuggestion> networkSuggestions,
List<ScanResult> scanResults,
String callingPackage, String callingFeatureId) {
throw new UnsupportedOperationException();
}
}