summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2017-04-23 22:46:41 -0700
committerEtan Cohen <etancohen@google.com>2017-04-23 22:46:41 -0700
commit0b31edb987c0552b75667e05f0d589937a16f1ad (patch)
tree2002d6da95c2b5dac52b799ad3e4bb326bfded89 /service
parentb44557082dfab11dcd4b4344dfa6de7259058297 (diff)
[AWARE] Fix race condition of Aware state machine & HAL
The Wi-Fi Aware HAL was started before the Aware state machine was ready. In case where the HAL was able to obtain a handle on the NAN interface it would attempt to enable Aware through the state machine - resulting in an NPE. Added an explicit start method to the Aware HAL which is called in order. Bug: 37613363 Test: unit tests and integration (sl4a) test Change-Id: I66698bd926ca5d4bdb19b3025ed2f26c61028d21
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java3
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareService.java1
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareStateManager.java4
3 files changed, 4 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
index 22f13851f..f1945808f 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
@@ -53,6 +53,9 @@ class WifiAwareNativeManager {
mWifiAwareStateManager = awareStateManager;
mHalDeviceManager = halDeviceManager;
mWifiAwareNativeCallback = wifiAwareNativeCallback;
+ }
+
+ public void start() {
mHalDeviceManager.registerStatusListener(
new HalDeviceManager.ManagerStatusListener() {
@Override
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareService.java b/service/java/com/android/server/wifi/aware/WifiAwareService.java
index 75efa0296..bd8156e17 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareService.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareService.java
@@ -65,6 +65,7 @@ public final class WifiAwareService extends SystemService {
HandlerThread awareHandlerThread = wifiInjector.getWifiAwareHandlerThread();
mImpl.start(awareHandlerThread, wifiAwareStateManager);
+ wifiAwareNativeManager.start();
} else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
mImpl.startLate();
}
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
index 1d00d162d..a35c786ee 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
@@ -391,10 +391,6 @@ public class WifiAwareStateManager {
* only happens when a connection is created.
*/
public void enableUsage() {
- if (mSm == null) {
- Log.e(TAG, "enableUsage: race condition - called while mSm null!");
- return;
- }
Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND);
msg.arg1 = COMMAND_TYPE_ENABLE_USAGE;
mSm.sendMessage(msg);