Commit graph

346 commits

Author SHA1 Message Date
Anthony Stange
c34e6683b1 Add a sub-HAL implementation for testing multi-HAL
Creates a fake sub-HAL using the default implementation for sensors HAL
2.0 with some small modifications to support the multi-HAL interface.

This sub-HAL can be configured to support two different sets of sensors
making it easier to build and load two different sub-HAL implementations
onto device and verify the multihal implementation works.

Bug: 136511617
Test: compile only. Once multihal can load in sub-HALs, then this can be
accurately tested.

Change-Id: I9b136506bdbc8a3b196fd363748bddfcdd564daf
2019-08-13 21:48:20 +00:00
Anthony Stange
a689f8a65b Add skeleton for multihal 2.0
Creates a basic set of structures needed to implement multihal 2.0.
Descriptions of each are as follows:

HalProxy - Main point of contact from the sensors framework. Implements
the ISensors interface and will implement several callbacks passed to
sub-HALs in the future

SubHal - Contains interface that sub-HALs are expected to implement in
order to be loaded properly by the HalProxy. Also contains definitions
for various callbacks and classes that will be fully implemented by the
HalProxy.

service.cpp - contains the main function that is reponsible for
initializing the HalProxy and starting the thread pool that will handle
communication between the HalProxy and sensors framework.

Bug: 136511617
Test: compile for now. Stubbed out sub-HAL to be added in a followup CL
    to facilitate testing before a vendor implements the subHAL
    interface.
Change-Id: If663159d444d721a0a65ebe49dd92e8924bbb3a3
2019-08-12 09:26:08 -04:00
Brian Duddie
d48333f6e1 Merge changes from topic "c2f2_sensors_vts" into qt-r1-dev am: 8813be6341 am: bab0c7efe3
am: 93d6c13f8e

Change-Id: Id49809aa35dfafb607c8ba781e48e1357981daa6
2019-08-02 21:11:02 -07:00
Anthony Stange
3883b06ed3 Change expected return type in direct report VTS am: 4bdd8fc774 am: 86063dc8da
am: 7063c1b00e

Change-Id: Ic541b4559b8958fd391553eedfc98b0f431168f8
2019-08-02 21:10:56 -07:00
Brian Duddie
b8959f4d0d Add support for new gralloc HAL versions am: df6e2b70ae am: 1eee061c84
am: 43e152dc7f

Change-Id: I6948a686cd20b139cd70a887e6797be51648d8ec
2019-08-02 21:10:52 -07:00
Vishal Agarwal
bb94a725ca Merge "VTS Sensor HAL 2.0: Fix Batch for One Shot sensors" into qt-r1-dev am: effdb89c97 am: 7af073c790
am: 2fe3c426b7

Change-Id: I907a418ab70bca9500677e65ab9fdfc80d9a5599
2019-08-02 21:10:48 -07:00
Brian Duddie
bab0c7efe3 Merge changes from topic "c2f2_sensors_vts" into qt-r1-dev
am: 8813be6341

Change-Id: Ie652236cdbd4734dc723fac8c27ca876161f623d
2019-08-02 19:40:55 -07:00
Anthony Stange
86063dc8da Change expected return type in direct report VTS
am: 4bdd8fc774

Change-Id: I7b313096992aa15f34a408fbed67b02e74060d5f
2019-08-02 19:40:49 -07:00
Brian Duddie
1eee061c84 Add support for new gralloc HAL versions
am: df6e2b70ae

Change-Id: Iea28b01046e9094a28d538119e5acdf845385f6f
2019-08-02 19:40:42 -07:00
Vishal Agarwal
7af073c790 Merge "VTS Sensor HAL 2.0: Fix Batch for One Shot sensors" into qt-r1-dev
am: effdb89c97

Change-Id: Ie3fa0c0a3a02e58d88ecc6971ca8bb744c005103
2019-08-02 19:40:33 -07:00
TreeHugger Robot
8813be6341 Merge changes from topic "c2f2_sensors_vts" into qt-r1-dev
* changes:
  Fix handling of reportToken when stopping
  Change expected return type in direct report VTS
  Add support for new gralloc HAL versions
2019-08-03 02:32:32 +00:00
TreeHugger Robot
effdb89c97 Merge "VTS Sensor HAL 2.0: Fix Batch for One Shot sensors" into qt-r1-dev 2019-08-03 02:32:32 +00:00
Andrew Lehmer
db00373b1b Fix assumptions in SensorsHidlTest.NoStaleEvents am: d8b212ec3e am: fec6b3b18f
am: 9b65c929d0

