diff options
author | Roshan Pius <rpius@google.com> | 2016-02-25 00:10:00 +0000 |
---|---|---|
committer | Android Partner Code Review <android-gerrit-partner@google.com> | 2016-02-25 00:10:00 +0000 |
commit | 1f8a9c21526f7cfd518fdcfa1e9ff42a1253f38d (patch) | |
tree | 3c2e85d55f1316931ce480ba0cdce9134164b0f5 /service | |
parent | e08c8038a432eb68a3493abdfa7e69d92bad3b80 (diff) | |
parent | 3d1baff308fd209648a4d3cf5c02a8bfd1a98a52 (diff) |
Merge "WifiConfigManager: Add SupplicantBridge callbacks" into mm-wireless-dev
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 54 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java | 33 |
2 files changed, 56 insertions, 31 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 6bef3bd5b..8ea062e18 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -476,6 +476,8 @@ public class WifiConfigManager { private final AnqpCache mAnqpCache; private final SupplicantBridge mSupplicantBridge; + private final SupplicantBridgeCallbacks mSupplicantBridgeCallbacks; + private final PasspointManagementObjectManager mMOManager; private final boolean mEnableOsuQueries; private final SIMAccessor mSIMAccessor; @@ -484,6 +486,32 @@ public class WifiConfigManager { private FrameworkFacade mFacade; private Clock mClock; + private class SupplicantBridgeCallbacks implements SupplicantBridge.SupplicantBridgeCallbacks { + @Override + public void notifyANQPResponse(ScanDetail scanDetail, + Map<Constants.ANQPElementType, ANQPElement> anqpElements) { + updateAnqpCache(scanDetail, anqpElements); + if (anqpElements == null || anqpElements.isEmpty()) { + return; + } + scanDetail.propagateANQPInfo(anqpElements); + + Map<HomeSP, PasspointMatch> matches = matchNetwork(scanDetail, false); + Log.d(Utils.hs2LogTag(getClass()), scanDetail.getSSID() + " pass 2 matches: " + + toMatchString(matches)); + + cacheScanResultForPasspointConfigs(scanDetail, matches, null); + } + @Override + public void notifyIconFailed(long bssid) { + Intent intent = new Intent(WifiManager.PASSPOINT_ICON_RECEIVED_ACTION); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); + intent.putExtra(WifiManager.EXTRA_PASSPOINT_ICON_BSSID, bssid); + mContext.sendBroadcastAsUser(intent, UserHandle.ALL); + } + + } + private class SupplicantSaver implements WifiEnterpriseConfig.SupplicantSaver { private final int mNetId; private final String mSetterSSID; @@ -677,7 +705,8 @@ public class WifiConfigManager { mMOManager = new PasspointManagementObjectManager(new File(PPS_FILE), hs2on); mEnableOsuQueries = true; mAnqpCache = new AnqpCache(mClock); - mSupplicantBridge = new SupplicantBridge(mWifiNative, this); + mSupplicantBridgeCallbacks = new SupplicantBridgeCallbacks(); + mSupplicantBridge = new SupplicantBridge(mWifiNative, mSupplicantBridgeCallbacks); mScanDetailCaches = new HashMap<>(); mSIMAccessor = new SIMAccessor(mContext); @@ -3341,13 +3370,6 @@ public class WifiConfigManager { } - public void notifyIconFailed(long bssid) { - Intent intent = new Intent(WifiManager.PASSPOINT_ICON_RECEIVED_ACTION); - intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); - intent.putExtra(WifiManager.EXTRA_PASSPOINT_ICON_BSSID, bssid); - mContext.sendBroadcastAsUser(intent, UserHandle.ALL); - } - public void wnmFrameReceived(WnmData event) { // %012x HS20-SUBSCRIPTION-REMEDIATION "%u %s", osu_method, url // %012x HS20-DEAUTH-IMMINENT-NOTICE "%u %u %s", code, reauth_delay, url @@ -3372,22 +3394,6 @@ public class WifiConfigManager { mContext.sendBroadcastAsUser(intent, UserHandle.ALL); } - public void notifyANQPResponse(ScanDetail scanDetail, - Map<Constants.ANQPElementType, ANQPElement> anqpElements) { - - updateAnqpCache(scanDetail, anqpElements); - if (anqpElements == null || anqpElements.isEmpty()) { - return; - } - scanDetail.propagateANQPInfo(anqpElements); - - Map<HomeSP, PasspointMatch> matches = matchNetwork(scanDetail, false); - Log.d(Utils.hs2LogTag(getClass()), scanDetail.getSSID() + - " pass 2 matches: " + toMatchString(matches)); - - cacheScanResultForPasspointConfigs(scanDetail, matches, null); - } - private void updateAnqpCache(ScanDetail scanDetail, Map<Constants.ANQPElementType,ANQPElement> anqpElements) { diff --git a/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java b/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java index 85f6935cc..a4243a41e 100644 --- a/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java +++ b/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java @@ -4,7 +4,6 @@ import android.util.Base64; import android.util.Log; import com.android.server.wifi.ScanDetail; -import com.android.server.wifi.WifiConfigManager; import com.android.server.wifi.WifiNative; import com.android.server.wifi.anqp.ANQPElement; import com.android.server.wifi.anqp.ANQPFactory; @@ -30,7 +29,7 @@ import java.util.Map; public class SupplicantBridge { private final WifiNative mSupplicantHook; - private final WifiConfigManager mConfigStore; + private final SupplicantBridgeCallbacks mCallbacks; private final Map<Long, ScanDetail> mRequestMap = new HashMap<>(); private static final int IconChunkSize = 1400; // 2K*3/4 - overhead @@ -52,14 +51,34 @@ public class SupplicantBridge { sWpsNames.put("hs20_osu_providers_list", Constants.ANQPElementType.HSOSUProviders); } + /** + * Interface to be implemented by the client to receive callbacks from SupplicantBridge. + */ + public interface SupplicantBridgeCallbacks { + /** + * Response from supplicant bridge for the initiated request. + * @param scanDetail + * @param anqpElements + */ + void notifyANQPResponse( + ScanDetail scanDetail, + Map<Constants.ANQPElementType, ANQPElement> anqpElements); + + /** + * Notify failure. + * @param bssid + */ + void notifyIconFailed(long bssid); + } + public static boolean isAnqpAttribute(String line) { int split = line.indexOf('='); return split >= 0 && sWpsNames.containsKey(line.substring(0, split)); } - public SupplicantBridge(WifiNative supplicantHook, WifiConfigManager configStore) { + public SupplicantBridge(WifiNative supplicantHook, SupplicantBridgeCallbacks callbacks) { mSupplicantHook = supplicantHook; - mConfigStore = configStore; + mCallbacks = callbacks; } public static Map<Constants.ANQPElementType, ANQPElement> parseANQPLines(List<String> lines) { @@ -161,7 +180,7 @@ public class SupplicantBridge { if (scanDetail == null) { if (!success) { - mConfigStore.notifyIconFailed(bssid); + mCallbacks.notifyIconFailed(bssid); } return; } @@ -171,7 +190,7 @@ public class SupplicantBridge { Map<Constants.ANQPElementType, ANQPElement> elements = parseWPSData(bssData); Log.d(Utils.hs2LogTag(getClass()), String.format("%s ANQP response for %012x: %s", success ? "successful" : "failed", bssid, elements)); - mConfigStore.notifyANQPResponse(scanDetail, success ? elements : null); + mCallbacks.notifyANQPResponse(scanDetail, success ? elements : null); } catch (IOException ioe) { Log.e(Utils.hs2LogTag(getClass()), "Failed to parse ANQP: " + @@ -181,7 +200,7 @@ public class SupplicantBridge { Log.e(Utils.hs2LogTag(getClass()), "Failed to parse ANQP: " + rte.toString() + ": " + bssData, rte); } - mConfigStore.notifyANQPResponse(scanDetail, null); + mCallbacks.notifyANQPResponse(scanDetail, null); } private static String escapeSSID(NetworkDetail networkDetail) { |