Commit graph

211 commits

Author SHA1 Message Date
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
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
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
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
Brian Duddie
ffe139e47c Merge "Add guidance for avoiding race in Sensors HAL 2.0" into qt-dev
am: 5c654f3fc6

Change-Id: I4720ca0dd2ec1c30b234fdf61aa6a3430ddd7a3e
2019-06-18 17:23:24 -07:00
Brian Duddie
a69036fbfe Add guidance for avoiding race in Sensors HAL 2.0
Bug: 135216821
Test: n/a, comment change only
Change-Id: Iad491c5e221c86a2724d4074ac645b8ee6e9af6f
2019-06-15 00:49:05 +00:00
Brian Duddie
0e70902d34 Fix null deref in sensors 2.0 VTS teardown
am: b6b28e58c4

Change-Id: I98288c2bea54fdbb7e733913ccba839817b7217a
2019-06-11 14:08:02 -07:00
Brian Duddie
b6b28e58c4 Fix null deref in sensors 2.0 VTS teardown
Avoid attempting to clean up resources that were never initialized, e.g.
if the target device doesn't support the version of the HAL in question.

Fixes: 134911861
Test: run VtsHalSensorsV2_0Target on device that only supports HAL v1.0
Change-Id: I6b529fae13b1347d533a19e04f1c7748bcda961b
2019-06-11 17:43:22 +00:00
Steven Moreland
99712c08cc Update hidl makefiles for bpfmt
hidl-generated makefiles are now generated such that bpfmt(file) == file.

Bug: 67417008
Test: enable bpfmt hook
Change-Id: I53e5bf67a0d314e1b10c0ba0c7172a7af358ddcc
2019-04-18 18:13:05 -07:00
Brian Stack
565cb9d2f0 Rename init script for Sensors 2.0 Mock Service
Bug: 129562840
Test: Builds
Change-Id: I4744a8e00657f39010d5e2a39fe38d13813e6439
2019-03-29 15:21:27 -07:00
Steven Moreland
b91ac5c6a0 Update makefies: no 'types' internal
Bug: 123976090
Test: N/A
Change-Id: I84b659b163b63d39535b462a3df8a9c19f680976
2019-03-04 14:09:25 -08:00
Steven Moreland
f8a47b7f01 Update makefiles.
Bug: 123976090
Test: N/A
Change-Id: I5fb6c126a090a3fe0fa4829ea9224564133dc1ae
2019-02-11 21:14:16 -08:00
Brian Stack
e42843f4ad Rename Sensors 2.0 Default Implementation
Rename the default implementation to include ".mock" to indicate that
the default implementation is a mock service and not intended to be
used on production devices.

Bug: 124020028
Test: Builds, cuttlefish loads sensors
Change-Id: I28c29f23615324cb2ae1dbe1767f18d40cf8d8e1
2019-02-07 10:42:28 -08:00
TreeHugger Robot
c9da65afbb Merge "Properly append META_DATA event on flush" 2019-01-30 18:27:16 +00:00
Brian Stack
e388f14db6 Use more realistic values for sensors
Bug: 123597515
Test: Builds, cuttlefish device health checks pass
Change-Id: Ifddf16761a218788ac7174e16b2d9f7ebb9685a9
2019-01-30 00:44:55 +00:00
Brian Stack
913334e036 Properly append META_DATA event on flush
Bug: 123597380
Test: atest VtsHalSensorsV2_0TargetTest:SensorsHidlTest#FlushSensor
Test: Framework properly receives and handles flush complete events
Change-Id: I09d2b52555c27602e1fd2ee2282f8ad700a1be18
2019-01-29 15:40:41 -08:00
Brian Stack
a2d16bbc44 Add missing sensors to Sensors 2.0
Bug: 123380869
Test: atest com.android.devicehealthchecks.SensorsBootCheck#checkSensors
      passes on Cuttlefish
Change-Id: I08a8406b3932469878da981add61f60b7774a377
2019-01-28 10:57:40 -08:00
Brian Stack
8972040239 Add VINTF Fragment to Sensors HAL 2.0
Bug: 122267378
Test: Built Cuttlefish, Sensors HAL 2.0 requested on boot
Change-Id: Ibe1eaa277852db1b8346caee172632f0951daefc
2019-01-23 22:35:38 +00:00
Brian Stack
1f56b51862 Verify stale requests are removed
Add tests to verify that sensor requests and direct connections are
invalidated after initialize is called on the Sensors HAL.

