Commit graph

392 commits

Author SHA1 Message Date
Nick Desaulniers
6f4a232928 hardware: interfaces: sensors: fix -Wreorder-init-list
C++20 is stricter about member ordering in designated initializers than
C99.

Bug: 139945549
Test: mm
Change-Id: I22179dfb829c328462c9b31caf543692d3cf57d9
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-11-12 13:48:58 -08:00
TreeHugger Robot
7ac81273de Merge "[hardware][interfaces][sensors] fix -Wreorder-init-list again" 2019-11-05 22:14:27 +00:00
Stan Rokita
57ed4c98c3 Merge "Bound pending write events queue to avoid OOM" am: 6cbd36f357 am: 797b06e220
am: ac564f2899

Change-Id: I09b08508fd3cf53381d524613dad63621eb63595
2019-11-05 11:11:16 -08:00
Stan Rokita
ac564f2899 Merge "Bound pending write events queue to avoid OOM" am: 6cbd36f357
am: 797b06e220

Change-Id: Ie8121004cc113714e4a9ad6085a551f832fc847a
2019-11-05 01:35:34 -08:00
Stan Rokita
5098f0a9ca Bound pending write events queue to avoid OOM
Bound the pending write events queue to a large amount of events in
total (100,000) so that we do not have out of memory crashes when the
sensors framework locks up. Events are 80B of memory each. So this
change caps are pending writes event queue to 8MB of memory.

Bug: 143302327
Test: atest android.hardware.sensors@2.0-halproxy-unit-tests &&
vts-tradefed run commandAndExit vts --skip-all-system-status-check
--primary-abi-only --skip-preconditions --module VtsHalSensorsV2_0Target

Change-Id: I5d0a7f382e3f61fbbe2c74b5c9cf13560432b84c
2019-11-04 14:33:06 -08:00
Nick Desaulniers
65d03e4d8f [hardware][interfaces][sensors] fix -Wreorder-init-list again
C++20 will require members in a designated initializer to be in order
unlike C99.

This snuck in because I haven't upgraded the platform toolchain yet.

Bug: 139945549
Test: mm
Change-Id: Ica2844a213467e41d9b6a8955f1750692da8b444
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-11-04 12:55:30 -08:00
Stan Rokita
e210b0b012 Merge "Add Sensors Multihal support for Hal 2.0" am: 2f27f7137e am: 2d399b5af0
am: 4950a9dc21

Change-Id: I87376735901a4477d901ef87bcecc3b6146f12b4
2019-10-31 09:15:20 -07:00
Stan Rokita
4950a9dc21 Merge "Add Sensors Multihal support for Hal 2.0" am: 2f27f7137e
am: 2d399b5af0

Change-Id: Iad679b84b91e62c03d8466a98fdff11163317578
2019-10-31 09:09:04 -07:00
Treehugger Robot
2f27f7137e Merge "Add Sensors Multihal support for Hal 2.0" 2019-10-31 15:32:44 +00:00
Stan Rokita
94e44b5764 Revert sensors multihal 2.0 changes temporarily.
Revert the changes that added multihal support to sensors HAL 2.0 while
waiting for merge from the same changes added to AOSP.

07b442e96 (refs/published/mh2_2) MH2 | Write processedEvents instead of
original events.
b38f2e251 Merge "MH2 | Check that subhal index is in range"
d38f99474 Merge "MH2 | Implement debug method of HalProxy"
bf46132fe (refs/published/mh2_4, mh2_4) MH2 | Implement debug method of
HalProxy
1de5bb334 MH2 | Fix wakelock name
e07215347 (refs/published/mh2_3, mh2_3) MH2 | Check that subhal index is
in range
336c1c71e MH2 | Add restart logic in HalProxy::initialize method.
731d7125b MH2 | Change rc file to more appropriate settings
f09465d11 MH2 | Add makeFMQ helpers to HalProxy_test
75cc7bf2f MH2 | Implement wakelock processing thread
e93fdf9a4 MH2 | Implement dynamic sensors callbacks on HalProxy
82b84148c Remove libhwbinder/libhidltransport deps
d45e49b4b Merge "MH2 | Implement pending writes thread"
597142692 MH2 | Implement pending writes thread
db23aa825 MH2 | Implement direct channel and direct report methods
83e4370ae MH2 | Implement injectSensorData method of HalProxy
d0cd57d4c MH2 | Implement ScopeWakelock ctor and dtor
537c0274b MH2 | Add rough proxy callback postEvents method
f97a3f357 Multihal 2.0 - Small tweaks to sensorHandle handling
7a7235461 MultiHal 2.0 - setOperationMode and init direct channel flags
dc7a8e789 MultiHal 2.0 - Get sensors list from subhals
4b4c7b744 MultiHal 2.0 - activate, batch, flush methods of HalProxy
1638531df MultiHal 2.0 - proxying api calls helper methods
aacbf9485 Set up shell to use for unit tests
2879067dd Multihal 2.0 - Implement SubHal discovery
c34e6683b Add a sub-HAL implementation for testing multi-HAL
a689f8a65 Add skeleton for multihal 2.0

