diff options
author | Ecco Park <eccopark@google.com> | 2018-11-08 09:57:56 -0800 |
---|---|---|
committer | Ecco Park <eccopark@google.com> | 2018-11-10 01:47:16 +0000 |
commit | 1c1418a33d4303f54ecfcf8335b908072630c31c (patch) | |
tree | d6b604159c5ab4a532addc3fca249529b4d6cf53 | |
parent | 1814bab638b34e51550fa23ccf0b8518b7aaec71 (diff) |
passpoint-r2: unregister ConnectivityCallbacks when it disconnects OSU AP
Currently when we connect to OSU AP, we register ConnectivityCallbacks function
to the network to listen for connection/disconnection event.
The problem is that we never unregister the network callback
even after we disconnect the OSU AP, which causes internal state of
OsuNetworkConnection to be connected state all the time.
Due to this, user no longer be able to start provisioning flow next
time.
It blocks us to run Provisioning test continously with following sequences:
Testcase:
1) OSU Provisioning to get a passpoint profile
2) Connecting to Passpoint AP
3) Delete Passpoint profile
Test results:
1) It failed without this CL:
First try passed, but second try failed.
2) It passed with this CL.
Firt try, second and subsequenet try all passed.
Bug: 119257536
Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: live test with Passpoint R2 service provider AP
Change-Id: I82377d54d545a918dbd491e570a7f6fb61edb3aa
Signed-off-by: Ecco Park <eccopark@google.com>
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/OsuNetworkConnection.java | 1 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java | 12 |
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); } |