summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/hotspot2/OsuNetworkConnection.java1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java12
2 files changed, 13 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/OsuNetworkConnection.java b/service/java/com/android/server/wifi/hotspot2/OsuNetworkConnection.java
index 367a80dc6..0de441434 100644
--- a/service/java/com/android/server/wifi/hotspot2/OsuNetworkConnection.java
+++ b/service/java/com/android/server/wifi/hotspot2/OsuNetworkConnection.java
@@ -136,6 +136,7 @@ public class OsuNetworkConnection {
}
return;
}
+ mConnectivityManager.unregisterNetworkCallback(mConnectivityCallbacks);
mWifiManager.removeNetwork(mNetworkId);
mNetworkId = -1;
mNetwork = null;
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java
index ae1f6ce03..f94c43976 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java
@@ -220,7 +220,11 @@ public class OsuNetworkConnectionTest {
callback.onLost(mCurrentNetwork);
verify(mNetworkCallbacks).onDisconnected();
+
mNetworkConnection.disconnectIfNeeded();
+
+ verify(mConnectivityManager).unregisterNetworkCallback(any(ConnectivityManager
+ .NetworkCallback.class));
verify(mWifiManager).removeNetwork(TEST_NETWORK_ID);
}
@@ -246,7 +250,11 @@ public class OsuNetworkConnectionTest {
callback.onUnavailable();
verify(mNetworkCallbacks).onTimeOut();
+
mNetworkConnection.disconnectIfNeeded();
+
+ verify(mConnectivityManager).unregisterNetworkCallback(any(ConnectivityManager
+ .NetworkCallback.class));
verify(mWifiManager).removeNetwork(TEST_NETWORK_ID);
}
@@ -258,7 +266,11 @@ public class OsuNetworkConnectionTest {
public void verifyNetworkDisconnect() {
mNetworkConnection.init(mHandler);
assertEquals(true, mNetworkConnection.connect(TEST_SSID, TEST_NAI));
+
mNetworkConnection.disconnectIfNeeded();
+
+ verify(mConnectivityManager).unregisterNetworkCallback(any(ConnectivityManager
+ .NetworkCallback.class));
verify(mWifiManager).removeNetwork(TEST_NETWORK_ID);
}