summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-04-06 19:07:38 -0700
committerRoshan Pius <rpius@google.com>2020-04-07 10:20:04 -0700
commit168ede29fc294eb4063f0cc2e54b4e9f9394dc01 (patch)
treef22dd0e79d88c99050bb18c581803f5b1127496d /service
parent21f44c83048dc643d699fe821ccc17a4e0509eb0 (diff)
WifiNetworkFactory: Ensure we disconnect when we release request
If the app releases a request in the midst of a connection attempt, ensure we trigger a disconnect. The current logic only triggers a disconnect if the app releases the request after the connection is established. Bug: 149500993 Test: act.py -c wifi_manager_cross.config -tb dut-name -tc WifiNetworkRequestTest Test: atest com.android.server.wifi Change-Id: I614c43b1d3121d50c719c428a835305df51ef792
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkFactory.java8
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java10
2 files changed, 13 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java
index 271bbefc4..26e602354 100644
--- a/service/java/com/android/server/wifi/WifiNetworkFactory.java
+++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java
@@ -645,11 +645,11 @@ public class WifiNetworkFactory extends NetworkFactory {
return;
}
if (Objects.equals(mActiveSpecificNetworkRequest, networkRequest)) {
- Log.i(TAG, "App released request, cancelling "
+ Log.i(TAG, "App released active request, cancelling "
+ mActiveSpecificNetworkRequest);
teardownForActiveRequest();
} else if (Objects.equals(mConnectedSpecificNetworkRequest, networkRequest)) {
- Log.i(TAG, "App released request, cancelling "
+ Log.i(TAG, "App released connected request, cancelling "
+ mConnectedSpecificNetworkRequest);
teardownForConnectedNetwork();
} else {
@@ -985,6 +985,10 @@ public class WifiNetworkFactory extends NetworkFactory {
// Invoked at the termination of current active request processing.
private void teardownForActiveRequest() {
+ if (mPendingConnectionSuccess) {
+ Log.i(TAG, "Disconnecting from network on reset");
+ disconnectAndRemoveNetworkFromWifiConfigManager(mUserSelectedNetwork);
+ }
cleanupActiveRequest();
// ensure there is no connected request in progress.
if (mConnectedSpecificNetworkRequest == null) {
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index 1ec56b4ab..64b29f2ac 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -470,9 +470,13 @@ public class WifiShellCommand extends BasicShellCommandHandler {
pw.println("Wifi is connected to " + info.getSSID());
pw.println("WifiInfo: " + info);
Network network = mWifiService.getCurrentNetwork();
- NetworkCapabilities capabilities =
- mConnectivityManager.getNetworkCapabilities(network);
- pw.println("NetworkCapabilities: " + capabilities);
+ try {
+ NetworkCapabilities capabilities =
+ mConnectivityManager.getNetworkCapabilities(network);
+ pw.println("NetworkCapabilities: " + capabilities);
+ } catch (SecurityException e) {
+ // ignore on unrooted shell.
+ }
} else {
pw.println("Wifi is not connected");
}