summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2017-01-25 11:10:34 -0800
committerEtan Cohen <etancohen@google.com>2017-01-25 21:39:08 +0000
commit6d3e37d70c416a408931e72a8a62de25004fc22c (patch)
treeccdd9c02b1f07c50b67b8586d599b6ebc09b95a4 /service
parent1716aa7ad8e00a41980c4120c2104b25fe36630e (diff)
[AWARE] Update Wi-Fi state machine to enable Aware
Use lazy initialization of WifiAwareManager. Prevents race condition or order-of-initialization issues which were causing WifiAwareManager to be null when the state machine was trying to use it to enable Aware. Bug: 34708106 Test: aware integration sl4a tests pass Change-Id: I7dc1e13287b51299b1464ad66fff54f0c94e2adc
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index bfcb1e89e..1c0c27dfa 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -3668,11 +3668,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
wifiP2pServiceImpl.getP2pStateMachineMessenger());
}
}
-
- // Set up Wifi Aware
- if (mAwareSupported) {
- mWifiAwareManager = mContext.getSystemService(WifiAwareManager.class);
- }
}
/********************************************************
@@ -4228,14 +4223,21 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
}
- if (mAwareSupported && mWifiAwareManager != null) {
- if (mOperationalMode == CONNECT_MODE) {
- mWifiAwareManager.enableUsage();
+ if (mAwareSupported) {
+ if (mWifiAwareManager == null) {
+ mWifiAwareManager = mContext.getSystemService(WifiAwareManager.class);
+ }
+ if (mWifiAwareManager == null) {
+ Log.e(TAG, "Can't get WifiAwareManager to enable usage!");
} else {
+ if (mOperationalMode == CONNECT_MODE) {
+ mWifiAwareManager.enableUsage();
+ } else {
/*
* Aware state machine starts in disabled state. Nothing
* needed to keep it disabled.
*/
+ }
}
}
@@ -4403,8 +4405,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
mBufferedScanMsg.clear();
- if (mAwareSupported && mWifiAwareManager != null) {
- mWifiAwareManager.disableUsage();
+ if (mAwareSupported) {
+ if (mWifiAwareManager == null) {
+ mWifiAwareManager = mContext.getSystemService(WifiAwareManager.class);
+ }
+ if (mWifiAwareManager == null) {
+ Log.e(TAG, "Can't get WifiAwareManager (to disable usage)!");
+ } else {
+ mWifiAwareManager.disableUsage();
+ }
}
mNetworkInfo.setIsAvailable(false);