Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78aa4fc9 authored by Brian Stack's avatar Brian Stack Committed by Brian Duddie
Browse files

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
parent 0bf3fb49
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ hidl_interface {
    srcs: [
        "types.hal",
        "ISensors.hal",
        "ISensorsCallback.hal",
    ],
    interfaces: [
        "android.hardware.sensors@1.0",
+23 −12
Original line number Diff line number Diff line
@@ -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 {
    /**
@@ -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.
@@ -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".
     *
@@ -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
@@ -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
+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);
};