summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-11-08 09:07:34 -0800
committerRoshan Pius <rpius@google.com>2018-11-16 16:30:41 -0800
commitca7e72ad7fb48243cf0f00cec05c4d03d984d7ed (patch)
treec13e5399c71328429f661435e1b4ee5cfded46e2 /tests/wifitests/src/com/android/server
parent016725de18209f64f887991e0cc84e75c99548df (diff)
downloadandroid_frameworks_opt_net_wifi-ca7e72ad7fb48243cf0f00cec05c4d03d984d7ed.tar.gz
android_frameworks_opt_net_wifi-ca7e72ad7fb48243cf0f00cec05c4d03d984d7ed.tar.bz2
android_frameworks_opt_net_wifi-ca7e72ad7fb48243cf0f00cec05c4d03d984d7ed.zip
ClientModeImpl: Send connection status to network factory
Indicate connection status to WifiNetworkFactory to let WifiNetworkFactory track its connection attempt status. Also, refactor the Carrier/Open-NetworkNotifier to use the same hooks for indicating connection status. This is to ensure that all of these modules have a somewhat consistent pattern for tracking connection status. Bug: 113878056 Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: Ensured that ONA connection still works. Change-Id: I7ae0cb529ae0fd3372657efeadae964ea019fe94
Diffstat (limited to 'tests/wifitests/src/com/android/server')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java20
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java21
3 files changed, 38 insertions, 11 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 9db119620..ceaeb7124 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -2331,6 +2331,7 @@ public class ClientModeImplTest {
/**
* Verifies that association failures make WifiDiagnostics report CONNECTION_EVENT_FAILED
* and then cancel any pending timeouts.
+ * Also, send connection status to {@link WifiNetworkFactory} & {@link WifiConnectivityManager}.
* @throws Exception
*/
@Test
@@ -2345,12 +2346,17 @@ public class ClientModeImplTest {
mLooper.dispatchAll();
verify(mWifiDiagnostics).reportConnectionEvent(
eq(WifiDiagnostics.CONNECTION_EVENT_FAILED));
+ verify(mWifiConnectivityManager).handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_REJECTION);
+ verify(mWifiNetworkFactory).handleConnectionAttemptEnded(
+ eq(WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_REJECTION), any());
verifyConnectionEventTimeoutDoesNotOccur();
}
/**
* Verifies that authentication failures make WifiDiagnostics report
* CONNECTION_EVENT_FAILED and then cancel any pending timeouts.
+ * Also, send connection status to {@link WifiNetworkFactory} & {@link WifiConnectivityManager}.
* @throws Exception
*/
@Test
@@ -2365,6 +2371,10 @@ public class ClientModeImplTest {
mLooper.dispatchAll();
verify(mWifiDiagnostics).reportConnectionEvent(
eq(WifiDiagnostics.CONNECTION_EVENT_FAILED));
+ verify(mWifiConnectivityManager).handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_AUTHENTICATION_FAILURE);
+ verify(mWifiNetworkFactory).handleConnectionAttemptEnded(
+ eq(WifiMetrics.ConnectionEvent.FAILURE_AUTHENTICATION_FAILURE), any());
verifyConnectionEventTimeoutDoesNotOccur();
}
@@ -2372,6 +2382,7 @@ public class ClientModeImplTest {
/**
* Verifies that dhcp failures make WifiDiagnostics report CONNECTION_EVENT_FAILED and then
* cancel any pending timeouts.
+ * Also, send connection status to {@link WifiNetworkFactory} & {@link WifiConnectivityManager}.
* @throws Exception
*/
@Test
@@ -2379,12 +2390,17 @@ public class ClientModeImplTest {
testDhcpFailure();
verify(mWifiDiagnostics, atLeastOnce()).reportConnectionEvent(
eq(WifiDiagnostics.CONNECTION_EVENT_FAILED));
+ verify(mWifiConnectivityManager, atLeastOnce()).handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_DHCP);
+ verify(mWifiNetworkFactory, atLeastOnce()).handleConnectionAttemptEnded(
+ eq(WifiMetrics.ConnectionEvent.FAILURE_DHCP), any());
verifyConnectionEventTimeoutDoesNotOccur();
}
/**
* Verifies that a successful connection make WifiDiagnostics report CONNECTION_EVENT_SUCCEEDED
* and then cancel any pending timeouts.
+ * Also, send connection status to {@link WifiNetworkFactory} & {@link WifiConnectivityManager}.
* @throws Exception
*/
@Test
@@ -2392,6 +2408,10 @@ public class ClientModeImplTest {
connect();
verify(mWifiDiagnostics).reportConnectionEvent(
eq(WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED));
+ verify(mWifiConnectivityManager).handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE);
+ verify(mWifiNetworkFactory).handleConnectionAttemptEnded(
+ eq(WifiMetrics.ConnectionEvent.FAILURE_NONE), any());
verifyConnectionEventTimeoutDoesNotOccur();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index e9abdc81c..eb090c548 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -672,8 +672,8 @@ public class WifiConnectivityManagerTest {
public void wifiConnected_openNetworkNotifierHandlesConnection() {
// Set WiFi to connected state
mWifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(CANDIDATE_SSID));
- mWifiConnectivityManager.handleConnectionStateChanged(
- WifiConnectivityManager.WIFI_STATE_CONNECTED);
+ mWifiConnectivityManager.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE);
verify(mOpenNetworkNotifier).handleWifiConnected(CANDIDATE_SSID);
}
@@ -815,8 +815,8 @@ public class WifiConnectivityManagerTest {
public void wifiConnected_carrierNetworkNotifierHandlesConnection() {
// Set WiFi to connected state
mWifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(CANDIDATE_SSID));
- mWifiConnectivityManager.handleConnectionStateChanged(
- WifiConnectivityManager.WIFI_STATE_CONNECTED);
+ mWifiConnectivityManager.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE);
verify(mCarrierNetworkNotifier).handleWifiConnected(CANDIDATE_SSID);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index c72da94b1..69fcc59c6 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -913,7 +913,8 @@ public class WifiNetworkFactoryTest {
// Send network connection failure indication.
assertNotNull(mSelectedNetwork);
- mWifiNetworkFactory.handleNetworkConnectionFailure(mSelectedNetwork);
+ mWifiNetworkFactory.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_DHCP, mSelectedNetwork);
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(mSelectedNetwork);
@@ -934,7 +935,8 @@ public class WifiNetworkFactoryTest {
assertNotNull(mSelectedNetwork);
WifiConfiguration connectedNetwork = new WifiConfiguration(mSelectedNetwork);
connectedNetwork.SSID += "test";
- mWifiNetworkFactory.handleNetworkConnectionFailure(connectedNetwork);
+ mWifiNetworkFactory.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_DHCP, connectedNetwork);
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback, never())
@@ -947,7 +949,8 @@ public class WifiNetworkFactoryTest {
.setSpecificNetworkRequestInProgress(false);
// Send network connection success to the correct network indication.
- mWifiNetworkFactory.handleNetworkConnectionFailure(mSelectedNetwork);
+ mWifiNetworkFactory.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_DHCP, mSelectedNetwork);
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(mSelectedNetwork);
@@ -966,7 +969,8 @@ public class WifiNetworkFactoryTest {
// Send network connection success indication.
assertNotNull(mSelectedNetwork);
- mWifiNetworkFactory.handleNetworkConnectionSuccess(mSelectedNetwork);
+ mWifiNetworkFactory.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork);
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(mSelectedNetwork);
@@ -985,7 +989,8 @@ public class WifiNetworkFactoryTest {
assertNotNull(mSelectedNetwork);
WifiConfiguration connectedNetwork = new WifiConfiguration(mSelectedNetwork);
connectedNetwork.SSID += "test";
- mWifiNetworkFactory.handleNetworkConnectionSuccess(connectedNetwork);
+ mWifiNetworkFactory.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE, connectedNetwork);
// verify that we did not send out the success callback and did not stop the alarm timeout.
verify(mNetworkRequestMatchCallback, never())
@@ -994,7 +999,8 @@ public class WifiNetworkFactoryTest {
.cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Send network connection success to the correct network indication.
- mWifiNetworkFactory.handleNetworkConnectionSuccess(mSelectedNetwork);
+ mWifiNetworkFactory.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork);
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(mSelectedNetwork);
@@ -1011,7 +1017,8 @@ public class WifiNetworkFactoryTest {
// Send network connection success indication.
assertNotNull(mSelectedNetwork);
- mWifiNetworkFactory.handleNetworkConnectionSuccess(mSelectedNetwork);
+ mWifiNetworkFactory.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork);
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(mSelectedNetwork);