Bug: 136511617
Test: N/A
Change-Id: Ic3588f42cf60aee6ca915be19b834462aeb7a95c
2019-10-29 13:59:50 -07:00
Stan Rokita
2e37ec4475 Add Sensors Multihal support for Hal 2.0
The multihal framework is a HAL interface for the sensors framework that
allows multiple vendors to package their HAL implementation into a
subHAL dynamic library that will be loaded and used to pass on method
calls to the appropriate subHAL. The HalProxy object, that will act as
the main proxy sensors wrapper for the multiHAL handles writing sensor
events to the event FMQ and wakelock acquisition and releasing via a
callback object it passes to the subHALs.

In order to turn your HAL 2.0 executable into a subHAL to be used by the
multiHAL, implement the Return<Result> initialize(sp<HalProxyCallback>&
callback) method of the ISensorsSubHal derived class. Implement the
ISensorsSubHal* sensorsHalGetSubHal(uint32_t* version)method and have it
return a pointer to your subHAL object. Build this into a dynamic
library and list its filename under /vendor/etc/sensors/hals.conf.

Squashed commits:

07b442e96 (refs/published/mh2_2) MH2 | Write processedEvents instead of
original events.
b38f2e251 Merge "MH2 | Check that subhal index is in range"
d38f99474 Merge "MH2 | Implement debug method of HalProxy"
bf46132fe (refs/published/mh2_4, mh2_4) MH2 | Implement debug method of
HalProxy
1de5bb334 MH2 | Fix wakelock name
e07215347 (refs/published/mh2_3, mh2_3) MH2 | Check that subhal index is
in range
336c1c71e MH2 | Add restart logic in HalProxy::initialize method.
731d7125b MH2 | Change rc file to more appropriate settings
f09465d11 MH2 | Add makeFMQ helpers to HalProxy_test
75cc7bf2f MH2 | Implement wakelock processing thread
e93fdf9a4 MH2 | Implement dynamic sensors callbacks on HalProxy
82b84148c Remove libhwbinder/libhidltransport deps
d45e49b4b Merge "MH2 | Implement pending writes thread"
597142692 MH2 | Implement pending writes thread
db23aa825 MH2 | Implement direct channel and direct report methods
83e4370ae MH2 | Implement injectSensorData method of HalProxy
d0cd57d4c MH2 | Implement ScopeWakelock ctor and dtor
537c0274b MH2 | Add rough proxy callback postEvents method
f97a3f357 Multihal 2.0 - Small tweaks to sensorHandle handling
7a7235461 MultiHal 2.0 - setOperationMode and init direct channel flags
dc7a8e789 MultiHal 2.0 - Get sensors list from subhals
4b4c7b744 MultiHal 2.0 - activate, batch, flush methods of HalProxy
1638531df MultiHal 2.0 - proxying api calls helper methods
aacbf9485 Set up shell to use for unit tests
2879067dd Multihal 2.0 - Implement SubHal discovery
c34e6683b Add a sub-HAL implementation for testing multi-HAL
a689f8a65 Add skeleton for multihal 2.0

Bug: 136511617
Test: atest android.hardware.sensors@2.0-halproxy-unit-tests &&
vts-tradefed run commandAndExit vts --skip-all-system-status-check
--primary-abi-only --skip-preconditions --module VtsHalSensorsV2_0Target

