diff options
author | Roshan Pius <rpius@google.com> | 2019-03-22 22:33:31 +0000 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-03-22 22:33:31 +0000 |
commit | f94353bbd50b7afdcdc01bf88f532acb117db21a (patch) | |
tree | 604173a5d6f825a68d7513a83c7cb3f24197608f | |
parent | 0cd22728c628e51e8f259f8404a97dec49804424 (diff) |
Revert "WifiConfigManager: Temporarily blacklist on disconnect"
This reverts commit 0cd22728c628e51e8f259f8404a97dec49804424.
Bug: 126503889
Reason for revert: UI changes was punted to R. No rationale in making this API changing behavior now.
Change-Id: Ie8cd931980d2eb0c7bf660cb0fa646848d315a71
10 files changed, 41 insertions, 92 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 1b460cb90..444219d2b 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -17,7 +17,6 @@ package com.android.server.wifi; import static android.net.shared.LinkPropertiesParcelableUtil.toStableParcelable; -import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WIFI_MANAGER_DISCONNECT; import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED; import static android.net.wifi.WifiManager.WIFI_STATE_DISABLING; import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED; @@ -1588,19 +1587,20 @@ public class ClientModeImpl extends StateMachine { } /** - * Method to trigger a disconnect. - * Note: To be used from within the wifi stack. + * Disconnect from Access Point */ - public void disconnectCommandInternal() { - sendMessage(CMD_DISCONNECT, 0 /* fromExternal */); + public void disconnectCommand() { + sendMessage(CMD_DISCONNECT); } /** * Method to trigger a disconnect. - * Note: To be used from public API surface. + * + * @param uid UID of requesting caller + * @param reason disconnect reason */ - public void disconnectCommandExternal() { - sendMessage(CMD_DISCONNECT, 1 /* fromExternal */); + public void disconnectCommand(int uid, int reason) { + sendMessage(CMD_DISCONNECT, uid, reason); } /** @@ -3671,7 +3671,7 @@ public class ClientModeImpl extends StateMachine { if (removedNetworkIds.contains(mTargetNetworkId) || removedNetworkIds.contains(mLastNetworkId)) { // Disconnect and let autojoin reselect a new network - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } break; case CMD_USER_UNLOCK: @@ -4129,7 +4129,7 @@ public class ClientModeImpl extends StateMachine { netId = message.arg1; if (netId == mTargetNetworkId || netId == mLastNetworkId) { // Disconnect and let autojoin reselect a new network - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } break; case CMD_ENABLE_NETWORK: @@ -4153,7 +4153,7 @@ public class ClientModeImpl extends StateMachine { replyToMessage(message, WifiManager.DISABLE_NETWORK_SUCCEEDED); if (netId == mTargetNetworkId || netId == mLastNetworkId) { // Disconnect and let autojoin reselect a new network - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } } else { loge("Failed to disable network"); @@ -4168,7 +4168,7 @@ public class ClientModeImpl extends StateMachine { if (config.networkId == mTargetNetworkId || config.networkId == mLastNetworkId) { // Disconnect and let autojoin reselect a new network - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } } break; @@ -4328,7 +4328,7 @@ public class ClientModeImpl extends StateMachine { if (removedNetworkIds.contains(mTargetNetworkId) || removedNetworkIds.contains(mLastNetworkId)) { // Disconnect and let autojoin reselect a new network. - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } break; case CMD_REMOVE_USER_CONFIGURATIONS: @@ -4337,7 +4337,7 @@ public class ClientModeImpl extends StateMachine { if (removedNetworkIds.contains(mTargetNetworkId) || removedNetworkIds.contains(mLastNetworkId)) { // Disconnect and let autojoin reselect a new network. - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } break; case WifiManager.CONNECT_NETWORK: @@ -4418,7 +4418,7 @@ public class ClientModeImpl extends StateMachine { netId = message.arg1; if (netId == mTargetNetworkId || netId == mLastNetworkId) { // Disconnect and let autojoin reselect a new network - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } break; case CMD_ASSOCIATED_BSSID: @@ -4482,7 +4482,7 @@ public class ClientModeImpl extends StateMachine { } else { logw("Connected to unknown networkId " + mLastNetworkId + ", disconnecting..."); - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } break; case WifiMonitor.NETWORK_DISCONNECTION_EVENT: @@ -4515,7 +4515,7 @@ public class ClientModeImpl extends StateMachine { if (isProviderOwnedNetwork(mTargetNetworkId, fqdn) || isProviderOwnedNetwork(mLastNetworkId, fqdn)) { logd("Disconnect from current network since its provider is updated"); - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } replyToMessage(message, message.what, SUCCESS); } else { @@ -4528,7 +4528,7 @@ public class ClientModeImpl extends StateMachine { if (isProviderOwnedNetwork(mTargetNetworkId, fqdn) || isProviderOwnedNetwork(mLastNetworkId, fqdn)) { logd("Disconnect from current network since its provider is removed"); - disconnectCommandInternal(); + sendMessage(CMD_DISCONNECT); } mWifiConfigManager.removePasspointConfiguredNetwork(fqdn); replyToMessage(message, message.what, SUCCESS); @@ -5055,17 +5055,8 @@ public class ClientModeImpl extends StateMachine { } break; case CMD_DISCONNECT: - boolean fromExternal = message.arg1 == 1; - if (fromExternal) { - mWifiMetrics.logStaEvent(StaEvent.TYPE_FRAMEWORK_DISCONNECT, - StaEvent.DISCONNECT_API); - // For external disconnect requests, temporarily disable the network. - mWifiConfigManager.updateNetworkSelectionStatus( - mLastNetworkId, DISABLED_BY_WIFI_MANAGER_DISCONNECT); - } else { - mWifiMetrics.logStaEvent(StaEvent.TYPE_FRAMEWORK_DISCONNECT, - StaEvent.DISCONNECT_GENERIC); - } + mWifiMetrics.logStaEvent(StaEvent.TYPE_FRAMEWORK_DISCONNECT, + StaEvent.DISCONNECT_GENERIC); mWifiNative.disconnect(mInterfaceName); transitionTo(mDisconnectingState); break; diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 92bec08a3..dfb3cd20f 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -16,8 +16,6 @@ package com.android.server.wifi; -import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_DISABLED_PERMANENT_STARTING_INDEX; - import android.annotation.Nullable; import android.app.ActivityManager; import android.app.admin.DeviceAdminInfo; @@ -128,7 +126,6 @@ public class WifiConfigManager { 1, // threshold for DISABLED_NO_INTERNET_TEMPORARY 1, // threshold for DISABLED_WPS_START 6, // threshold for DISABLED_TLS_VERSION_MISMATCH - 1, // threshold for DISABLED_BY_WIFI_MANAGER_DISCONNECT 1, // threshold for DISABLED_AUTHENTICATION_NO_CREDENTIALS 1, // threshold for DISABLED_NO_INTERNET_PERMANENT 1, // threshold for DISABLED_BY_WIFI_MANAGER @@ -153,7 +150,6 @@ public class WifiConfigManager { 10 * 60 * 1000, // threshold for DISABLED_NO_INTERNET_TEMPORARY 0 * 60 * 1000, // threshold for DISABLED_WPS_START Integer.MAX_VALUE, // threshold for DISABLED_TLS_VERSION - 1 * 60 * 60 * 1000, // threshold for DISABLED_BY_WIFI_MANAGER_DISCONNECT Integer.MAX_VALUE, // threshold for DISABLED_AUTHENTICATION_NO_CREDENTIALS Integer.MAX_VALUE, // threshold for DISABLED_NO_INTERNET_PERMANENT Integer.MAX_VALUE, // threshold for DISABLED_BY_WIFI_MANAGER @@ -1568,7 +1564,7 @@ public class WifiConfigManager { if (reason == NetworkSelectionStatus.NETWORK_SELECTION_ENABLE) { setNetworkSelectionEnabled(config); setNetworkStatus(config, WifiConfiguration.Status.ENABLED); - } else if (reason < NETWORK_SELECTION_DISABLED_PERMANENT_STARTING_INDEX) { + } else if (reason < NetworkSelectionStatus.DISABLED_TLS_VERSION_MISMATCH) { setNetworkSelectionTemporarilyDisabled(config, reason); } else { setNetworkSelectionPermanentlyDisabled(config, reason); diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java index 98f72c2e2..057fc99ac 100644 --- a/service/java/com/android/server/wifi/WifiNetworkFactory.java +++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java @@ -937,7 +937,7 @@ public class WifiNetworkFactory extends NetworkFactory { // Invoked at the termination of current connected request processing. private void teardownForConnectedNetwork() { Log.i(TAG, "Disconnecting from network on reset"); - mWifiInjector.getClientModeImpl().disconnectCommandInternal(); + mWifiInjector.getClientModeImpl().disconnectCommand(); mConnectedSpecificNetworkRequest = null; mConnectedSpecificNetworkRequestSpecifier = null; // ensure there is no active request in progress. diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java index 121d1cb60..12055704e 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java +++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java @@ -504,7 +504,7 @@ public class WifiNetworkSuggestionsManager { if (mActiveNetworkSuggestionsMatchingConnection.isEmpty()) { Log.i(TAG, "Only network suggestion matching the connected network removed. " + "Disconnecting..."); - mWifiInjector.getClientModeImpl().disconnectCommandInternal(); + mWifiInjector.getClientModeImpl().disconnectCommand(); } } } diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 83e8cb0f0..728a4b4ec 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1644,7 +1644,7 @@ public class WifiServiceImpl extends BaseWifiService { return false; } mLog.info("disconnect uid=%").c(Binder.getCallingUid()).flush(); - mClientModeImpl.disconnectCommandExternal(); + mClientModeImpl.disconnectCommand(); return true; } diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 4e7bec64d..22e8c2c1f 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -3304,40 +3304,4 @@ public class ClientModeImplTest { assertEquals(OP_PACKAGE_NAME, mCmi.getWifiInfo().getNetworkSuggestionOrSpecifierPackageName()); } - - /** - * Verifies the handling of disconnect initiated from API surface when connected to a network. - */ - @Test - public void testExternalDisconnectWhenConnected() throws Exception { - connect(); - - mCmi.disconnectCommandExternal(); // Simulate settings invoking this. - mLooper.dispatchAll(); - - verify(mWifiNative).disconnect(WIFI_IFACE_NAME); - verify(mWifiMetrics).logStaEvent(StaEvent.TYPE_FRAMEWORK_DISCONNECT, - StaEvent.DISCONNECT_API); - // verify that we temp blacklist the network. - verify(mWifiConfigManager).updateNetworkSelectionStatus(0, - WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WIFI_MANAGER_DISCONNECT); - } - - /** - * Verifies the handling of disconnect initiated internally when connected to a network. - */ - @Test - public void testInternalDisconnectWhenConnected() throws Exception { - connect(); - - mCmi.disconnectCommandInternal(); // Internal stack initiated disconnect. - mLooper.dispatchAll(); - - verify(mWifiNative).disconnect(WIFI_IFACE_NAME); - verify(mWifiMetrics).logStaEvent(StaEvent.TYPE_FRAMEWORK_DISCONNECT, - StaEvent.DISCONNECT_GENERIC); - // verify that we don't temp blacklist the network. - verify(mWifiConfigManager, never()).updateNetworkSelectionStatus(0, - WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WIFI_MANAGER_DISCONNECT); - } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 2fe85902e..5155ccb5f 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -16,8 +16,6 @@ package com.android.server.wifi; -import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_DISABLED_PERMANENT_STARTING_INDEX; - import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -4980,7 +4978,7 @@ public class WifiConfigManagerTest { NetworkSelectionStatus.INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP, retrievedDisableTime); verifyUpdateNetworkStatus(retrievedNetwork, WifiConfiguration.Status.ENABLED); - } else if (reason < NETWORK_SELECTION_DISABLED_PERMANENT_STARTING_INDEX) { + } else if (reason < NetworkSelectionStatus.DISABLED_TLS_VERSION_MISMATCH) { // For temporarily disabled networks, we need to ensure that the current status remains // until the threshold is crossed. assertEquals(temporaryDisableReasonCounter, retrievedDisableReasonCounter); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java index 5a41ae90e..a35d99da1 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java @@ -587,7 +587,7 @@ public class WifiNetworkFactoryTest { // Release the network request. mWifiNetworkFactory.releaseNetworkFor(mNetworkRequest); // Verify that we did not trigger a disconnect because we've not yet connected. - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); // Re-enable connectivity manager . verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false); @@ -1411,7 +1411,7 @@ public class WifiNetworkFactoryTest { // Now release the network request. mWifiNetworkFactory.releaseNetworkFor(mNetworkRequest); // Verify that we triggered a disconnect. - verify(mClientModeImpl).disconnectCommandInternal(); + verify(mClientModeImpl).disconnectCommand(); // Re-enable connectivity manager . verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false); } @@ -1586,12 +1586,12 @@ public class WifiNetworkFactoryTest { verify(mWifiConnectivityManager, times(1)).setSpecificNetworkRequestInProgress(true); verify(mWifiScanner, times(2)).startScan(any(), any(), any()); // we shouldn't disconnect until the user accepts the next request. - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); // Remove the connected request1 & ensure we disconnect. mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier1); mWifiNetworkFactory.releaseNetworkFor(mNetworkRequest); - verify(mClientModeImpl).disconnectCommandInternal(); + verify(mClientModeImpl).disconnectCommand(); verifyNoMoreInteractions(mWifiConnectivityManager, mWifiScanner, mClientModeImpl, mAlarmManager); @@ -1636,7 +1636,7 @@ public class WifiNetworkFactoryTest { // We shouldn't explicitly disconnect, the new connection attempt will implicitly disconnect // from the connected network. - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); // Remove the stale request1 & ensure nothing happens (because it was replaced by the // second request) @@ -1649,7 +1649,7 @@ public class WifiNetworkFactoryTest { // Now remove the rejected request2, ensure we disconnect & re-enable auto-join. mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier2); mWifiNetworkFactory.releaseNetworkFor(mNetworkRequest); - verify(mClientModeImpl).disconnectCommandInternal(); + verify(mClientModeImpl).disconnectCommand(); verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false); verifyNoMoreInteractions(mWifiConnectivityManager, mWifiScanner, mClientModeImpl, @@ -1685,12 +1685,12 @@ public class WifiNetworkFactoryTest { // we shouldn't disconnect/re-enable auto-join until the connected request is released. verify(mWifiConnectivityManager, never()).setSpecificNetworkRequestInProgress(false); - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); // Remove the connected request1 & ensure we disconnect & ensure auto-join is re-enabled. mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier1); mWifiNetworkFactory.releaseNetworkFor(mNetworkRequest); - verify(mClientModeImpl).disconnectCommandInternal(); + verify(mClientModeImpl).disconnectCommand(); verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false); verifyNoMoreInteractions(mWifiConnectivityManager, mWifiScanner, mClientModeImpl, diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index 4e2cb9b5d..eb09d239b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -1257,7 +1257,7 @@ public class WifiNetworkSuggestionsManagerTest { // Now remove the network suggestion and ensure we did not trigger a disconnect. assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS, mWifiNetworkSuggestionsManager.remove(networkSuggestionList, TEST_PACKAGE_1)); - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); } /** @@ -1293,11 +1293,11 @@ public class WifiNetworkSuggestionsManagerTest { // Now remove one of the apps and ensure we did not trigger a disconnect. mWifiNetworkSuggestionsManager.removeApp(TEST_PACKAGE_1); - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); // Now remove the other app and ensure we trigger a disconnect. mWifiNetworkSuggestionsManager.removeApp(TEST_PACKAGE_2); - verify(mClientModeImpl).disconnectCommandInternal(); + verify(mClientModeImpl).disconnectCommand(); } /** @@ -1324,7 +1324,7 @@ public class WifiNetworkSuggestionsManagerTest { // Now remove the app and ensure we did not trigger a disconnect. mWifiNetworkSuggestionsManager.removeApp(TEST_PACKAGE_1); - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); } /** @@ -1356,7 +1356,7 @@ public class WifiNetworkSuggestionsManagerTest { // Now remove the app and ensure we did not trigger a disconnect. mWifiNetworkSuggestionsManager.removeApp(TEST_PACKAGE_1); - verify(mClientModeImpl, never()).disconnectCommandInternal(); + verify(mClientModeImpl, never()).disconnectCommand(); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 191acc6a7..48efb51a6 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -2780,7 +2780,7 @@ public class WifiServiceImplTest { doThrow(new SecurityException()).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); assertTrue(mWifiServiceImpl.disconnect(TEST_PACKAGE_NAME)); - verify(mClientModeImpl).disconnectCommandExternal(); + verify(mClientModeImpl).disconnectCommand(); } /** @@ -2792,7 +2792,7 @@ public class WifiServiceImplTest { public void testDisconnectWithChangeWifiStatePerm() throws Exception { assertFalse(mWifiServiceImpl.disconnect(TEST_PACKAGE_NAME)); verifyCheckChangePermission(TEST_PACKAGE_NAME); - verify(mClientModeImpl, never()).disconnectCommandExternal(); + verify(mClientModeImpl, never()).disconnectCommand(); } /** @@ -2811,7 +2811,7 @@ public class WifiServiceImplTest { } verifyCheckChangePermission(TEST_PACKAGE_NAME); - verify(mClientModeImpl, never()).disconnectCommandExternal(); + verify(mClientModeImpl, never()).disconnectCommand(); } @Test |