Change-Id: I98efe951a44574640426b72151bc07d478efe332
2019-08-02 18:14:05 -07:00
Andrew Lehmer
9b65c929d0 Fix assumptions in SensorsHidlTest.NoStaleEvents am: d8b212ec3e
am: fec6b3b18f

Change-Id: I804356a47b3c7178a14f347cd3c38be22b98a39b
2019-08-02 17:44:30 -07:00
Andrew Lehmer
2e3eceded7 Fix assumptions in SensorsHidlTest.NoStaleEvents
am: d8b212ec3e

Change-Id: I039f346605006576c7854de75d4d57b0aac08324
2019-08-02 17:33:35 -07:00
Brian Duddie
63d4f57976 Fix handling of reportToken when stopping
VTS should ignore the reportToken returned by configDirectReport when it
passes in RateLevel::STOP.

Bug: 138758242
Test: run direct channel tests on device using 2.0 HAL
Change-Id: I07e789157e051ceab488a61e856f17d50f435072
2019-08-02 15:16:45 -07:00
Anthony Stange
4bdd8fc774 Change expected return type in direct report VTS
If a sensor doesn't support a particular memory type for direct
reporting, then registerChannel will return an invalid channel handle.
When this handle is used in configureDirectReport, it will return
BAD_VALUE and when used in unregisterDirectReport, it will return OK.
Currently, the VTS tests assert it will return INVALID_OPERATION, but
that will only happen if the entire HAL doesn't support direct
reporting instead of a single sensor not supporting a certain memory
type.

Bug: 138758242
Test: Run VTS and verify DirectChannel* tests now pass
Change-Id: Ifba4262b68ec0c4ca6921dad40a03e0a52088d28
2019-08-02 15:08:30 -07:00
Vishal Agarwal
66d8297210 VTS Sensor HAL 2.0: Fix Batch for One Shot sensors
One Shot sensors have minDelay set to -1. Force the minDelay to be 0 in
the VTS test to avoid errors from invalid parameter

Bug: 138758242
Test: Run Batch test manually VtsHalSensorsV2_0TargetTest --gtest_filter=SensorsHidlTest.Batch
Change-Id: Ib2287f6f11502c10d346f5e7216c5f31d585edf9
2019-08-02 14:03:41 -07:00
Andrew Lehmer
d8b212ec3e Fix assumptions in SensorsHidlTest.NoStaleEvents
This test was making a couple of false assumptions which were causing it
to fail. The fixes are related to the following assertions:
  1. One-shot sensors do not report an initial event.
  2. Special sensors may not report an initial event.
  2. Some on-change sensors may not report an initial event.
The test now only checks for a stale event if the sensor reports an
initial event consistently.

Bug: 138758242
Test: ran on C2 DVT; only fails due to an improperly configured sensor
Change-Id: I83f0cb2f6e878244f3d94ae77f64bb8ed2f78e0b
2019-08-02 14:01:57 -07:00
Brian Duddie
df6e2b70ae Add support for new gralloc HAL versions
As VTS connects to the IMapper and IAllocator HALs directly, it needs to
handle the case where the device only supports the newer HAL versions,
which includes IMapper 2.1 & 3.0 and IAllocator 3.0.

Since sensors VTS uses the same functionality from the different HAL
versions, condense the code into a common interface with HAL
version-specific template instantiation. Also remove the unused code
that came along with copying from the gralloc VTS reference source.

Bug: 138758242
Test: run gralloc-related sensors VTS on Pixel 2+
Change-Id: I1646d8f92546623594af8541bc8ac02955370694
2019-08-02 12:07:39 -07:00
Anthony Stange
57800d71f6 Update OWNERS for sensors HAL
Changes sensors team owners to reflect the current owners on the team.

Test: N/A
Change-Id: Ic5b957bc65688ffb2bce7d0eab256a5153b61efd
2019-07-31 09:47:06 -04:00
Anthony Stange
09100250f7 Merge "Fix wait_for timestamps in Sensors VTS" into qt-r1-dev am: 29c8337d89 am: e62371fe48
am: 848f995df5

Change-Id: I0266ed4a31a3bc6e1978b20cfd958dbb7e663950
2019-07-29 16:42:32 -07:00
Anthony Stange
848f995df5 Merge "Fix wait_for timestamps in Sensors VTS" into qt-r1-dev am: 29c8337d89
am: e62371fe48