Change-Id: Ibe92d40c92b70848526b0e941bbcffbaf81ffaf2
2019-10-29 11:08:38 -07:00
Stan Rokita
07b442e96c MH2 | Write processedEvents instead of original events.
Fix bug where the HalProxyCallback::postEvents method was passing the
unaltered events vector to HalProxy::postEventsToMessageQueue instead of
the processedEvents with altered sensorHandles. Add a unit test to test
that the proper sensorHandles are seen compared to the event posted from
subhal.

Additionally, fix problems with fake subhals and their dummy sensors
that allows VTS tests to pass all tests.

Bug: 136511617
Test: New unit tests pass and VTS tests under module
VtsHalSensorsV2_0Target passing.
Change-Id: If30da03a2399666700844523cd1104b07f6b65d2
2019-10-24 13:31:19 -07:00
TreeHugger Robot
b38f2e2513 Merge "MH2 | Check that subhal index is in range" 2019-10-21 20:06:21 +00:00
TreeHugger Robot
d38f994742 Merge "MH2 | Implement debug method of HalProxy" 2019-10-19 00:06:01 +00:00
Stan Rokita
bf46132fe5 MH2 | Implement debug method of HalProxy
Bug: 9569382
Test: Observed debug output from
$ adb shell lshal debug android.hardware.sensors@2.0::ISensors/default
Change-Id: I9f2627a05d37bd8407a22e263b7557834a9677b8
2019-10-18 14:50:36 -07:00
Stan Rokita
1de5bb334c MH2 | Fix wakelock name
Name is supposed to be "SensorsHAL_WAKEUP".

Bug: 142505817
Test: N/A
Change-Id: I79f01509bffba499678fa519d038db37e2a9efbd
2019-10-18 14:23:16 -07:00
Stan Rokita
e072153474 MH2 | Check that subhal index is in range
For each HalProxy method that takes in a sensorHandle, the code now
checks that the subhal index byte (first byte) of the handle is the
range of subhals in list before indexing into mSubHalList so that are
crash does not occur and returns Result::BAD_VALUE if that is the case.
Add unit tests to assert that error is returned. Also change the methods
that accept sensorHandles to int32_t type since that is the actual type
defined in the HAL spec.

Bug: 136511617
Test: Passing new unit tests.

Change-Id: I5489e999bc5eaef1a21698bdbc0a0341bc88194c
2019-10-18 12:12:47 -07:00
TreeHugger Robot
e53b23b6ad Merge "MH2 | Add restart logic in HalProxy::initialize method." 2019-10-17 23:42:24 +00:00
Stan Rokita
336c1c71e2 MH2 | Add restart logic in HalProxy::initialize method.
Bug: 136511617
Test: None yet

Change-Id: I389a7243d3612586aae4e8a802afda92af8dcc6d
2019-10-17 14:59:47 -07:00
Nick Desaulniers
0e2911ebe0 [hardware][interfaces][sensors] fix -Wreorder-init-list
C++20 will require members in a designated initializer to be in order
unlike C99.

Bug: 139945549
Test: mm
Change-Id: I78d64ea2b7df3f2bd3b8503aa553a0523b20d711
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-10-17 11:15:36 -07:00
Stan Rokita
731d7125bf MH2 | Change rc file to more appropriate settings
Bug: 136511617
Test: N/A
Change-Id: I23db5a299e5419156c3cb59fad9ea086ac2f393d
2019-10-16 09:39:50 -07:00
Stan Rokita
f09465d111 MH2 | Add makeFMQ helpers to HalProxy_test
Bug: 136511617
Test: Ran the tests with success.
Change-Id: Ide35e39529193696f3fb8d5898e9a3daf15b1630
2019-10-16 09:39:50 -07:00
Stan Rokita
75cc7bf2fe MH2 | Implement wakelock processing thread
Bug: 136511617
Test: Unit tests cannot be written for this change. Integration testing
will be performed later.

Change-Id: I651b5fde77c6017b3270413de896a947d95ff5f8
2019-10-16 09:39:47 -07:00
Stan Rokita
801ff068ff Merge "MH2 | Implement dynamic sensors callbacks on HalProxy" 2019-10-11 23:18:41 +00:00
Stan Rokita
e93fdf9a4a MH2 | Implement dynamic sensors callbacks on HalProxy
Additionally, have HalProxyCallback::processEvents use
HalProxy::setSubHalIndex static method instead of its own helper.
Add unit tests to test the dynamic sensor methods.

