summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-06-12 22:17:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-06-12 22:17:35 +0000
commit1d094527e82f2e1e4ca1c8883eaf2384ddd7d9dc (patch)
tree2cf41b954eab88d713ea536427a97d8ba234aa1a /service
parent27e0f581a968efc5fec49b761472ebe3649244b9 (diff)
parent94ea8c951f0dd81563e7ea22f878397e75487746 (diff)
Merge changes from topic 'osu_provider_api'
* changes: WifiServiceImpl: add support for retrieving Hotspot 2.0 OSU providers hotspot2: PasspointManager: add support for retrieving OSU providers info hotspot2: anqp: OsuProviderInfo: friendly name and service description selection
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java18
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java27
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java50
-rw-r--r--service/java/com/android/server/wifi/hotspot2/anqp/OsuProviderInfo.java43
4 files changed, 137 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 2dff54a50..3306fb608 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -73,6 +73,7 @@ import android.net.wifi.WifiLinkLayerStats;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.LocalOnlyHotspotCallback;
import android.net.wifi.WifiScanner;
+import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.os.AsyncTask;
import android.os.BatteryStats;
@@ -1537,6 +1538,23 @@ public class WifiServiceImpl extends IWifiManager.Stub {
}
/**
+ * Returns list of OSU (Online Sign-Up) providers associated with the given Passpoint network.
+ *
+ * @param scanResult scanResult of the Passpoint AP
+ * @return List of {@link OsuProvider}
+ */
+ @Override
+ public List<OsuProvider> getMatchingOsuProviders(ScanResult scanResult) {
+ enforceAccessPermission();
+ mLog.trace("getMatchingOsuProviders uid=%").c(Binder.getCallingUid()).flush();
+ if (!mContext.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WIFI_PASSPOINT)) {
+ throw new UnsupportedOperationException("Passpoint not enabled");
+ }
+ return mWifiStateMachine.syncGetMatchingOsuProviders(scanResult, mWifiStateMachineChannel);
+ }
+
+ /**
* see {@link android.net.wifi.WifiManager#addOrUpdateNetwork(WifiConfiguration)}
* @return the supplicant-assigned identifier for the new or updated
* network if the operation succeeds, or {@code -1} if it fails
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 89675b62d..06714c72f 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -75,6 +75,7 @@ import android.net.wifi.WifiSsid;
import android.net.wifi.WpsInfo;
import android.net.wifi.WpsResult;
import android.net.wifi.WpsResult.Status;
+import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.net.wifi.p2p.IWifiP2pManager;
import android.os.BatteryStats;
@@ -600,6 +601,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
// Get the list of installed Passpoint configurations.
static final int CMD_GET_PASSPOINT_CONFIGS = BASE + 108;
+ // Get the list of OSU providers associated with a Passpoint network.
+ static final int CMD_GET_MATCHING_OSU_PROVIDERS = BASE + 109;
+
/* Commands from/to the SupplicantStateTracker */
/* Reset the supplicant state tracker */
static final int CMD_RESET_SUPPLICANT_STATE = BASE + 111;
@@ -1874,6 +1878,22 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
/**
+ * Retrieve a list of {@link OsuProvider} associated with the given AP synchronously.
+ *
+ * @param scanResult The scan result of the AP
+ * @param channel Channel for communicating with the state machine
+ * @return List of {@link OsuProvider}
+ */
+ public List<OsuProvider> syncGetMatchingOsuProviders(ScanResult scanResult,
+ AsyncChannel channel) {
+ Message resultMsg =
+ channel.sendMessageSynchronously(CMD_GET_MATCHING_OSU_PROVIDERS, scanResult);
+ List<OsuProvider> providers = (List<OsuProvider>) resultMsg.obj;
+ resultMsg.recycle();
+ return providers;
+ }
+
+ /**
* Add or update a Passpoint configuration synchronously.
*
* @param channel Channel for communicating with the state machine
@@ -3899,6 +3919,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
case CMD_GET_MATCHING_CONFIG:
replyToMessage(message, message.what);
break;
+ case CMD_GET_MATCHING_OSU_PROVIDERS:
+ replyToMessage(message, message.what, new ArrayList<OsuProvider>());
+ break;
case CMD_IP_CONFIGURATION_SUCCESSFUL:
case CMD_IP_CONFIGURATION_LOST:
case CMD_IP_REACHABILITY_LOST:
@@ -4982,6 +5005,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
replyToMessage(message, message.what,
mPasspointManager.getMatchingWifiConfig((ScanResult) message.obj));
break;
+ case CMD_GET_MATCHING_OSU_PROVIDERS:
+ replyToMessage(message, message.what,
+ mPasspointManager.getMatchingOsuProviders((ScanResult) message.obj));
+ break;
case CMD_RECONNECT:
mWifiConnectivityManager.forceConnectivityScan();
break;
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index f892e7051..3695ba35f 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -33,6 +33,7 @@ import android.graphics.drawable.Icon;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
+import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -47,6 +48,8 @@ import com.android.server.wifi.WifiKeyStore;
import com.android.server.wifi.WifiNative;
import com.android.server.wifi.hotspot2.anqp.ANQPElement;
import com.android.server.wifi.hotspot2.anqp.Constants;
+import com.android.server.wifi.hotspot2.anqp.HSOsuProvidersElement;
+import com.android.server.wifi.hotspot2.anqp.OsuProviderInfo;
import com.android.server.wifi.util.InformationElementUtil;
import com.android.server.wifi.util.ScanResultUtil;
@@ -439,7 +442,13 @@ public class PasspointManager {
InformationElementUtil.getHS2VendorSpecificIE(scanResult.informationElements);
// Lookup ANQP data in the cache.
- long bssid = Utils.parseMac(scanResult.BSSID);
+ long bssid;
+ try {
+ bssid = Utils.parseMac(scanResult.BSSID);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Invalid BSSID provided in the scan result: " + scanResult.BSSID);
+ return new HashMap<Constants.ANQPElementType, ANQPElement>();
+ }
ANQPData anqpEntry = mAnqpCache.getEntry(ANQPNetworkKey.buildKey(
scanResult.SSID, bssid, scanResult.hessid, vsa.anqpDomainID));
if (anqpEntry != null) {
@@ -480,6 +489,45 @@ public class PasspointManager {
}
/**
+ * Return the list of Hosspot 2.0 OSU (Online Sign-Up) providers associated with the given
+ * AP.
+ *
+ * An empty list will be returned when an invalid scan result is provided or no match is found.
+ *
+ * @param scanResult The scan result of the AP
+ * @return List of {@link OsuProvider}
+ */
+ public List<OsuProvider> getMatchingOsuProviders(ScanResult scanResult) {
+ if (scanResult == null) {
+ Log.e(TAG, "Attempt to retrieve OSU providers for a null ScanResult");
+ return new ArrayList<OsuProvider>();
+ }
+ if (!scanResult.isPasspointNetwork()) {
+ Log.e(TAG, "Attempt to retrieve OSU providers for a non-Passpoint AP");
+ return new ArrayList<OsuProvider>();
+ }
+
+ // Lookup OSU Providers ANQP element.
+ Map<Constants.ANQPElementType, ANQPElement> anqpElements = getANQPElements(scanResult);
+ if (!anqpElements.containsKey(Constants.ANQPElementType.HSOSUProviders)) {
+ return new ArrayList<OsuProvider>();
+ }
+
+ HSOsuProvidersElement element =
+ (HSOsuProvidersElement) anqpElements.get(Constants.ANQPElementType.HSOSUProviders);
+ List<OsuProvider> providers = new ArrayList<>();
+ for (OsuProviderInfo info : element.getProviders()) {
+ // TODO(b/62256482): include icon data once the icon file retrieval and management
+ // support is added.
+ OsuProvider provider = new OsuProvider(element.getOsuSsid(), info.getFriendlyName(),
+ info.getServiceDescription(), info.getServerUri(),
+ info.getNetworkAccessIdentifier(), info.getMethodList(), null);
+ providers.add(provider);
+ }
+ return providers;
+ }
+
+ /**
* Dump the current state of PasspointManager to the provided output stream.
*
* @param pw The output stream to write to
diff --git a/service/java/com/android/server/wifi/hotspot2/anqp/OsuProviderInfo.java b/service/java/com/android/server/wifi/hotspot2/anqp/OsuProviderInfo.java
index 85b024e50..8952c5a51 100644
--- a/service/java/com/android/server/wifi/hotspot2/anqp/OsuProviderInfo.java
+++ b/service/java/com/android/server/wifi/hotspot2/anqp/OsuProviderInfo.java
@@ -30,6 +30,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.Objects;
/**
@@ -168,6 +169,28 @@ public class OsuProviderInfo {
return Collections.unmodifiableList(mServiceDescriptions);
}
+ /**
+ * Return the friendly name string from the friendly name list. The string matching
+ * the default locale will be returned if it is found, otherwise the first name in the list
+ * will be returned. A null will be returned if the list is empty.
+ *
+ * @return friendly name string
+ */
+ public String getFriendlyName() {
+ return getI18String(mFriendlyNames);
+ }
+
+ /**
+ * Return the service description string from the service description list. The string
+ * matching the default locale will be returned if it is found, otherwise the first element in
+ * the list will be returned. A null will be returned if the list is empty.
+ *
+ * @return service description string
+ */
+ public String getServiceDescription() {
+ return getI18String(mServiceDescriptions);
+ }
+
@Override
public boolean equals(Object thatObject) {
if (this == thatObject) {
@@ -255,4 +278,24 @@ public class OsuProviderInfo {
payload.position(payload.position() + length);
return subBuffer;
}
+
+ /**
+ * Return the appropriate I18 string value from the list of I18 string values.
+ * The string matching the default locale will be returned if it is found, otherwise the
+ * first string in the list will be returned. A null will be returned if the list is empty.
+ *
+ * @param i18Strings List of I18 string values
+ * @return String matching the default locale, null otherwise
+ */
+ private static String getI18String(List<I18Name> i18Strings) {
+ for (I18Name name : i18Strings) {
+ if (name.getLanguage().equals(Locale.getDefault().getLanguage())) {
+ return name.getText();
+ }
+ }
+ if (i18Strings.size() > 0) {
+ return i18Strings.get(0).getText();
+ }
+ return null;
+ }
}