summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-03-21 21:48:27 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-21 21:48:27 +0000
commit8968c27b92f525a9c349c4fab0930b53523164ff (patch)
tree0d80f9127c3c8ef5e0700859ec30692b6c58b452
parent821a0601577f4f281d4e4cb16f3baf3fe699ae59 (diff)
parent7a9a3b4d49b2bbff2e65a51022240ea8c3e61108 (diff)
Merge "SupplicantStaIfaceHal: Broadcast bssid change event" am: 168fba7187
am: 7a9a3b4d49 Change-Id: Ice12dee9c695a6b0ff6f8a8cd3742a34d9c0bba5
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaIfaceHal.java19
-rw-r--r--service/java/com/android/server/wifi/WifiMonitor.java14
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java30
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java6
4 files changed, 59 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index 8308b4c0d..0fdcebe7e 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -32,6 +32,7 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicantIface;
import android.hardware.wifi.supplicant.V1_0.ISupplicantNetwork;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIface;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback;
+import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.BssidChangeReason;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork;
import android.hardware.wifi.supplicant.V1_0.IfaceType;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatus;
@@ -1753,9 +1754,7 @@ public class SupplicantStaIfaceHal {
String bssidStr = NativeUtil.macAddressFromByteArray(bssid);
mWifiMonitor.broadcastSupplicantStateChangeEvent(
mIfaceName, mFrameworkNetworkId, wifiSsid, bssidStr, newSupplicantState);
- if (newSupplicantState == SupplicantState.ASSOCIATED) {
- mWifiMonitor.broadcastAssociationSuccesfulEvent(mIfaceName, bssidStr);
- } else if (newSupplicantState == SupplicantState.COMPLETED) {
+ if (newSupplicantState == SupplicantState.COMPLETED) {
mWifiMonitor.broadcastNetworkConnectionEvent(
mIfaceName, mFrameworkNetworkId, bssidStr);
}
@@ -1859,6 +1858,20 @@ public class SupplicantStaIfaceHal {
}
@Override
+ public void onBssidChanged(byte reason, byte[/* 6 */] bssid) {
+ logCallback("onBssidChanged");
+ synchronized (mLock) {
+ if (reason == BssidChangeReason.ASSOC_START) {
+ mWifiMonitor.broadcastTargetBssidEvent(
+ mIfaceName, NativeUtil.macAddressFromByteArray(bssid));
+ } else if (reason == BssidChangeReason.ASSOC_COMPLETE) {
+ mWifiMonitor.broadcastAssociatedBssidEvent(
+ mIfaceName, NativeUtil.macAddressFromByteArray(bssid));
+ }
+ }
+ }
+
+ @Override
public void onEapFailure() {
logCallback("onEapFailure");
synchronized (mLock) {
diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java
index 317d3991c..15ec8fd77 100644
--- a/service/java/com/android/server/wifi/WifiMonitor.java
+++ b/service/java/com/android/server/wifi/WifiMonitor.java
@@ -499,13 +499,23 @@ public class WifiMonitor {
* Broadcast the association success event to all the handlers registered for this event.
*
* @param iface Name of iface on which this occurred.
- * @param bssid BSSID of the access point from which we received the reject.
+ * @param bssid BSSID of the access point.
*/
- public void broadcastAssociationSuccesfulEvent(String iface, String bssid) {
+ public void broadcastAssociatedBssidEvent(String iface, String bssid) {
sendMessage(iface, WifiStateMachine.CMD_ASSOCIATED_BSSID, 0, 0, bssid);
}
/**
+ * Broadcast the start of association event to all the handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param bssid BSSID of the access point.
+ */
+ public void broadcastTargetBssidEvent(String iface, String bssid) {
+ sendMessage(iface, WifiStateMachine.CMD_TARGET_BSSID, 0, 0, bssid);
+ }
+
+ /**
* Broadcast the network connection event to all the handlers registered for this event.
*
* @param iface Name of iface on which this occurred.
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index d7c3b93e3..de96a7a2a 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -38,6 +39,7 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicant;
import android.hardware.wifi.supplicant.V1_0.ISupplicantIface;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIface;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback;
+import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.BssidChangeReason;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork;
import android.hardware.wifi.supplicant.V1_0.IfaceType;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatus;
@@ -879,8 +881,6 @@ public class SupplicantStaIfaceHalTest {
verify(mWifiMonitor).broadcastSupplicantStateChangeEvent(
eq(WLAN_IFACE_NAME), eq(frameworkNetworkId),
any(WifiSsid.class), eq(BSSID), eq(SupplicantState.ASSOCIATED));
- verify(mWifiMonitor).broadcastAssociationSuccesfulEvent(
- eq(WLAN_IFACE_NAME), eq(BSSID));
}
/**
@@ -1010,6 +1010,32 @@ public class SupplicantStaIfaceHalTest {
}
/**
+ * Tests the handling of bssid change notification.
+ */
+ @Test
+ public void testBssidChangedCallback() throws Exception {
+ executeAndValidateInitializationSequence();
+ assertNotNull(mISupplicantStaIfaceCallback);
+
+ mISupplicantStaIfaceCallback.onBssidChanged(
+ BssidChangeReason.ASSOC_START, NativeUtil.macAddressToByteArray(BSSID));
+ verify(mWifiMonitor).broadcastTargetBssidEvent(eq(WLAN_IFACE_NAME), eq(BSSID));
+ verify(mWifiMonitor, never()).broadcastAssociatedBssidEvent(eq(WLAN_IFACE_NAME), eq(BSSID));
+
+ reset(mWifiMonitor);
+ mISupplicantStaIfaceCallback.onBssidChanged(
+ BssidChangeReason.ASSOC_COMPLETE, NativeUtil.macAddressToByteArray(BSSID));
+ verify(mWifiMonitor, never()).broadcastTargetBssidEvent(eq(WLAN_IFACE_NAME), eq(BSSID));
+ verify(mWifiMonitor).broadcastAssociatedBssidEvent(eq(WLAN_IFACE_NAME), eq(BSSID));
+
+ reset(mWifiMonitor);
+ mISupplicantStaIfaceCallback.onBssidChanged(
+ BssidChangeReason.DISASSOC, NativeUtil.macAddressToByteArray(BSSID));
+ verify(mWifiMonitor, never()).broadcastTargetBssidEvent(eq(WLAN_IFACE_NAME), eq(BSSID));
+ verify(mWifiMonitor, never()).broadcastAssociatedBssidEvent(eq(WLAN_IFACE_NAME), eq(BSSID));
+ }
+
+ /**
* Tests the handling of EAP failure notification.
*/
@Test
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
index 873583954..e9424223d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
@@ -361,14 +361,14 @@ public class WifiMonitorTest {
}
/**
- * Broadcast association successful test.
+ * Broadcast associated bssid test.
*/
@Test
- public void testBroadcastAssociationSuccessfulEvent() {
+ public void testBroadcastAssociatedBssidEvent() {
mWifiMonitor.registerHandler(
WLAN_IFACE_NAME, WifiStateMachine.CMD_ASSOCIATED_BSSID, mHandlerSpy);
String bssid = BSSID;
- mWifiMonitor.broadcastAssociationSuccesfulEvent(WLAN_IFACE_NAME, bssid);
+ mWifiMonitor.broadcastAssociatedBssidEvent(WLAN_IFACE_NAME, bssid);
mLooper.dispatchAll();
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);