Change-Id: Ic56589dde075b4e1709b140ee439887a36f9994c
2019-07-29 15:53:39 -07:00
Anthony Stange
1cc1242cbe Merge "Fix wait_for timestamps in Sensors VTS" into qt-r1-dev
am: 29c8337d89

Change-Id: I781d960f513045bdf46e8ee6e2f613e8e0f5aa8a
2019-07-29 15:45:41 -07:00
Anthony Stange
4a80e231ed Fix wait_for timestamps in Sensors VTS
Previously, NoStaleEvents was treating any timestamps it dealt with as
if they were in microseconds, but sensors.minDelay is in microseconds
and Event timestamps are in nanoseconds. This uses std::chrono helpers
to ensure the correct time is used when deciding how long to sleep
during the test so that if waitForEvents never passes, the test doesn't
time out.

Bug: 136736906
Test: Run VTS and verify VtsHalSensorsV2_0Target doesn't finish as an
    incomplete module.

Change-Id: Ibba59dbf9312f97d7275e5aa8cd36547ab09e328
2019-07-29 14:40:20 -04:00
Anthony Stange
0a049754b3 Verify mPollThread is joinable before detaching am: 65945cfb15 am: f75cf1cf4d
am: ce98cb7938

Change-Id: If939dfc29dade2ab90dc398253e5eb73752e4c19
2019-07-15 18:47:51 -07:00
Anthony Stange
ce98cb7938 Verify mPollThread is joinable before detaching am: 65945cfb15
am: f75cf1cf4d

Change-Id: I8282d67898fffa2efff979250b10dde842511daa
2019-07-15 18:12:24 -07:00
Anthony Stange
f75cf1cf4d Verify mPollThread is joinable before detaching
am: 65945cfb15

