blob: a8d2c6110c50ffcfe26b5ee2c501845e5b01cbc1 [file] [log] [blame]
This folder contains example code for writing native apps that use Brillo
sensors. The sensors HAL implementation must exist on the device for the apps
in this folder to run successfully.
Example files:
hal-example-app.cpp:
An example app that uses the sensors HAL (defined in
hardware/libhardware/include/sensors.h) directly. In the app, the list of
sensors found on the device is printed. And if an accelerometer exists, the
app will read the data and print it out.
ndk-example-app.cpp:
An example app that uses the NDK sensors interface. In the app, the list of
sensors found on the device is printed. And then the app tries to read data
from accelerometer, proximity sensor, and significant motion sensor, which
has continuous, on-change, and one-shot reporting modes respectively.
sensors_hal.cpp
An example implementation of a sensors HAL. It implements a fake
accelerometer and custom sensor (defined in example_sensors.{h|cpp}). The
accelerometer always returns random data. The custom sensor returns the hour
for the local time.
To use this HAL implementation, push the binary file sensors.example into
/system/lib/hw/ folder and rename it to sensors.default (make sure there is
no other sensors.* file under that folder).