Bug: 120857563
Test: Builds, tests pass against default implementation
Change-Id: I690bc5168dfa9adb7b5e08fd6ddac49f68366846
2019-01-15 09:30:33 -08:00
TreeHugger Robot
bc91e1388c Merge "Stop Wake Lock thread if it is running" 2019-01-12 05:57:20 +00:00
TreeHugger Robot
0fffa374e3 Merge "Add WakeLockQueueFlagBits to Sensors 2.0" 2019-01-11 03:08:23 +00:00
Brian Stack
2c313368d8 Add WakeLockQueueFlagBits to Sensors 2.0
WakeLockQueueFlagBits is used to signal between the framework and the
HAL whenever events are available on the Wake Lock FMQ. The
introduction of this type allows for the HAL to utilize blocking calls
when reading the Wake Lock FMQ, if desired.

Also removes stale reference to WakeLockEvent.

Bug: 122528664
Test: Builds, verified Sensors 2.0 default implementation reads events
      when they become available on the Wake Lock FMQ

Change-Id: Ia83bd1642b8f6aa8ea86da05e83f4040c6e593bb
2019-01-10 16:41:06 -08:00
Brian Stack
d3849e1029 Stop Wake Lock thread if it is running
If the Wake Lock thread is running, stop it whenever initialize() is
called in order to prevent an invalid Wake Lock Queue from being read.

Also disable all sensors whenever initialize() is called to ensure
that stale sensor registrations are properly cleaned up.

Bug: 122468928
Test: Sensors HAL 2.0 tests run without crashing
Change-Id: I5fb55628545adbb481da6fcda157c78cff834134
2019-01-09 17:08:34 +00:00
Brian Stack
54a73b633e Initialize callback for Sensors HAL 2.0 VTS tests
Bug: 122468928
Test: Sensors HAL 2.0 tests successfully run
Change-Id: Ic34c47548ea45e9a49392e2fa94e2d787f3c6a0f
2019-01-07 12:59:51 -08:00
Brian Stack
6e4a22068f Update documentation for initialize()
Updates the documentation for the initialize() function and defines
the requirements for using the Event FMQ's writeBlocking function
which requires both a read and write notification.

Also adds requirement for the Sensors HAL to cleanup active sensor
requests and direct connections whenever initialize is called.

Bug: 120857563
Test: Builds
Change-Id: I11c8f7404d27e9ab21f9314523faebc1970b9f0c
2018-12-18 13:11:15 -08:00
TreeHugger Robot
fad169eb33 Merge "Add support for writeBlocking" 2018-12-07 17:18:28 +00:00
TreeHugger Robot
745badbe07 Merge "Implement Direct Channel Tests" 2018-11-15 06:31:15 +00:00
TreeHugger Robot
cca99ce47f Merge "Data Injection Tests for Sensors HAL 2.0" 2018-11-15 03:44:41 +00:00
Brian Stack
f2aca3b487 Acquire and Release Wake Lock
Acquire a wake lock in the Sensors 2.0 Default implementation whenever
there are outstanding WAKE_UP events. Release the wake lock whenever
the number of oustanding WAKE_UP events is zero or at least
SensorTimeout::WAKE_LOCK_SECONDS seconds have elapsed since the
previous WAKE_UP event was written to the Event FMQ.

Bug: 111070257
Test: Builds, wake lock is acquired and released as expected.
Change-Id: I7c57724430144fd4022646d1fef1b1fa8bc4235d
2018-11-14 16:04:44 -08:00
Brian Stack
56358cae58 Implement Direct Channel Tests
Implements Direct Channel tests for Sensors HAL 2.0. The tests verify
that the interface has been implemented correctly and that expected
values are returned. These tests are not intended to verify that the
rate at which sensor events are generated is correct.

Also, correctly return -1 as the channel handle if direct report is
not supported.

Bug: 115969174
Test: Tests pass against default implementation
Change-Id: I31b3211268701665757b03d5ee4ba2316f461282
2018-11-14 15:19:04 -08:00
Brian Stack
00c4288d66 Data Injection Tests for Sensors HAL 2.0
Implements VTS tests for Sensors HAL 2.0 DATA_INJECTION mode. Ensures
that if a sensor reports that it supports data injection, events that
are injected while in data injection mode are written back to the
Event FMQ. Ensures that AdditionalInfo events not written to the
Event FMQ.

Bug: 115969174
Test: Data injection tests pass against default Sensors HAL 2.0
Change-Id: I350956b759e14abfff73de4e20384524bbc00a0f
2018-11-14 15:18:50 -08:00
Brian Stack
d23f200603 Data Injection Support for Default Sensors HAL 2.0
Implements data injection support for the default Sensors HAL 2.0.
Allows events to be injected into the Sensors HAL and these events be
written back to the Event FMQ.

