blob: abe7f43bfe4bc3c6acc43e0bc7a5ff70fa131188 [file] [log] [blame]
Andreas Huberdb49a412016-10-10 13:23:59 -07001/*
2 * Copyright (C) 2016 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#ifndef HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_
18
19#define HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_
20
21#include <android/hardware/sensors/1.0/ISensors.h>
22#include <hardware/sensors.h>
23
24namespace android {
25namespace hardware {
26namespace sensors {
27namespace V1_0 {
28namespace implementation {
29
30struct Sensors : public ::android::hardware::sensors::V1_0::ISensors {
31 Sensors();
32
33 status_t initCheck() const;
34
35 Return<void> getSensorsList(getSensorsList_cb _aidl_cb) override;
36
37 Return<Result> setOperationMode(OperationMode mode) override;
38
39 Return<Result> activate(
40 int32_t sensor_handle, bool enabled) override;
41
42 Return<Result> setDelay(
43 int32_t sensor_handle, int64_t sampling_period_ns) override;
44
45 Return<void> poll(int32_t maxCount, poll_cb _hidl_cb) override;
46
47 Return<Result> batch(
48 int32_t sensor_handle,
49 int32_t flags,
50 int64_t sampling_period_ns,
51 int64_t max_report_latency_ns) override;
52
53 Return<Result> flush(int32_t sensor_handle) override;
54
55 Return<Result> injectSensorData(const Event& event) override;
56
Peng Xu0f0df7e2017-01-05 23:39:08 -080057 Return<void> registerDirectChannel(
58 const SharedMemInfo& mem, registerDirectChannel_cb _aidl_cb) override;
59
60 Return<Result> unregisterDirectChannel(int32_t channelHandle) override;
61
62 Return<void> configDirectReport(
63 int32_t sensorHandle, int32_t channelHandle, RateLevel rate,
64 configDirectReport_cb _hidl_cb) override;
65
Andreas Huberdb49a412016-10-10 13:23:59 -070066private:
67 status_t mInitCheck;
68 sensors_module_t *mSensorModule;
69 sensors_poll_device_1_t *mSensorDevice;
70
71 int getHalDeviceVersion() const;
72
73 static void convertFromSensorEvents(
74 size_t count, const sensors_event_t *src, hidl_vec<Event> *dst);
75
76 DISALLOW_COPY_AND_ASSIGN(Sensors);
77};
78
79extern "C" ISensors *HIDL_FETCH_ISensors(const char *name);
80
81} // namespace implementation
82} // namespace V1_0
83} // namespace sensors
84} // namespace hardware
85} // namespace android
86
87#endif // HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_