Bug: 136511617
Test: New unit tests are passing.
Change-Id: Ib903291a83df2fafa480082f9305c594bd325f79
2019-10-10 16:56:21 -07:00
Brian Duddie
e38c678515 Add sensors 1.0 default HAL to uhid group am: 82299438b5
am: f4a503a101

Change-Id: Ib04587185e36c4f7bc7820b2cd7c155b76443f7f
2019-10-08 13:07:04 -07:00
Brian Duddie
f4a503a101 Add sensors 1.0 default HAL to uhid group
am: 82299438b5

Change-Id: I4b9fbba3e85873763211b1bb36a2bf5d80fb39a1
2019-10-08 12:54:21 -07:00
Brian Duddie
82299438b5 Add sensors 1.0 default HAL to uhid group
Ensures it can access /dev/uinput in Android Q, sepolicy permitting.

Bug: 142105193
Test: confirm hall sensor works again on marlin
Change-Id: I585c32d4da4bdc0917068e4d81adeca43d257e56
2019-10-07 15:53:27 -07:00
Steven Moreland
82b84148c7 Remove libhwbinder/libhidltransport deps
Since these were combined into libhidlbase.

Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: I878a4d04e65ef13f3a0ebaf64177f673958d213c
2019-10-02 12:50:29 -07:00
Stan Rokita
d45e49b4b3 Merge "MH2 | Implement pending writes thread" 2019-09-26 15:15:19 +00:00
Stan Rokita
5971426925 MH2 | Implement pending writes thread
Spin up a background thread inside the hal proxy that is responsible for
writing events to the event fmq if a previous write failed on the normal
postEvents thread. Create several new unit tests that help test the new
functionality.

Bug: 136511617
Test: Unit tests passing.
Change-Id: Ic35c9736fc0402297ab50072c195f66c9feb887d
2019-09-25 16:40:53 -07:00
Stan Rokita
db23aa825b MH2 | Implement direct channel and direct report methods
Implement registerDirectChannel, unregisterDirectChannel, and
configDirectReport methods of HalProxy.

Bug: 136511617
Test: Compiles successfully. Simple enough change to ignore unit tests
for now.

Change-Id: I7e1e6a4da6ba2fc070836084210c83bd9b53aabe
2019-09-24 14:46:49 -07:00
Stan Rokita
83e4370aec MH2 | Implement injectSensorData method of HalProxy
Bug: 136511617
Test: Compiles. No unit tests needed right now for such simple change.
Change-Id: Iaaf74579c26393ef8854ae717f01bb7a451de496
2019-09-24 10:44:53 -07:00
Stan Rokita
d0cd57d4cb MH2 | Implement ScopeWakelock ctor and dtor
Put the ScopedWakelock class into its own header and its implementation
into its own cpp. Implement the refcounting of the wakelocks. However,
do not incorporate the wakelock handling into post events in halproxy
yet.

Bug: 136511617
Test: No new tests yet. Will add more in a later patchset once more
fleshed out and integrated with postEvents.
Change-Id: I0815c6a6659ec5933b799294956595b11e7bf1b3
2019-09-23 08:55:28 -07:00
Stan Rokita
537c0274b8 MH2 | Add rough proxy callback postEvents method
Add post events method to HalProxyCallback without fully implementing
the wakeup events handling and pending blocking writes. Also change
mSensorList of the halProxy to mSensors which is a map from sensorHandle
to sensorInfo so that getNumWakeupEvents method of callback can find
sensorinfo info from sensorhandle of event type. Instantiate
halproxycallback vector in HalProxy for each subhal in the ctor as well.
Add very simple test for the postEvents method of callback.

Bug: 136511617
Test: New unit test passes.
Change-Id: I39c861cff286f24992bfcfcaa6bb468b4544b0e0
2019-09-23 08:55:17 -07:00
Stan Rokita
f97a3f3579 Multihal 2.0 - Small tweaks to sensorHandle handling
Add the sensor handle to subhal index bitmask as a constant. Change the
name of zeroOutFirstByte method to clearSubHalIndex and use the constant
there. Also use the constant in initSensorsList method.

