summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-02-15 15:32:45 -0800
committerRoshan Pius <rpius@google.com>2017-02-16 10:19:15 -0800
commit773ef3483e18f1afbd9cdce1564add3d89cb21fa (patch)
treed34c29cfabd2f3c478251917675aed8a5ed9e189 /service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java
parent65d8ba5dd551cd132789e8feb270dfc7998dfbdc (diff)
downloadandroid_frameworks_opt_net_wifi-773ef3483e18f1afbd9cdce1564add3d89cb21fa.tar.gz
android_frameworks_opt_net_wifi-773ef3483e18f1afbd9cdce1564add3d89cb21fa.tar.bz2
android_frameworks_opt_net_wifi-773ef3483e18f1afbd9cdce1564add3d89cb21fa.zip
Passpoint: Change ICON response handling
Currently, the ICON done notification from WifiMonitor is used as a trigger to fetch icon data in PasspointEventHandler. In the HIDL interface, the callback itself will contain all the necessary icon data. So, change the currently handling to prepare for integration with HIDL interface. Changes in the CL: 1. Move the icon data fetching to WifiMonitor away from PasspointEventHandler. 2. Change the params of the icon done event to include the icon data. 3. Add a new public method in WifiMonitor to send the notification out from WifiMonitor, which will be used by the HIDL interface in the future. Note: There are no unit tests for any of these changes because this CL is just moving things around and most of it is going to be removed when we integrate with HIDL. Bug: 35393853 Test: Connects to passpoint networks. Test: Will send for regression tests. Change-Id: I197180c8a8ec8673e5e8fa29ba8bb51b026d44fb
Diffstat (limited to 'service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java')
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java68
1 files changed, 4 insertions, 64 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java b/service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java
index 2bf099a5b..a46a0e591 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointEventHandler.java
@@ -16,14 +16,12 @@
package com.android.server.wifi.hotspot2;
-import android.util.Base64;
import android.util.Log;
import com.android.server.wifi.WifiNative;
import com.android.server.wifi.hotspot2.anqp.ANQPElement;
import com.android.server.wifi.hotspot2.anqp.Constants;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -36,8 +34,6 @@ public class PasspointEventHandler {
private final WifiNative mSupplicantHook;
private final Callbacks mCallbacks;
- private static final int ICON_CHUNK_SIZE = 1400; // 2K*3/4 - overhead
-
/**
* Interface to be implemented by the client to receive callbacks for passpoint
* related events.
@@ -124,22 +120,12 @@ public class PasspointEventHandler {
* Invoked when icon query is completed.
* TODO(zqiu): currently icon completion notification is through WifiMonitor,
* this shouldn't be needed once we switch over to wificond for icon requests.
- * @param bssid BSSID of the AP
* @param iconEvent icon event data
*/
- public void notifyIconDone(long bssid, IconEvent iconEvent) {
- String filename = null;
- byte[] data = null;
- if (iconEvent != null) {
- try {
- data = retrieveIcon(iconEvent);
- filename = iconEvent.getFileName();
- } catch (IOException ioe) {
- Log.e(Utils.hs2LogTag(getClass()), "Failed to retrieve icon: " +
- ioe.toString() + ": " + iconEvent.getFileName());
- }
- }
- mCallbacks.onIconResponse(bssid, filename, data);
+ public void notifyIconDone(IconEvent iconEvent) {
+ if (iconEvent == null) return;
+ mCallbacks.onIconResponse(
+ iconEvent.getBSSID(), iconEvent.getFileName(), iconEvent.getData());
}
/**
@@ -197,50 +183,4 @@ public class PasspointEventHandler {
return sb.toString();
}
- private byte[] retrieveIcon(IconEvent iconEvent) throws IOException {
- byte[] iconData = new byte[iconEvent.getSize()];
- try {
- int offset = 0;
- while (offset < iconEvent.getSize()) {
- int size = Math.min(iconEvent.getSize() - offset, ICON_CHUNK_SIZE);
-
- String command = String.format("GET_HS20_ICON %s %s %d %d",
- Utils.macToString(iconEvent.getBSSID()), iconEvent.getFileName(),
- offset, size);
- Log.d(Utils.hs2LogTag(getClass()), "Issuing '" + command + "'");
- String response = mSupplicantHook.doCustomSupplicantCommand(command);
- if (response == null) {
- throw new IOException("No icon data returned");
- }
-
- try {
- byte[] fragment = Base64.decode(response, Base64.DEFAULT);
- if (fragment.length == 0) {
- throw new IOException("Null data for '" + command + "': " + response);
- }
- if (fragment.length + offset > iconData.length) {
- throw new IOException("Icon chunk exceeds image size");
- }
- System.arraycopy(fragment, 0, iconData, offset, fragment.length);
- offset += fragment.length;
- } catch (IllegalArgumentException iae) {
- throw new IOException("Failed to parse response to '" + command
- + "': " + response);
- }
- }
- if (offset != iconEvent.getSize()) {
- Log.w(Utils.hs2LogTag(getClass()), "Partial icon data: " + offset +
- ", expected " + iconEvent.getSize());
- }
- }
- finally {
- // Delete the icon file in supplicant.
- Log.d(Utils.hs2LogTag(getClass()), "Deleting icon for " + iconEvent);
- String result = mSupplicantHook.doCustomSupplicantCommand("DEL_HS20_ICON " +
- Utils.macToString(iconEvent.getBSSID()) + " " + iconEvent.getFileName());
- Log.d(Utils.hs2LogTag(getClass()), "Result: " + result);
- }
-
- return iconData;
- }
}