1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.car.hardware;
18 
19 import android.car.hardware.CarSensorConfig;
20 import android.car.hardware.CarSensorEvent;
21 import android.car.hardware.ICarSensorEventListener;
22 
23 /** @hide */
24 interface ICarSensor {
25 
getSupportedSensors()26     int[] getSupportedSensors() = 0;
27 
28     /**
29      * register a callback or update registration if already updated.
30      * @param sensorType sensor to listen with this callback.
31      * @param rate sensor rate.
32      * @return false if requested sensors cannot be subscribed / started.
33      */
registerOrUpdateSensorListener(int sensorType, int rate, in ICarSensorEventListener callback)34     boolean registerOrUpdateSensorListener(int sensorType, int rate,
35             in ICarSensorEventListener callback) = 1;
36 
37     /**
38      * get latest sensor event for the type. If there was no update after car connection, it will
39      * return null immediately.
40      */
getLatestSensorEvent(int sensorType)41     CarSensorEvent getLatestSensorEvent(int sensorType) = 2;
42 
43     /**
44      * Stop listening for the given sensor type. All other sensors registered before will not
45      * be affected.
46      */
unregisterSensorListener(int sensorType, in ICarSensorEventListener callback)47     void unregisterSensorListener(int sensorType, in ICarSensorEventListener callback) = 3;
48 
49     /**
50      * get config flags and config array for the sensor type
51      */
getSensorConfig(int sensorType)52     CarSensorConfig getSensorConfig(int sensorType) = 4;
53 }
54