blob: e8bd98dcfe792640427dee024eb4e861d8a7f1f2 [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
Peng Xu0873e642017-01-08 13:28:10 -080035 Return<void> getSensorsList(getSensorsList_cb _hidl_cb) override;
Andreas Huberdb49a412016-10-10 13:23:59 -070036
37 Return<Result> setOperationMode(OperationMode mode) override;
38
39 Return<Result> activate(
40 int32_t sensor_handle, bool enabled) override;
41
Andreas Huberdb49a412016-10-10 13:23:59 -070042 Return<void> poll(int32_t maxCount, poll_cb _hidl_cb) override;
43
44 Return<Result> batch(
45 int32_t sensor_handle,
Andreas Huberdb49a412016-10-10 13:23:59 -070046 int64_t sampling_period_ns,
47 int64_t max_report_latency_ns) override;
48
49 Return<Result> flush(int32_t sensor_handle) override;
50
51 Return<Result> injectSensorData(const Event& event) override;
52
Peng Xu0f0df7e2017-01-05 23:39:08 -080053 Return<void> registerDirectChannel(
Peng Xu0873e642017-01-08 13:28:10 -080054 const SharedMemInfo& mem, registerDirectChannel_cb _hidl_cb) override;
Peng Xu0f0df7e2017-01-05 23:39:08 -080055
56 Return<Result> unregisterDirectChannel(int32_t channelHandle) override;
57
58 Return<void> configDirectReport(
59 int32_t sensorHandle, int32_t channelHandle, RateLevel rate,
60 configDirectReport_cb _hidl_cb) override;
61
Andreas Huberdb49a412016-10-10 13:23:59 -070062private:
63 status_t mInitCheck;
64 sensors_module_t *mSensorModule;
65 sensors_poll_device_1_t *mSensorDevice;
66
67 int getHalDeviceVersion() const;
68
69 static void convertFromSensorEvents(
70 size_t count, const sensors_event_t *src, hidl_vec<Event> *dst);
71
72 DISALLOW_COPY_AND_ASSIGN(Sensors);
73};
74
75extern "C" ISensors *HIDL_FETCH_ISensors(const char *name);
76
77} // namespace implementation
78} // namespace V1_0
79} // namespace sensors
80} // namespace hardware
81} // namespace android
82
83#endif // HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_