summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/WifiNetworkFactory.java
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-12-04 08:22:30 -0800
committerRoshan Pius <rpius@google.com>2018-12-06 14:20:59 -0800
commit90c812d29c263b265bc8c2f1dacb6636ae61e6de (patch)
tree3ae1a6afd74a0075d28f5bc943f5ce25473616a0 /service/java/com/android/server/wifi/WifiNetworkFactory.java
parent56ada4f17193a6e6a90dea7ffe0c9a37920cd952 (diff)
downloadandroid_frameworks_opt_net_wifi-90c812d29c263b265bc8c2f1dacb6636ae61e6de.tar.gz
android_frameworks_opt_net_wifi-90c812d29c263b265bc8c2f1dacb6636ae61e6de.tar.bz2
android_frameworks_opt_net_wifi-90c812d29c263b265bc8c2f1dacb6636ae61e6de.zip
WifiNetworkFactory: Handle wifi toggle
Abort any ongoing requests and reject any new requests when wifi is toggled off. Bug: 120477750 Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: Ie7bc6908ecbba0ea25f2eea1a53793384fd178bd
Diffstat (limited to 'service/java/com/android/server/wifi/WifiNetworkFactory.java')
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkFactory.java33
1 files changed, 31 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java
index e3a8d5c32..3e757ee8f 100644
--- a/service/java/com/android/server/wifi/WifiNetworkFactory.java
+++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java
@@ -105,6 +105,7 @@ public class WifiNetworkFactory extends NetworkFactory {
private boolean mConnectionTimeoutSet = false;
private boolean mIsConnectedToUserSelectedNetwork = false;
private boolean mIsPeriodicScanPaused = false;
+ private boolean mWifiEnabled = false;
// Scan listener for scan requests.
private class NetworkFactoryScanListener implements WifiScanner.ScanListener {
@@ -315,6 +316,10 @@ public class WifiNetworkFactory extends NetworkFactory {
Log.e(TAG, "Invalid network specifier mentioned. Rejecting");
return false;
}
+ if (!mWifiEnabled) {
+ Log.e(TAG, "Wifi off. Rejecting");
+ return false;
+ }
WifiNetworkSpecifier wns = (WifiNetworkSpecifier) ns;
if (!WifiConfigurationUtil.validateNetworkSpecifier(wns)) {
@@ -375,6 +380,10 @@ public class WifiNetworkFactory extends NetworkFactory {
Log.e(TAG, "Invalid network specifier mentioned. Rejecting");
return;
}
+ if (!mWifiEnabled) {
+ Log.e(TAG, "Wifi off. Rejecting");
+ return;
+ }
retrieveWifiScanner();
// Reset state from any previous request.
resetStateForActiveRequestStart();
@@ -408,7 +417,11 @@ public class WifiNetworkFactory extends NetworkFactory {
} else {
// Invalid network specifier.
if (!(ns instanceof WifiNetworkSpecifier)) {
- Log.e(TAG, "Invalid network specifier mentioned. Ingoring");
+ Log.e(TAG, "Invalid network specifier mentioned. Ignoring");
+ return;
+ }
+ if (!mWifiEnabled) {
+ Log.e(TAG, "Wifi off. Ignoring");
return;
}
if (mActiveSpecificNetworkRequest == null) {
@@ -592,6 +605,22 @@ public class WifiNetworkFactory extends NetworkFactory {
}
}
+ /**
+ * Invoked by {@link ClientModeImpl} to indicate wifi state toggle.
+ */
+ public void setWifiState(boolean enabled) {
+ if (mVerboseLoggingEnabled) Log.v(TAG, "setWifiState " + enabled);
+ if (enabled) {
+ reevaluateAllRequests(); // Re-evaluate any pending requests.
+ } else {
+ if (mActiveSpecificNetworkRequest != null) {
+ Log.w(TAG, "Wifi off, cancelling " + mActiveSpecificNetworkRequest);
+ resetStateForActiveRequestEnd();
+ }
+ }
+ mWifiEnabled = enabled;
+ }
+
private void resetState() {
if (mIsConnectedToUserSelectedNetwork) {
Log.i(TAG, "Disconnecting from network on reset");
@@ -757,7 +786,7 @@ public class WifiNetworkFactory extends NetworkFactory {
}
}
if (mVerboseLoggingEnabled) {
- Log.e(TAG, "List of scan results matching the active request "
+ Log.v(TAG, "List of scan results matching the active request "
+ matchedScanResults);
}
return matchedScanResults;