blob: 09729d39e6e23cccbc9b18b2c4dc082bc4a71087 [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
Peng Xucefa91b2017-01-16 03:10:40 -080030
Andreas Huberdb49a412016-10-10 13:23:59 -070031struct Sensors : public ::android::hardware::sensors::V1_0::ISensors {
32 Sensors();
33
34 status_t initCheck() const;
35
Peng Xu0873e642017-01-08 13:28:10 -080036 Return<void> getSensorsList(getSensorsList_cb _hidl_cb) override;
Andreas Huberdb49a412016-10-10 13:23:59 -070037
38 Return<Result> setOperationMode(OperationMode mode) override;
39
40 Return<Result> activate(
41 int32_t sensor_handle, bool enabled) override;
42
Andreas Huberdb49a412016-10-10 13:23:59 -070043 Return<void> poll(int32_t maxCount, poll_cb _hidl_cb) override;
44
45 Return<Result> batch(
46 int32_t sensor_handle,
Andreas Huberdb49a412016-10-10 13:23:59 -070047 int64_t sampling_period_ns,
48 int64_t max_report_latency_ns) override;
49
50 Return<Result> flush(int32_t sensor_handle) override;
51
52 Return<Result> injectSensorData(const Event& event) override;
53
Peng Xu0f0df7e2017-01-05 23:39:08 -080054 Return<void> registerDirectChannel(
Peng Xu0873e642017-01-08 13:28:10 -080055 const SharedMemInfo& mem, registerDirectChannel_cb _hidl_cb) override;
Peng Xu0f0df7e2017-01-05 23:39:08 -080056
57 Return<Result> unregisterDirectChannel(int32_t channelHandle) override;
58
59 Return<void> configDirectReport(
60 int32_t sensorHandle, int32_t channelHandle, RateLevel rate,
61 configDirectReport_cb _hidl_cb) override;
62
Andreas Huberdb49a412016-10-10 13:23:59 -070063private:
Peng Xucefa91b2017-01-16 03:10:40 -080064 static constexpr int32_t kPollMaxBufferSize = 128;
Andreas Huberdb49a412016-10-10 13:23:59 -070065 status_t mInitCheck;
66 sensors_module_t *mSensorModule;
67 sensors_poll_device_1_t *mSensorDevice;
68
69 int getHalDeviceVersion() const;
70
71 static void convertFromSensorEvents(
72 size_t count, const sensors_event_t *src, hidl_vec<Event> *dst);
73
74 DISALLOW_COPY_AND_ASSIGN(Sensors);
75};
76
77extern "C" ISensors *HIDL_FETCH_ISensors(const char *name);
78
79} // namespace implementation
80} // namespace V1_0
81} // namespace sensors
82} // namespace hardware
83} // namespace android
84
85#endif // HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_