summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2018-04-23 11:07:07 -0700
committerRebecca Silberstein <silberst@google.com>2018-04-23 16:03:26 -0700
commit51e701cd43459ed946e46e306d4156e4f9aed73e (patch)
treecaf35d1a550ae7227f2ce24f09eb8385837c6df0 /service
parent1fd43a9ace3814f13f4a865878c9c11fe5cdd18b (diff)
ClientModeManager: set wifi state
Add call to set current wifi state (client mode) for ClientModeManager to WifiStateMachine to service API calls requesting the current wifi state. Verified added verbose logging: 04-23 13:59:36.901 18053 18194 D WifiStateMachine: setting wifi state to: 2 04-23 13:59:37.340 18053 18194 D WifiStateMachine: setting wifi state to: 3 04-23 13:59:53.874 18053 18194 D WifiStateMachine: setting wifi state to: 0 04-23 13:59:54.943 18053 18194 D WifiStateMachine: setting wifi state to: 1 Bug: 78247892 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: manually checked wifi states in bug report Test: ran WifiManager CTS tests Change-Id: Id515c46f805e6d18c0bcb81df4778a556ae6cc19
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();
}