blob: 9ff14350b7d7acd497c42394f6828ae8d05fb825 [file] [log] [blame]
Hridya Valsaraju29dc1e02016-10-21 14:41:12 -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 android_hardware_gnss_V1_0_GnssMeasurement_H_
18#define android_hardware_gnss_V1_0_GnssMeasurement_H_
19
20#include <ThreadCreationWrapper.h>
21#include <android/hardware/gnss/1.0/IGnssMeasurement.h>
22#include <hidl/Status.h>
23#include <hardware/gps.h>
24
25namespace android {
26namespace hardware {
27namespace gnss {
28namespace V1_0 {
29namespace implementation {
30
31using ::android::hardware::gnss::V1_0::IGnssMeasurement;
32using ::android::hardware::gnss::V1_0::IGnssMeasurementCallback;
33using ::android::hardware::Return;
34using ::android::hardware::Void;
35using ::android::hardware::hidl_vec;
36using ::android::hardware::hidl_string;
37using ::android::sp;
38
39using LegacyGnssData = ::GnssData;
40
41/*
42 * Extended interface for GNSS Measurements support. Also contains wrapper methods to allow methods
43 * from IGnssMeasurementCallback interface to be passed into the conventional implementation of the
44 * GNSS HAL.
45 */
46struct GnssMeasurement : public IGnssMeasurement {
47 GnssMeasurement(const GpsMeasurementInterface* gpsMeasurementIface);
48
49 /*
50 * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
51 * These declarations were generated from IGnssMeasurement.hal.
52 */
53 Return<GnssMeasurementStatus> setCallback(
54 const sp<IGnssMeasurementCallback>& callback) override;
55 Return<void> close() override;
56
57 /*
58 * Callback methods to be passed into the conventional GNSS HAL by the default
59 * implementation. These methods are not part of the IGnssMeasurement base class.
60 */
61 static void gnssMeasurementCb(LegacyGnssData* data);
62 /*
63 * Deprecated callback added for backward compatibity for devices that do
64 * not support GnssData measurements.
65 */
66 static void gpsMeasurementCb(GpsData* data);
67
68 /*
69 * Holds function pointers to the callback methods.
70 */
71 static GpsMeasurementCallbacks sGnssMeasurementCbs;
72
73 private:
74 const GpsMeasurementInterface* mGnssMeasureIface = nullptr;
75 static sp<IGnssMeasurementCallback> sGnssMeasureCbIface;
76};
77
78} // namespace implementation
79} // namespace V1_0
80} // namespace gnss
81} // namespace hardware
82} // namespace android
83
84#endif // android_hardware_gnss_V1_0_GnssMeasurement_H_