summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2017-05-09 17:43:21 -0700
committermukesh agrawal <quiche@google.com>2017-06-07 19:11:36 -0700
commit5e6aea460e272ef7c70029abe9f0e5a695ad119e (patch)
treec2333f529cdc96d08345f12ea098d6917f239821 /tests
parent9da08e01464d39de3f14fe09f535660635d39c42 (diff)
WifiVendorHal: improve handling of debug events
Move processing of debug events (onRingBufferDataAvailable and onDebugErrorAlert) from a HWBinder thread, to the WifiStateMachine thread. The idea here is to quickly free up shared resources: the thread on which we receive the HIDL event, and the HWBinder async buffer space that is used to queue pending upcalls. The reason we want to free up these resources more quickly is that, in some cases, the debug events need to wait 100-200msec to acquire the WifiDiagnostics object's intrinsic lock. A risk of this change is that we might use a large amount of memory by queuing up large amounts of ring-buffer data callbacks on the Looper's MessageQueue. However, I think that is a better risk to take, than the risk of starving other HALs of access to HWBinder resources. Bug: 38182372 Test: tests/wifitests/runtests.sh # on bullhead Test: adb shell dumpsys wifi | grep TIMEOUT # expect no match Change-Id: I7ec24f8b862cfb8ac100b1c975d732a886ed09fe
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index 66a55b51a..34ddf2378 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -1679,9 +1679,10 @@ public class WifiVendorHalTest {
new Random().nextBytes(errorData);
// Randomly raise the HIDL callback before we register for the log callback.
- // This should be ignored.
+ // This should be safely ignored. (Not trigger NPE.)
mIWifiChipEventCallback.onDebugErrorAlert(
errorCode, NativeUtil.byteArrayToArrayList(errorData));
+ mLooper.dispatchAll();
WifiNative.WifiLoggerEventHandler eventHandler =
mock(WifiNative.WifiLoggerEventHandler.class);
@@ -1691,12 +1692,16 @@ public class WifiVendorHalTest {
// Now raise the HIDL callback, this should be properly handled.
mIWifiChipEventCallback.onDebugErrorAlert(
errorCode, NativeUtil.byteArrayToArrayList(errorData));
+ mLooper.dispatchAll();
verify(eventHandler).onWifiAlert(eq(errorCode), eq(errorData));
// Now stop the logging and invoke the callback. This should be ignored.
+ reset(eventHandler);
assertTrue(mWifiVendorHal.resetLogHandler());
mIWifiChipEventCallback.onDebugErrorAlert(
errorCode, NativeUtil.byteArrayToArrayList(errorData));
+ mLooper.dispatchAll();
+ verify(eventHandler, never()).onWifiAlert(anyInt(), anyObject());
}
/**
@@ -1714,9 +1719,10 @@ public class WifiVendorHalTest {
new Random().nextBytes(errorData);
// Randomly raise the HIDL callback before we register for the log callback.
- // This should be ignored.
+ // This should be safely ignored. (Not trigger NPE.)
mIWifiChipEventCallback.onDebugRingBufferDataAvailable(
new WifiDebugRingBufferStatus(), NativeUtil.byteArrayToArrayList(errorData));
+ mLooper.dispatchAll();
WifiNative.WifiLoggerEventHandler eventHandler =
mock(WifiNative.WifiLoggerEventHandler.class);
@@ -1726,13 +1732,17 @@ public class WifiVendorHalTest {
// Now raise the HIDL callback, this should be properly handled.
mIWifiChipEventCallback.onDebugRingBufferDataAvailable(
new WifiDebugRingBufferStatus(), NativeUtil.byteArrayToArrayList(errorData));
+ mLooper.dispatchAll();
verify(eventHandler).onRingBufferData(
any(WifiNative.RingBufferStatus.class), eq(errorData));
// Now stop the logging and invoke the callback. This should be ignored.
+ reset(eventHandler);
assertTrue(mWifiVendorHal.resetLogHandler());
mIWifiChipEventCallback.onDebugRingBufferDataAvailable(
new WifiDebugRingBufferStatus(), NativeUtil.byteArrayToArrayList(errorData));
+ mLooper.dispatchAll();
+ verify(eventHandler, never()).onRingBufferData(anyObject(), anyObject());
}
/**