Bug: 111070257
Test: Passes data injection VTS tests
Change-Id: If652417ec0df4148ffb5be3d5dd8bc6f0be65467
2018-11-13 17:32:10 -08:00
Brian Stack
4e152dd8bd Add support for writeBlocking
Adds support for the Sensors HAL to use writeBlocking when sending
sensor events to the framework.

Bug: 111070257
Test: Builds, verified that if the default implementation is modified
      to use a writeBlocking call, the framework receives events, and
      the HAL blocks if the Event FMQ is full.
Change-Id: I62fc654513afe98901b1e65bdf422af276d22663
2018-11-09 10:29:03 -08:00
Brian Stack
9c1867eec8 Update member variables to use mNamingConvention
Bug: 115969174
Test: Builds
Change-Id: Id4334d9060a3110d13debcfaf1bebc9dddd321c5
2018-11-07 17:26:01 -08:00
Brian Stack
40525b145e Implement activate tests for Sensors HAL 2.0
Implements new VTS tests to verify that Sensors HAL 2.0 activate
function behaves as expected and returns the correct values.

Bug: 115969174
Test: Tests pass against default implementation
Change-Id: I3dbc86b0c9df3958f11bae4eff925d1869319738
2018-11-07 17:26:01 -08:00
Brian Stack
0a20036927 Implement batch test for Sensors 2.0
Verify that the batch function is correctly implemented for Sensors
HAL 2.0. This test ensures that the interface is properly implemented,
not that sensors generate events at the requested rate.

Bug: 115969174
Test: Builds, new test passes against default implementation
Change-Id: I607ff18f59d1ba73aa972ed46b04332892772355
2018-11-07 13:48:20 -08:00
Brian Stack
1fdd1bb4db Implement VTS tests for Sensors 2.0 flush
Bug: 115969174
Test: Tests pass against default implementation
Change-Id: Icb8c3d7776b8460d502bfec251ded061f978bec9
2018-11-07 13:36:11 -08:00
Brian Stack
9920e212f8 Only save newly received events during testing
All events in the temporary event buffer were being saved during
testing. This caused some events to be saved multiple times. This
patch ensures that only new events are saved.

Bug: 115969174
Test: Verified duplicate events are not received
Change-Id: Ia2c7df7273456700e0da2ddd927f7daf42e69334
2018-10-30 12:04:33 -07:00
Brian Stack
e4f74c77b1 Default flush implementation for Sensors 2.0
Bug: 111070257
Test: Builds, passes corresponding VTS tests
Change-Id: I5b46232ffb0dd2c85bccd9dad34dd04d29a5677d
2018-10-30 12:02:52 -07:00
TreeHugger Robot
4c1e30cebd Merge "Register default accelerometer sensor" 2018-10-27 02:02:19 +00:00
TreeHugger Robot
c7aa50238e Merge "Generate events for default Sensors 2.0" 2018-10-27 00:10:19 +00:00
TreeHugger Robot
cad117641a Merge "Add CallInitializeTwice Test" 2018-10-26 23:55:24 +00:00
Brian Stack
2927ab7ed7 Register default accelerometer sensor
Registers a default accelerometer with the Sensors HAL.

Bug: 111070257
Test: Builds, a_sns_test receives accel events
Change-Id: I2f016eb74b9b729854e771264f4c2f1adf025c09
2018-10-24 16:33:34 -07:00
Brian Stack
237abc6cf8 Generate events for default Sensors 2.0
Adds the ability for default Sensors 2.0 implementation to generate
sensor events.

Bug: 111070257
Test: Builds
Change-Id: I98f04dbac5370cc6fc3be43468ba43b6476b4515
2018-10-24 16:33:34 -07:00
Brian Stack
897528dd53 Implement activate and batch functions
Implements the activate and batch functions for the default Sensors
2.0 implementation.

Bug: 111070257
Test: Builds
Change-Id: I5987ab722cdd97c7cd7ff466d6d989794171b851
2018-10-24 16:33:26 -07:00
Brian Stack
9a407f23a6 Implement default functions for direct channel
Implements default functions for a Sensors 2.0 HAL that does not
support direct channel operation.

Although Sensors 2.0 supports direct channel operation, it is not a
requirement unless a device supports High Fidelity Sensors. A direct
channel implementation is vendor-specific, and therefore, the default
implementation does not provide a reference implementation.

A default implementation is able to be found in Sensors 1.0 since
direct channel operation has not changed between Sensors 1.0 and 2.0.

