From 771b4dd25daedb13c9de736a8bca18485fcb1ab6 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 10 Jul 2020 06:57:23 -0700 Subject: ClientModeImpl: Reset WifiInfo on NETWORK_DISCONNECTION_EVENT Invoke WifiInfo.reset() on connection failure. Bug: 160787425 Test: atest com.android.server.wifi Change-Id: I5c3000b4c9eefa8a264ee7ae89abd0b8039dca88 Merged-In: I5c3000b4c9eefa8a264ee7ae89abd0b8039dca88 --- .../android/server/wifi/ClientModeImplTest.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 23726786d..3048ef3d5 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -5295,4 +5295,28 @@ public class ClientModeImplTest extends WifiBaseTest { assertEquals(mNetwork, mCmi.syncGetCurrentNetwork(mCmiAsyncChannel)); mLooper.stopAutoDispatch(); } + + @Test + public void clearRequestingPackageNameInWifiInfoOnConnectionFailure() throws Exception { + mConnectedNetwork.fromWifiNetworkSpecifier = true; + mConnectedNetwork.ephemeral = true; + mConnectedNetwork.creatorName = OP_PACKAGE_NAME; + + triggerConnect(); + + // association completed + mCmi.sendMessage(WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, 0, 0, + new StateChangeResult(0, sWifiSsid, sBSSID, SupplicantState.ASSOCIATED)); + mLooper.dispatchAll(); + + assertTrue(mCmi.getWifiInfo().isEphemeral()); + assertEquals(OP_PACKAGE_NAME, mCmi.getWifiInfo().getRequestingPackageName()); + + // fail the connection. + mCmi.sendMessage(WifiMonitor.NETWORK_DISCONNECTION_EVENT, FRAMEWORK_NETWORK_ID, 0, sBSSID); + mLooper.dispatchAll(); + + assertFalse(mCmi.getWifiInfo().isEphemeral()); + assertNull(mCmi.getWifiInfo().getRequestingPackageName()); + } } -- cgit v1.2.3