summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-03-14 16:07:46 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-03-14 16:07:48 +0000
commit4fdbb2cd44da9cd50bfdc022e7fcf7eec53986a6 (patch)
tree92dd1f97c1ce2d47514850633a09cf7a3fd991d7
parent49ecbbe78fac8edfd99186c33c9efd68bcd3fd97 (diff)
parentb48796131ddd016071144f77f208360e8c408f0e (diff)
Merge "hotspot2: use the updated public intent definitions"
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java59
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java91
2 files changed, 104 insertions, 46 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index 3d4d61bf6..ff8b50f77 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -16,19 +16,19 @@
package com.android.server.wifi.hotspot2;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_ICON_BSSID;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_ICON_DATA;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_ICON_FILE;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_WNM_BSSID;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_WNM_DELAY;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_WNM_ESS;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_WNM_METHOD;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_WNM_URL;
-import static android.net.wifi.WifiManager.PASSPOINT_ICON_RECEIVED_ACTION;
-import static android.net.wifi.WifiManager.PASSPOINT_WNM_FRAME_RECEIVED_ACTION;
+import static android.net.wifi.WifiManager.ACTION_PASSPOINT_DEAUTH_IMMINENT;
+import static android.net.wifi.WifiManager.ACTION_PASSPOINT_ICON;
+import static android.net.wifi.WifiManager.ACTION_PASSPOINT_SUBSCRIPTION_REMEDIATION;
+import static android.net.wifi.WifiManager.EXTRA_BSSID_LONG;
+import static android.net.wifi.WifiManager.EXTRA_DELAY;
+import static android.net.wifi.WifiManager.EXTRA_ESS;
+import static android.net.wifi.WifiManager.EXTRA_ICON_INFO;
+import static android.net.wifi.WifiManager.EXTRA_SUBSCRIPTION_REMEDIATION_METHOD;
+import static android.net.wifi.WifiManager.EXTRA_URL;
import android.content.Context;
import android.content.Intent;
+import android.net.wifi.IconInfo;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.hotspot2.PasspointConfiguration;
@@ -124,36 +124,35 @@ public class PasspointManager {
@Override
public void onIconResponse(long bssid, String fileName, byte[] data) {
- Intent intent = new Intent(PASSPOINT_ICON_RECEIVED_ACTION);
+ Intent intent = new Intent(ACTION_PASSPOINT_ICON);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
- intent.putExtra(EXTRA_PASSPOINT_ICON_BSSID, bssid);
- intent.putExtra(EXTRA_PASSPOINT_ICON_FILE, fileName);
- if (data != null) {
- intent.putExtra(EXTRA_PASSPOINT_ICON_DATA, data);
- }
- mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ intent.putExtra(EXTRA_BSSID_LONG, bssid);
+ intent.putExtra(EXTRA_ICON_INFO, new IconInfo(fileName, data));
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
+ android.Manifest.permission.ACCESS_WIFI_STATE);
}
@Override
public void onWnmFrameReceived(WnmData event) {
// %012x HS20-SUBSCRIPTION-REMEDIATION "%u %s", osu_method, url
// %012x HS20-DEAUTH-IMMINENT-NOTICE "%u %u %s", code, reauth_delay, url
- Intent intent = new Intent(PASSPOINT_WNM_FRAME_RECEIVED_ACTION);
- intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
-
- intent.putExtra(EXTRA_PASSPOINT_WNM_BSSID, event.getBssid());
- intent.putExtra(EXTRA_PASSPOINT_WNM_URL, event.getUrl());
-
+ Intent intent;
if (event.isDeauthEvent()) {
- intent.putExtra(EXTRA_PASSPOINT_WNM_ESS, event.isEss());
- intent.putExtra(EXTRA_PASSPOINT_WNM_DELAY, event.getDelay());
+ intent = new Intent(ACTION_PASSPOINT_DEAUTH_IMMINENT);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+ intent.putExtra(EXTRA_BSSID_LONG, event.getBssid());
+ intent.putExtra(EXTRA_URL, event.getUrl());
+ intent.putExtra(EXTRA_ESS, event.isEss());
+ intent.putExtra(EXTRA_DELAY, event.getDelay());
} else {
- intent.putExtra(EXTRA_PASSPOINT_WNM_METHOD, event.getMethod());
- // TODO(zqiu): set the passpoint matching status with the respect to the
- // current connected network (e.g. HomeProvider, RoamingProvider, None,
- // Declined).
+ intent = new Intent(ACTION_PASSPOINT_SUBSCRIPTION_REMEDIATION);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+ intent.putExtra(EXTRA_BSSID_LONG, event.getBssid());
+ intent.putExtra(EXTRA_SUBSCRIPTION_REMEDIATION_METHOD, event.getMethod());
+ intent.putExtra(EXTRA_URL, event.getUrl());
}
- mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
+ android.Manifest.permission.ACCESS_WIFI_STATE);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
index 8def58ccf..e424b4dbe 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -16,10 +16,15 @@
package com.android.server.wifi.hotspot2;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_ICON_BSSID;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_ICON_DATA;
-import static android.net.wifi.WifiManager.EXTRA_PASSPOINT_ICON_FILE;
-import static android.net.wifi.WifiManager.PASSPOINT_ICON_RECEIVED_ACTION;
+import static android.net.wifi.WifiManager.ACTION_PASSPOINT_DEAUTH_IMMINENT;
+import static android.net.wifi.WifiManager.ACTION_PASSPOINT_ICON;
+import static android.net.wifi.WifiManager.ACTION_PASSPOINT_SUBSCRIPTION_REMEDIATION;
+import static android.net.wifi.WifiManager.EXTRA_BSSID_LONG;
+import static android.net.wifi.WifiManager.EXTRA_DELAY;
+import static android.net.wifi.WifiManager.EXTRA_ESS;
+import static android.net.wifi.WifiManager.EXTRA_ICON_INFO;
+import static android.net.wifi.WifiManager.EXTRA_SUBSCRIPTION_REMEDIATION_METHOD;
+import static android.net.wifi.WifiManager.EXTRA_URL;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -39,6 +44,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.EAPConstants;
+import android.net.wifi.IconInfo;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.hotspot2.PasspointConfiguration;
@@ -128,24 +134,22 @@ public class PasspointManagerTest {
}
/**
- * Verify PASSPOINT_ICON_RECEIVED_ACTION broadcast intent.
+ * Verify {@link WifiManager#ACTION_PASSPOINT_ICON} broadcast intent.
* @param bssid BSSID of the AP
* @param fileName Name of the icon file
* @param data icon data byte array
*/
private void verifyIconIntent(long bssid, String fileName, byte[] data) {
ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
- verify(mContext).sendBroadcastAsUser(intent.capture(), eq(UserHandle.ALL));
- assertEquals(PASSPOINT_ICON_RECEIVED_ACTION, intent.getValue().getAction());
- assertTrue(intent.getValue().getExtras().containsKey(EXTRA_PASSPOINT_ICON_BSSID));
- assertEquals(bssid, intent.getValue().getExtras().getLong(EXTRA_PASSPOINT_ICON_BSSID));
- assertTrue(intent.getValue().getExtras().containsKey(EXTRA_PASSPOINT_ICON_FILE));
- assertEquals(fileName, intent.getValue().getExtras().getString(EXTRA_PASSPOINT_ICON_FILE));
- if (data != null) {
- assertTrue(intent.getValue().getExtras().containsKey(EXTRA_PASSPOINT_ICON_DATA));
- assertEquals(data,
- intent.getValue().getExtras().getByteArray(EXTRA_PASSPOINT_ICON_DATA));
- }
+ verify(mContext).sendBroadcastAsUser(intent.capture(), eq(UserHandle.ALL),
+ eq(android.Manifest.permission.ACCESS_WIFI_STATE));
+ assertEquals(ACTION_PASSPOINT_ICON, intent.getValue().getAction());
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_BSSID_LONG));
+ assertEquals(bssid, intent.getValue().getExtras().getLong(EXTRA_BSSID_LONG));
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_ICON_INFO));
+ IconInfo expectedInfo = new IconInfo(fileName, data);
+ assertEquals(new IconInfo(fileName, data),
+ (IconInfo) intent.getValue().getExtras().getParcelable(EXTRA_ICON_INFO));
}
/**
@@ -330,6 +334,61 @@ public class PasspointManagerTest {
}
/**
+ * Validate the broadcast intent {@link WifiManager#ACTION_PASSPOINT_DEAUTH_IMMINENT} when
+ * Deauth Imminent WNM frame is received.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void onDeauthImminentReceived() throws Exception {
+ String reasonUrl = "test.com";
+ int delay = 123;
+ boolean ess = true;
+
+ mCallbacks.onWnmFrameReceived(new WnmData(BSSID, reasonUrl, ess, delay));
+ // Verify the broadcast intent.
+ ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcastAsUser(intent.capture(), eq(UserHandle.ALL),
+ eq(android.Manifest.permission.ACCESS_WIFI_STATE));
+ assertEquals(ACTION_PASSPOINT_DEAUTH_IMMINENT, intent.getValue().getAction());
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_BSSID_LONG));
+ assertEquals(BSSID, intent.getValue().getExtras().getLong(EXTRA_BSSID_LONG));
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_ESS));
+ assertEquals(ess, intent.getValue().getExtras().getBoolean(EXTRA_ESS));
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_DELAY));
+ assertEquals(delay, intent.getValue().getExtras().getInt(EXTRA_DELAY));
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_URL));
+ assertEquals(reasonUrl, intent.getValue().getExtras().getString(EXTRA_URL));
+ }
+
+ /**
+ * Validate the broadcast intent {@link WifiManager#ACTION_PASSPOINT_SUBSCRIPTION_REMEDIATION}
+ * when Subscription Remediation WNM frame is received.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void onSubscriptionRemediationReceived() throws Exception {
+ int serverMethod = 1;
+ String serverUrl = "testUrl";
+
+ mCallbacks.onWnmFrameReceived(new WnmData(BSSID, serverUrl, serverMethod));
+ // Verify the broadcast intent.
+ ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcastAsUser(intent.capture(), eq(UserHandle.ALL),
+ eq(android.Manifest.permission.ACCESS_WIFI_STATE));
+ assertEquals(ACTION_PASSPOINT_SUBSCRIPTION_REMEDIATION, intent.getValue().getAction());
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_BSSID_LONG));
+ assertEquals(BSSID, intent.getValue().getExtras().getLong(EXTRA_BSSID_LONG));
+ assertTrue(intent.getValue().getExtras().containsKey(
+ EXTRA_SUBSCRIPTION_REMEDIATION_METHOD));
+ assertEquals(serverMethod, intent.getValue().getExtras().getInt(
+ EXTRA_SUBSCRIPTION_REMEDIATION_METHOD));
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_URL));
+ assertEquals(serverUrl, intent.getValue().getExtras().getString(EXTRA_URL));
+ }
+
+ /**
* Verify that adding a provider with a null configuration will fail.
*
* @throws Exception