Bug: 136511617
Test: Tested compilation success.
Change-Id: I3983850827697ff77c484e7b8d33e7722a7fb52a
2019-09-13 10:04:44 -07:00
Stan Rokita
7a7235461f MultiHal 2.0 - setOperationMode and init direct channel flags
Implement setOperationMode method of HalProxy object and initialized the
direct channel flag for the sensors list. Also create some unit tests to
test both of these new additions in HalProxy_test.cpp.

Bug: 136511617
Test: Tested using unit tests and tested on device with both fake
      subhals

Change-Id: I4e39ca0e94b3e109706d628612d1db9c98aca053
2019-09-12 15:05:53 -07:00
Stan Rokita
dc7a8e7898 MultiHal 2.0 - Get sensors list from subhals
Implement SubHal constructors. The default ctor will get the SubHal
object pointers from dynamic libraries. The test ctor will take a vector
of SubHal objects. Implment the HalProxy getSensorsList method which
will return all the sensors from the subhal objects. Create one unit
test for getSensorsList as well.

Bug: 136511617
Test: Flashed onto device and observed proper logs for both test
subhals. Also, passed getSensorsList test.

Change-Id: I6e8ca4883c50daabbd7b0955d3664f66b6cd74bf
2019-09-12 14:23:41 -07:00
Stan Rokita
4b4c7b744d MultiHal 2.0 - activate, batch, flush methods of HalProxy
These three methods of HalProxy simply call the apropriate ISensors
methods of the subhal pointed to by sensorHandle.

Test: Loaded onto device and observed no crashing.
Bug: 136511617
Change-Id: If90652554ea18c22b24aead0074ab9847eae0a4f
2019-09-11 07:43:22 -07:00
Stan Rokita
1638531dfb MultiHal 2.0 - proxying api calls helper methods
Create getSubHalForSensorHandle method which will get the proper subhal
pointer by getting the subhal list index from the first byte of the
sensor handle. Create the zeroOutFirstByte static helper method that
will return a version of the sensor handle without the first byte when
passed a handle.

Test: Tested compilation.
Bug: 136511617
Change-Id: I7d07003e1903aa1d8abaf904b778248c7b352653
2019-09-11 07:43:20 -07:00
Xin Li
15be13ea71 Merge qt-r1-dev-plus-aosp-without-vendor (5817612) into stage-aosp-master
Bug: 135460123
Change-Id: Ia07db5c8afeed7fe22a2b18d867a38390f910a81
Merged-In: Ibbd540dbb5baee46360d3fe9469212cfd8f550ba
2019-09-08 13:06:54 -07:00
Steven Moreland
38c46d0b98 Merge "Remove libhwbinder/libhidltransport deps" am: 6b62c58a9a am: 8c22c3862f am: 6684ee8c36
am: 9a5ffa3196

Change-Id: I3a80895d10767fe68e90a907312a83ded976cbcc
2019-09-06 16:06:13 -07:00
Steven Moreland
6684ee8c36 Merge "Remove libhwbinder/libhidltransport deps" am: 6b62c58a9a
am: 8c22c3862f

Change-Id: Iaedfceb49f81387f7deaad434613b7c9f1c502a0
2019-09-06 14:28:04 -07:00
Steven Moreland
b3a4d3832e Remove libhwbinder/libhidltransport deps
Since these were combined into libhidlbase.

Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: I075670b64eebbbbd6a6ae0e84ad51bf1c6f5ba36
2019-09-06 01:07:02 +00:00
Anthony Stange
aacbf94854 Set up shell to use for unit tests
Sets up a unit test file that can be used to unit test the HalProxy. The
unit tests will eventually end up containing code that injects the fake
SensorsSubHal implementation into the HalProxy and verifies various
parts of the implementation. This will likely require some modifications
to the SensorsSubHal class to modify it during test execution, but it's
better that the same implementation is shared between unit / manual
integration testing.

Test: Run atest android.hardware.sensors@2.0-halproxy-unit-tests
Bug: 136511617
Change-Id: I7b6865564ea41ab3c58f77d3168366c95e3289e5
2019-09-03 11:22:38 -04:00
Stan Rokita
2879067ddb Multihal 2.0 - Implement SubHal discovery
Collect the SubHal pointers discovered from dynamic libs contained
within the multi hal config file.

Bug: 136511617
Test: Compiled with mma -j and observed loading of modules

Change-Id: I148265722e70d4cd56671af9c6f1ff6dde355ae4
2019-08-23 11:16:58 -07:00
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