summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-01-13 17:07:52 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-01-13 17:07:53 +0000
commitaba0ba2f764a87e0ac7708bdb13f1e1e51fd0ace (patch)
treeead6503fd5803db7e5ac3a3009db124d4b949054
parentf91694ff0b589d5b9fbe55b5da1b80642990321a (diff)
parentf826a412709e7e30bd993440fa8174596cc384e7 (diff)
Merge "WifiStateMachine: remove service dependence"
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java46
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java8
2 files changed, 33 insertions, 21 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 9b62a0cd6..5786d8b56 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -429,7 +429,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
// Channel for sending replies.
private AsyncChannel mReplyChannel = new AsyncChannel();
- private WifiP2pServiceImpl mWifiP2pServiceImpl;
private WifiAwareManager mWifiAwareManager;
// Used to initiate a connection with WifiP2pService
@@ -876,6 +875,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
.hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE);
mWifiConfigManager = mWifiInjector.getWifiConfigManager();
+ mWifiApConfigStore = mWifiInjector.getWifiApConfigStore();
mWifiSupplicantControl = mWifiInjector.getWifiSupplicantControl();
mWifiSupplicantControl.setSystemSupportsFastBssTransition(
mContext.getResources().getBoolean(R.bool.config_wifi_fast_bss_transition_enabled));
@@ -892,13 +892,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mLinkProperties = new LinkProperties();
- IBinder s1 = mFacade.getService(Context.WIFI_P2P_SERVICE);
- mWifiP2pServiceImpl = (WifiP2pServiceImpl) IWifiP2pManager.Stub.asInterface(s1);
-
- if (mAwareSupported) {
- mWifiAwareManager = mContext.getSystemService(WifiAwareManager.class);
- }
-
mNetworkInfo.setIsAvailable(false);
mLastBssid = null;
mLastNetworkId = WifiConfiguration.INVALID_NETWORK_ID;
@@ -3653,6 +3646,31 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
}
+ /**
+ * WifiStateMachine needs to enable/disable other services when wifi is in client mode. This
+ * method allows WifiStateMachine to get these additional system services.
+ *
+ * At this time, this method is used to setup variables for P2P service and Wifi Aware.
+ */
+ private void getAdditionalWifiServiceInterfaces() {
+ // First set up Wifi Direct
+ // TODO: b/34193861 determine if we can avoid starting WIFI_P2P_SERVICE when not supported
+ IBinder s1 = mFacade.getService(Context.WIFI_P2P_SERVICE);
+ WifiP2pServiceImpl wifiP2pServiceImpl =
+ (WifiP2pServiceImpl) IWifiP2pManager.Stub.asInterface(s1);
+
+ if (wifiP2pServiceImpl != null) {
+ mWifiP2pChannel = new AsyncChannel();
+ mWifiP2pChannel.connect(mContext, getHandler(),
+ wifiP2pServiceImpl.getP2pStateMachineMessenger());
+ }
+
+ // Set up Wifi Aware
+ if (mAwareSupported) {
+ mWifiAwareManager = mContext.getSystemService(WifiAwareManager.class);
+ }
+ }
+
/********************************************************
* HSM states
*******************************************************/
@@ -3716,6 +3734,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
break;
case CMD_BOOT_COMPLETED:
+ // get other services that we need to manage
+ getAdditionalWifiServiceInterfaces();
maybeRegisterNetworkFactory();
break;
case CMD_SCREEN_STATE_CHANGED:
@@ -3944,16 +3964,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
@Override
public void enter() {
cleanup();
- if (mWifiP2pChannel == null && mWifiP2pServiceImpl != null) {
- mWifiP2pChannel = new AsyncChannel();
- mWifiP2pChannel.connect(mContext, getHandler(),
- mWifiP2pServiceImpl.getP2pStateMachineMessenger());
- }
-
- if (mWifiApConfigStore == null) {
- mWifiApConfigStore = mWifiInjector.getWifiApConfigStore();
- }
}
+
@Override
public boolean processMessage(Message message) {
logStateAndMessage(message, this);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 349f26983..5fb6513f4 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -837,7 +837,7 @@ public class WifiStateMachineTest {
@Test
public void normalLogRecSizeIsUsedByDefault() {
for (int i = 0; i < WifiStateMachine.NUM_LOG_RECS_NORMAL * 2; i++) {
- mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ mWsm.sendMessage(WifiStateMachine.CMD_DISCONNECT);
}
mLooper.dispatchAll();
assertEquals(WifiStateMachine.NUM_LOG_RECS_NORMAL, mWsm.getLogRecSize());
@@ -851,7 +851,7 @@ public class WifiStateMachineTest {
assertTrue(LOG_REC_LIMIT_IN_VERBOSE_MODE > WifiStateMachine.NUM_LOG_RECS_NORMAL);
mWsm.enableVerboseLogging(1);
for (int i = 0; i < LOG_REC_LIMIT_IN_VERBOSE_MODE * 2; i++) {
- mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ mWsm.sendMessage(WifiStateMachine.CMD_DISCONNECT);
}
mLooper.dispatchAll();
assertEquals(LOG_REC_LIMIT_IN_VERBOSE_MODE, mWsm.getLogRecSize());
@@ -865,7 +865,7 @@ public class WifiStateMachineTest {
public void disablingVerboseLoggingClearsRecordsAndDecreasesLogRecSize() {
mWsm.enableVerboseLogging(1);
for (int i = 0; i < LOG_REC_LIMIT_IN_VERBOSE_MODE; i++) {
- mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ mWsm.sendMessage(WifiStateMachine.CMD_DISCONNECT);
}
mLooper.dispatchAll();
assertEquals(LOG_REC_LIMIT_IN_VERBOSE_MODE, mWsm.getLogRecSize());
@@ -873,7 +873,7 @@ public class WifiStateMachineTest {
mWsm.enableVerboseLogging(0);
assertEquals(0, mWsm.getLogRecSize());
for (int i = 0; i < LOG_REC_LIMIT_IN_VERBOSE_MODE; i++) {
- mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ mWsm.sendMessage(WifiStateMachine.CMD_DISCONNECT);
}
mLooper.dispatchAll();
assertEquals(WifiStateMachine.NUM_LOG_RECS_NORMAL, mWsm.getLogRecSize());