Bug: 111070257
Test: Builds
Change-Id: I1c4ef0cd9d4bd4b7ae3212358f9493c28c2798f4
2018-10-24 16:26:33 -07:00
Brian Stack
475d4d4d5e Default implementation for initialize()
Implements the default initialize() function for Sensors HAL 2.0

Bug: 111070257
Test: Builds
Change-Id: I1d1f0d732d931adaf12ae40167eea484887fb140
2018-10-24 16:26:27 -07:00
Brian Stack
60fcdcf635 Create Sensors HAL 2.0 Default Implementation
Auto-generated default implementation for Sensors HAL 2.0 via
hidl-gen and cleaned up formatting.

Modifies Android.bp for binderized HAL implementation which includes:
- Adding service.cpp
- Adding android.hardware.sensors@2.0-service.rc

android.hardware.sensors@2.0-service.rc was copied and updated from
the sensors@1.0 default implementation.

Bug: 111070257
Test: Builds
Change-Id: I6a939511ff6b4011cfe95bd26c3093ad18f26f5a
2018-10-24 16:15:59 -07:00
Brian Stack
1d329e633a Add CallInitializeTwice Test
Adds a test to Sensors 2.0 to ensure that if the initialize function
is called twice, then the FMQs used in the second call receive events.

Bug: 115969174
Test: New test passes (SensorsHidlTest#CallInitializeTwice)
Change-Id: I21a9307397eca1f2be93a826db89d24002e848c0
2018-10-19 15:18:28 -07:00
Brian Stack
85c8b31945 Initialize Sensors Test Environment
Properly initialize the test environment for Sensors HAL 2.0 by
constructing and reading from FMQs.

Bug: 115969174
Test: Builds, VTS tests run (some pass) against locally modified
      sensors HAL
Change-Id: Id959e50c18b643d2693c90bac15710ed6f34b1b4
2018-10-17 16:49:46 -07:00
Brian Stack
b6962f6e7d Copy Sensors VTS 1.0 into 2.0
Copy the VTS tests for Sensors 1.0 into the 2.0 directory to provide a
starting point for 2.0 tests. Updates references to 2.0 from 1.0 where
necessary.

Bug: 115969174
Test: Builds
Change-Id: Ia385552c208087175272627c65b9096cdb8f4afa
2018-10-15 15:19:03 -07:00
Brian Stack
7ff9564b20 Require consistent getSensorsList
Require that the values returned from getSensorsList do not change
before the entire system reboots. The values must be stable even
across Sensors HAL restarts. This allows for the framework to
automatically re-establish connections if the Sensors HAL crashes.

Bug: 111070257
Test: Compiles
Change-Id: I0e4b7d6ef8f89f6780c6a14d67465fd3692cd482
2018-10-02 21:29:53 +00:00
Brian Stack
78aa4fc9dd Define the ISensorsCallback
The ISensorsCallback will be used to push notifications into the
sensors framework, such as when dynamic sensors are connected.

Bug: 111070257
Test: Compiles
Change-Id: I681e6de341a80016983a3ab7fa45284ee9104918
2018-09-24 21:33:11 +00:00
Brian Stack
1f0c5ea652 Define EventQueueFlagBits
The EventQueueFlagBits is used to notify the other end of an FMQ when
an action should be taken. For instance, the read end of the queue is
able to wait on a particular mask bit to be set by the write end of
the queue before reading events.

This is necessary because the number of events to read must be
specified when calling the FMQ's read() or readBlocking() functions.
read() will fail if the specified number of events is not available.
readBlocking() will not perform a partial read, so if the number of
events to read is not known ahead of time, the function may block for
an extended period of time until enough events are queued up. By
utilizing the EventFlag, the reading of events is able to wait until
events are ready to be read, and then the availableToRead() function
provides the number of events to read when calling read() or
readBlocking().

Bug: 111070257
Test: Compiles
Change-Id: I20e9e566efc58196e27e50dae3fc13518ce605fc
2018-09-20 13:11:46 -07:00
Brian Stack
28c675fd86 Replace poll with initializeMessageQueues
Replaces poll with the new initializeMessageQueues call in
ISensors::2.0.

Bug: 111070257
Test: Build succeeds
Change-Id: I99f951fe5f1d93d267bee6734534993b1088baeb
2018-09-13 14:18:50 -07:00
Brian Stack
ee3f720115 Copy ISensors 1.0 into 2.0 directory
Copy the current version of the Sensors HAL into the 2.0 directory to
provide a starting point to replace the polling function. Update
version and headers. Import types from version 1.0 of Sensors HAL.

Bug: 111070257
Test: Build succeeds
Change-Id: Ibd00d83016dedc06e583579a0d76c7baa8fbcd05
2018-09-13 11:02:27 -07:00