Commit graph

402 commits

Author SHA1 Message Date
Stan Rokita
655675db00 Make ScopedWakelock a shared library am: 1d53f9563b am: 1e9bac4b58
am: b0af4f5a25

Change-Id: I641b4d611e8b9637f07fda2592d3d078dc82a677
2019-11-25 14:37:40 -08:00
Stan Rokita
b0af4f5a25 Make ScopedWakelock a shared library am: 1d53f9563b
am: 1e9bac4b58

Change-Id: I68ece185c348668aa5da86e6b3802f5db167af0d
2019-11-25 14:34:48 -08:00
Stan Rokita
1d53f9563b Make ScopedWakelock a shared library
Change the build configuration of multihal and its tests to make the
ScopedWakelock.cpp file and its associated headers available as a
library to be included by the fake subhals and the multihal binary
seperately.

Bug: 144722764
Test: Compiled and loaded onto device without issue
Change-Id: Ide83b6761302c5df6c72bc3202727341361b36ed
2019-11-25 12:36:10 -08:00
Stan Rokita
dda3a5c7c4 Merge "Change instance name to default in multihal 2 xml" am: 724b7471e0 am: c3f2745aae
am: eba6d2429a

Change-Id: Ifbbabaee01f39c79f395408c2d29764541ce8e46
2019-11-19 08:30:03 -08:00
Stan Rokita
eba6d2429a Merge "Change instance name to default in multihal 2 xml" am: 724b7471e0
am: c3f2745aae

Change-Id: I2553def9c40ab1494be28b2659685f86a3601ceb
2019-11-19 08:25:58 -08:00
Treehugger Robot
724b7471e0 Merge "Change instance name to default in multihal 2 xml" 2019-11-19 16:15:08 +00:00
Stan Rokita
a1ed22e34f Change instance name to default in multihal 2 xml
Bug: 144722764
Test: N/A
Change-Id: Ic6b4a4f5ccb8df11ac8ed819fd750841373bc11f
2019-11-18 15:09:00 -08:00
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
Nick Desaulniers
69871db874 Merge changes I8a7ff4b0,Id121ecd4,I23375d73 am: 944e640e16
am: d770f4c628

Change-Id: Ie2a0a0dad8d32f7eb2a07784bd0f60bf666b61a1
2019-11-06 09:58:31 -08:00
Nick Desaulniers
8cb3c9b326 [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
Merged-In: I78d64ea2b7df3f2bd3b8503aa553a0523b20d711
Change-Id: I8a7ff4b025ac693398b79ad5f16687afe3a4c5a9
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-11-05 14:58:13 -08:00
Nick Desaulniers
890faa2ac5 [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: Id121ecd46b7e53f5dd7b4a32daae0594d851d0e5
Merged-in: Ica2844a213467e41d9b6a8955f1750692da8b444
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-11-05 14:55:47 -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