summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2018-04-24 16:39:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-04-24 16:39:04 +0000
commitd306f961e6cf39e5edc30de519f7ebebb1157c9b (patch)
tree175b2246e4715fde47d9e4b0d18e43e7a7e48633 /service
parentc1446c32c8784809ac81f35a1794771eeb6d57cc (diff)
parent51e701cd43459ed946e46e306d4156e4f9aed73e (diff)
Merge "ClientModeManager: set wifi state" into pi-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ClientModeManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java58
2 files changed, 30 insertions, 30 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeManager.java b/service/java/com/android/server/wifi/ClientModeManager.java
index 4fd3c6e27..f45623663 100644
--- a/service/java/com/android/server/wifi/ClientModeManager.java
+++ b/service/java/com/android/server/wifi/ClientModeManager.java
@@ -111,6 +111,8 @@ public class ClientModeManager implements ActiveModeManager {
return;
}
+ mWifiStateMachine.setWifiStateForApiCalls(newState);
+
final Intent intent = new Intent(WifiManager.WIFI_STATE_CHANGED_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
intent.putExtra(WifiManager.EXTRA_WIFI_STATE, newState);
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index bae8f3a3b..84db81b39 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -1379,7 +1379,34 @@ public class WifiStateMachine extends StateMachine {
}
/**
- * TODO: doc
+ * Temporary method that allows the active ClientModeManager to set the wifi state that is
+ * retrieved by API calls. This will be removed when WifiServiceImpl no longer directly calls
+ * this class (b/31479117).
+ *
+ * @param newState new state to set, invalid states are ignored.
+ */
+ public void setWifiStateForApiCalls(int newState) {
+ switch (newState) {
+ case WIFI_STATE_DISABLING:
+ case WIFI_STATE_DISABLED:
+ case WIFI_STATE_ENABLING:
+ case WIFI_STATE_ENABLED:
+ case WIFI_STATE_UNKNOWN:
+ if (mVerboseLoggingEnabled) {
+ Log.d(TAG, "setting wifi state to: " + newState);
+ }
+ mWifiState.set(newState);
+ return;
+ default:
+ Log.d(TAG, "attempted to set an invalid state: " + newState);
+ return;
+ }
+ }
+
+ /**
+ * Method used by WifiServiceImpl to get the current state of Wifi (in client mode) for API
+ * calls. This will be removed when WifiService no longer directly calls this class
+ * (b/31479117).
*/
public int syncGetWifiState() {
return mWifiState.get();
@@ -2451,31 +2478,6 @@ public class WifiStateMachine extends StateMachine {
if (mVerboseLoggingEnabled) log("mSuspendOptNeedsDisabled " + mSuspendOptNeedsDisabled);
}
- private void setWifiState(int wifiState) {
- final int previousWifiState = mWifiState.get();
-
- mWifiState.set(wifiState);
-
- if (mVerboseLoggingEnabled) log("setWifiState: " + syncGetWifiStateByName());
-
- // first let WifiController know what is going on
- if (mClientModeCallback != null) {
- mClientModeCallback.onStateChanged(wifiState);
- // once this instance of client mode is complete, remove the callback so we don't
- // confuse ourselves
- if (wifiState == WifiManager.WIFI_STATE_UNKNOWN
- || wifiState == WifiManager.WIFI_STATE_DISABLED) {
- mClientModeCallback = null;
- }
- }
-
- final Intent intent = new Intent(WifiManager.WIFI_STATE_CHANGED_ACTION);
- intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
- intent.putExtra(WifiManager.EXTRA_WIFI_STATE, wifiState);
- intent.putExtra(WifiManager.EXTRA_PREVIOUS_WIFI_STATE, previousWifiState);
- mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
- }
-
/*
* Fetch RSSI, linkspeed, and frequency on current connection
*/
@@ -3814,7 +3816,6 @@ public class WifiStateMachine extends StateMachine {
if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo);
mCountryCode.setReadyForChange(false);
mInterfaceName = null;
- setWifiState(WIFI_STATE_DISABLED);
}
void registerConnected() {
@@ -3886,8 +3887,6 @@ public class WifiStateMachine extends StateMachine {
mScanRequestProxy.enableScanningForHiddenNetworks(true);
mWifiInfo.reset();
mWifiInfo.setSupplicantState(SupplicantState.DISCONNECTED);
- // Let the system know that wifi is available in client mode.
- setWifiState(WIFI_STATE_ENABLED);
mWifiInjector.getWakeupController().reset();
@@ -3925,7 +3924,6 @@ public class WifiStateMachine extends StateMachine {
mScanRequestProxy.clearScanResults();
mWifiInfo.reset();
mWifiInfo.setSupplicantState(SupplicantState.DISCONNECTED);
- setWifiState(WIFI_STATE_DISABLED);
stopClientMode();
}