Change-Id: Iee183865223aa993241c19924245177b3462d4da
2019-07-15 17:50:18 -07:00
Anthony Stange
65945cfb15 Verify mPollThread is joinable before detaching
If HidlSetUp() bails before startPollingThread() is called (which can
happen if the HAL isn't implemented on the given device), mPollThread
will initialize with the default constructor resulting in joinable()
returning false which means calling detach() throws an exception.

Checking joinable() before detaching allows the test suite to be skipped
successfully.

Fixes: 136736906
Test: Run vts-tradefed on VtsHalSensorsV1_0Target and verify that it is
    skipped successfully on a device that doesn't support HAL 1.0

Change-Id: Ie685ae2dc314edb8df2f3cc7112141a2f5e46008
2019-07-15 19:17:25 +00:00
Felix
84af4f6e7e Merge "Add interface info to .rc files" am: 98d0f4d52c am: 37298a7616 am: 3531ec0183
am: bf481c99ed

Change-Id: Ie44e2aa87f7407a9820dc6f1ad6298b61bae34f3
2019-07-08 12:57:01 -07:00
Felix
bf481c99ed Merge "Add interface info to .rc files" am: 98d0f4d52c am: 37298a7616
am: 3531ec0183

Change-Id: I9a48f01064e6b64fdbd3dcae3623163a27998703
2019-07-08 12:42:48 -07:00
Felix
3531ec0183 Merge "Add interface info to .rc files" am: 98d0f4d52c
am: 37298a7616

Change-Id: Ib279bd04cbdf030104d077b9a2a836a348322476
2019-07-08 12:31:38 -07:00
Felix
37298a7616 Merge "Add interface info to .rc files"
am: 98d0f4d52c

Change-Id: Ie6cfbacd523c4b09f77bee3369ec8e88b3fa0419
2019-07-08 12:22:23 -07:00
Anthony Stange
2e89e4344b Merge "Deactivate sensors after flush events are received" into qt-dev am: 8913d1df2c am: 9ca9db61f8
am: 2ff09083af

Change-Id: I28bea9e6d7ab6083e6ee2f7d112b3eb2a6953027
2019-07-02 16:48:57 -07:00
Anthony Stange
80a247e090 Merge "Deactivate sensors after flush events are received" into qt-dev
am: 8913d1df2c

Change-Id: Ie32a5d1c5f1308060af6ae8c3b7d4c25ebdc9301
2019-07-02 15:14:45 -07:00
Anthony Stange
2ff09083af Merge "Deactivate sensors after flush events are received" into qt-dev am: 8913d1df2c
am: 9ca9db61f8

Change-Id: I4e3f088897dd557e92191bccb5b46288ecf40806
2019-07-02 15:14:18 -07:00
Anthony Stange
9ca9db61f8 Merge "Deactivate sensors after flush events are received" into qt-dev
am: 8913d1df2c

Change-Id: I74b279c6e4b26429c3868fac3e9ca9e0327af202
2019-07-02 14:44:12 -07:00
TreeHugger Robot
8913d1df2c Merge "Deactivate sensors after flush events are received" into qt-dev 2019-07-02 16:28:53 +00:00
Anthony Stange
4d90400985 Deactivate sensors after flush events are received
The VTS flush test case was previously deactivating sensors before
waiting for flush events to be received causing any pending flush events
to be discarded per the HAL contract.

Bug: 136472044
Test: Run test and ensure it passes
Change-Id: I23b94e650c6dbbc33640768bee356a49565ba753
2019-07-01 21:29:01 +00:00
Brian Duddie
1353468370 Avoid potential race condition in test setup
Resize the event queue before starting the polling thread to avoid
potential concurrent access.

Test: run VtsHalSensorsV2_0TargetTest
Change-Id: I71af46169e7731df4135639644665365b3714e1f
2019-07-01 18:07:03 +00:00
Felix
551b8d15ce Add interface info to .rc files
Signed-off-by: Felix <google@ix5.org>
Change-Id: I6d70bbdb66c3dce280bf6908c3750316a6f6cf70
2019-06-25 20:00:07 +02:00
Brian Duddie
b828e7bc48 Avoid NPD when re-initializing HAL fails
am: bd109b9374

Change-Id: Ibe5e262b89dc2f9645ee44bc084265164cd57827
2019-06-20 18:05:25 -07:00
Brian Duddie
62a0c5bae9 Fix NPD in GrallocWrapper
am: ccbcaaee45

Change-Id: Id9cc57ee5f9bfbabb64285671a23b6b9dbfc7b69
2019-06-20 18:05:22 -07:00
Brian Duddie
06ef2015ee Fix log tag for sensors VTS tests
am: 56d64faff7

Change-Id: I5e2c3e8aca8133fde1d26c0615b9245d54a76f43
2019-06-20 18:05:18 -07:00
Brian Duddie
bd109b9374 Avoid NPD when re-initializing HAL fails
If the sensors HAL crashes or errors out during a test where we manually
re-run the environment setup function (e.g.
CleanupConnectionsOnInitialize), the pointer to the interface will
become null. Avoid dereferencing it by checking for nullness in the
per-test setup function and after each manual setup call. Also add a
death recipient to help identify instances where the HAL crashes during
a test.

Bug: 135638664
Test: run VTS on device where HAL crashes during above mentioned test
Change-Id: Iff7aa159c6b859272cfd18e7efb3ca431ea214fc
2019-06-20 13:36:43 -07:00
Brian Duddie
ccbcaaee45 Fix NPD in GrallocWrapper
Avoid dereferencing null if mapper service is not available.

Bug: 135638664
Test: run VtsHalSensorsV2_0TargetTest
Change-Id: I3cf2a9f152d8f1737cb5a94356e252d54156c716
2019-06-20 13:36:43 -07:00
Brian Duddie
56d64faff7 Fix log tag for sensors VTS tests
Define log tag at build level to ensure all libraries have a tag
defined.

Bug: 135638664
Test: run VtsHalSensorsV2_0TargetTest
Change-Id: I593055b59238e9fa8dead00a3dafa84c00e90ec4
2019-06-20 13:36:43 -07:00
Brian Duddie
6834c2da4f Merge "Notify HAL when events are read" into qt-dev am: be19a50010
am: 2f0cedfad1

Change-Id: I5970e4b104e7d227ec50afe1207d5f392bebba65
2019-06-19 16:05:29 -07:00
Brian Duddie
45668158f5 Merge "Notify HAL when events are read" into qt-dev
am: be19a50010

Change-Id: I1339c37d0a28fd056afbc3f2ce1634bfbb60a955
2019-06-19 15:44:11 -07:00
Brian Duddie
441842e38e Notify HAL when events are read
As defined in the HAL specification, the client of the HAL (framework or
VTS) needs to set the EVENTS_READ flag when it fetches samples out of
the FMQ, to support blocking write mode.

Bug: 135442877
Test: run VTS on a device supporting HAL 2.0
Change-Id: Ic7755e869b999b638086275e4e579a84600be314
2019-06-19 02:14:51 +00:00