Loading sensors/2.0/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ hidl_interface { srcs: [ "types.hal", "ISensors.hal", "ISensorsCallback.hal", ], interfaces: [ "android.hardware.sensors@1.0", Loading sensors/2.0/ISensors.hal +23 −12 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import @1.0::RateLevel; import @1.0::Result; import @1.0::SensorInfo; import @1.0::SharedMemInfo; import @2.0::ISensorsCallback; interface ISensors { /** Loading Loading @@ -59,8 +60,11 @@ interface ISensors { activate(int32_t sensorHandle, bool enabled) generates (Result result); /** * Initialize the Fast Message Queues (FMQ) that are used to send data * between the framework and the HAL. * Initialize the Sensors HAL's Fast Message Queues (FMQ) and callback. * * The Fast Message Queues (FMQ) that are used to send data between the * framework and the HAL. The callback is used by the HAL to notify the * framework of asynchronous events, such as a dynamic sensor connection. * * The Event FMQ is used to transport sensor events from the HAL to the * framework. The Event FMQ is created using the eventQueueDescriptor. Loading @@ -81,6 +85,9 @@ interface ISensors { * unprocessed WAKE_UP events and release its wake_lock if the current * count of unprocessed WAKE_UP events is zero. * * The ISensorsCallback is used by the HAL to notify the framework of * asynchronous events, such as a dynamic sensor connection. * * The name of any wake_lock acquired by the Sensors HAL for WAKE_UP events * must begin with "SensorsHAL_WAKEUP". * Loading @@ -90,14 +97,14 @@ interface ISensors { * released. * * If either the Event FMQ or the Wake Lock FMQ is already initialized when * initializeMessageQueues is invoked, then both existing FMQs must be * discarded and the new descriptors must be used to create new FMQs within * the HAL. The number of outstanding WAKE_UP events should also be reset to * zero, and any outstanding wake_locks held as a result of WAKE_UP events * should be released. * initialize is invoked, then both existing FMQs must be discarded and the * new descriptors must be used to create new FMQs within the HAL. The * number of outstanding WAKE_UP events should also be reset to zero, and * any outstanding wake_locks held as a result of WAKE_UP events should be * released. * * initializeMessageQueues must be thread safe and prevent concurrent calls * to initializeMessageQueues from simultaneously modifying state. * initialize must be thread safe and prevent concurrent calls * to initialize from simultaneously modifying state. * * @param eventQueueDescriptor Fast Message Queue descriptor that is used to * create the Event FMQ which is where sensor events are written. The Loading @@ -107,14 +114,18 @@ interface ISensors { * create the Wake Lock FMQ which is where wake_lock events are read * from. The descriptor is obtained from the framework's FMQ that is * used to write wake_lock events. * @param sensorsCallback sensors callback that receives asynchronous data * from the Sensors HAL. * @return result OK on success; BAD_VALUE if descriptor is invalid (such * as null) */ @entry @callflow(next = {"getSensorsList"}) initializeMessageQueues(fmq_sync<Event> eventQueueDescriptor, fmq_sync<uint32_t> wakeLockDescriptor) generates (Result result); initialize(fmq_sync<Event> eventQueueDescriptor, fmq_sync<uint32_t> wakeLockDescriptor, ISensorsCallback sensorsCallback) generates (Result result); /** * Sets a sensor’s parameters, including sampling frequency and maximum Loading sensors/2.0/ISensorsCallback.hal 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.sensors@2.0; import @1.0::SensorInfo; interface ISensorsCallback { /** * Notify the framework that new dynamic sensors have been connected. * * If a dynamic sensor was previously connected and has not been * disconnected, then that sensor must not be included in sensorInfos. * * @param sensorInfos vector of SensorInfo for each dynamic sensor that * was connected. */ oneway onDynamicSensorsConnected(vec<SensorInfo> sensorInfos); /** * Notify the framework that previously connected dynamic sensors have been * disconnected. * * If a dynamic sensor was previously disconnected and has not been * reconnected, then that sensor must not be included in sensorHandles. * * The HAL must ensure that all sensor events from departing dynamic * sensors have been written to the Event FMQ before calling * onDynamicSensorsDisconnected. * * @param sensorHandles vector of sensor handles for each dynamic sensors * that was disconnected. */ oneway onDynamicSensorsDisconnected(vec<int32_t> sensorHandles); }; Loading
sensors/2.0/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ hidl_interface { srcs: [ "types.hal", "ISensors.hal", "ISensorsCallback.hal", ], interfaces: [ "android.hardware.sensors@1.0", Loading
sensors/2.0/ISensors.hal +23 −12 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import @1.0::RateLevel; import @1.0::Result; import @1.0::SensorInfo; import @1.0::SharedMemInfo; import @2.0::ISensorsCallback; interface ISensors { /** Loading Loading @@ -59,8 +60,11 @@ interface ISensors { activate(int32_t sensorHandle, bool enabled) generates (Result result); /** * Initialize the Fast Message Queues (FMQ) that are used to send data * between the framework and the HAL. * Initialize the Sensors HAL's Fast Message Queues (FMQ) and callback. * * The Fast Message Queues (FMQ) that are used to send data between the * framework and the HAL. The callback is used by the HAL to notify the * framework of asynchronous events, such as a dynamic sensor connection. * * The Event FMQ is used to transport sensor events from the HAL to the * framework. The Event FMQ is created using the eventQueueDescriptor. Loading @@ -81,6 +85,9 @@ interface ISensors { * unprocessed WAKE_UP events and release its wake_lock if the current * count of unprocessed WAKE_UP events is zero. * * The ISensorsCallback is used by the HAL to notify the framework of * asynchronous events, such as a dynamic sensor connection. * * The name of any wake_lock acquired by the Sensors HAL for WAKE_UP events * must begin with "SensorsHAL_WAKEUP". * Loading @@ -90,14 +97,14 @@ interface ISensors { * released. * * If either the Event FMQ or the Wake Lock FMQ is already initialized when * initializeMessageQueues is invoked, then both existing FMQs must be * discarded and the new descriptors must be used to create new FMQs within * the HAL. The number of outstanding WAKE_UP events should also be reset to * zero, and any outstanding wake_locks held as a result of WAKE_UP events * should be released. * initialize is invoked, then both existing FMQs must be discarded and the * new descriptors must be used to create new FMQs within the HAL. The * number of outstanding WAKE_UP events should also be reset to zero, and * any outstanding wake_locks held as a result of WAKE_UP events should be * released. * * initializeMessageQueues must be thread safe and prevent concurrent calls * to initializeMessageQueues from simultaneously modifying state. * initialize must be thread safe and prevent concurrent calls * to initialize from simultaneously modifying state. * * @param eventQueueDescriptor Fast Message Queue descriptor that is used to * create the Event FMQ which is where sensor events are written. The Loading @@ -107,14 +114,18 @@ interface ISensors { * create the Wake Lock FMQ which is where wake_lock events are read * from. The descriptor is obtained from the framework's FMQ that is * used to write wake_lock events. * @param sensorsCallback sensors callback that receives asynchronous data * from the Sensors HAL. * @return result OK on success; BAD_VALUE if descriptor is invalid (such * as null) */ @entry @callflow(next = {"getSensorsList"}) initializeMessageQueues(fmq_sync<Event> eventQueueDescriptor, fmq_sync<uint32_t> wakeLockDescriptor) generates (Result result); initialize(fmq_sync<Event> eventQueueDescriptor, fmq_sync<uint32_t> wakeLockDescriptor, ISensorsCallback sensorsCallback) generates (Result result); /** * Sets a sensor’s parameters, including sampling frequency and maximum Loading
sensors/2.0/ISensorsCallback.hal 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.sensors@2.0; import @1.0::SensorInfo; interface ISensorsCallback { /** * Notify the framework that new dynamic sensors have been connected. * * If a dynamic sensor was previously connected and has not been * disconnected, then that sensor must not be included in sensorInfos. * * @param sensorInfos vector of SensorInfo for each dynamic sensor that * was connected. */ oneway onDynamicSensorsConnected(vec<SensorInfo> sensorInfos); /** * Notify the framework that previously connected dynamic sensors have been * disconnected. * * If a dynamic sensor was previously disconnected and has not been * reconnected, then that sensor must not be included in sensorHandles. * * The HAL must ensure that all sensor events from departing dynamic * sensors have been written to the Event FMQ before calling * onDynamicSensorsDisconnected. * * @param sensorHandles vector of sensor handles for each dynamic sensors * that was disconnected. */ oneway onDynamicSensorsDisconnected(vec<int32_t> sensorHandles); };