blob: 15645ebfb8cb8530c9c293c5b214ae0374cda549 [file] [log] [blame]
Michael Bestas3a0209e2023-05-04 01:15:47 +03001/*
2 * Copyright (c) 2017-2018-2018-2018, The Linux Foundation. All rights reserved.
3 * Not a Contribution
4 */
5/*
6 * Copyright (C) 2016 The Android Open Source Project
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
22#define ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
23
24#include <AGnss.h>
25#include <AGnssRil.h>
26#include <GnssBatching.h>
27#include <GnssConfiguration.h>
28#include <GnssGeofencing.h>
29#include <GnssMeasurement.h>
30#include <GnssNi.h>
31#include <GnssDebug.h>
32
33#include <android/hardware/gnss/1.1/IGnss.h>
34#include <hidl/MQDescriptor.h>
35#include <hidl/Status.h>
36
37#include <GnssAPIClient.h>
38#include <location_interface.h>
39
40namespace android {
41namespace hardware {
42namespace gnss {
43namespace V1_1 {
44namespace implementation {
45
46using ::android::hardware::hidl_array;
47using ::android::hardware::hidl_memory;
48using ::android::hardware::hidl_string;
49using ::android::hardware::hidl_vec;
50using ::android::hardware::Return;
51using ::android::hardware::Void;
52using ::android::sp;
53using ::android::hardware::gnss::V1_0::GnssLocation;
54
55struct Gnss : public IGnss {
56 Gnss();
57 ~Gnss();
58
59 /*
60 * Methods from ::android::hardware::gnss::V1_0::IGnss follow.
61 * These declarations were generated from Gnss.hal.
62 */
63 Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override;
64 Return<bool> start() override;
65 Return<bool> stop() override;
66 Return<void> cleanup() override;
67 Return<bool> injectLocation(double latitudeDegrees,
68 double longitudeDegrees,
69 float accuracyMeters) override;
70 Return<bool> injectTime(int64_t timeMs,
71 int64_t timeReferenceMs,
72 int32_t uncertaintyMs) override;
73 Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override;
74 Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
75 V1_0::IGnss::GnssPositionRecurrence recurrence,
76 uint32_t minIntervalMs,
77 uint32_t preferredAccuracyMeters,
78 uint32_t preferredTimeMs) override;
79 Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
80 Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
81 Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
82 Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
83 Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
84 Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
85
86 Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
87
88 inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
89 return nullptr;
90 }
91
92 inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override {
93 return nullptr;
94 }
95
96 Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
97
98 // Methods from ::android::hardware::gnss::V1_1::IGnss follow.
99 Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
100 Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
101 V1_0::IGnss::GnssPositionRecurrence recurrence,
102 uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
103 uint32_t preferredTimeMs, bool lowPowerMode) override;
104 Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
105 Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
106 Return<bool> injectBestLocation(const GnssLocation& location) override;
107
108 // These methods are not part of the IGnss base class.
109 GnssAPIClient* getApi();
110 Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
111 Return<bool> updateConfiguration(GnssConfig& gnssConfig);
112 const GnssInterface* getGnssInterface();
113
114 // Callback for ODCPI request
115 void odcpiRequestCb(const OdcpiRequestInfo& request);
116
117 private:
118 struct GnssDeathRecipient : hidl_death_recipient {
119 GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
120 }
121 ~GnssDeathRecipient() = default;
122 virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
123 sp<Gnss> mGnss;
124 };
125
126 private:
127 sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
128
129 sp<AGnss> mAGnssIface = nullptr;
130 sp<GnssNi> mGnssNi = nullptr;
131 sp<GnssMeasurement> mGnssMeasurement = nullptr;
132 sp<GnssConfiguration> mGnssConfig = nullptr;
133 sp<GnssGeofencing> mGnssGeofencingIface = nullptr;
134 sp<GnssBatching> mGnssBatching = nullptr;
135 sp<IGnssDebug> mGnssDebug = nullptr;
136 sp<AGnssRil> mGnssRil = nullptr;
137
138 GnssAPIClient* mApi = nullptr;
139 sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
140 sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
141 sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
142 GnssConfig mPendingConfig;
143 const GnssInterface* mGnssInterface = nullptr;
144};
145
146extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name);
147
148} // namespace implementation
149} // namespace V1_1
150} // namespace gnss
151} // namespace hardware
152} // namespace android
153
154#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSS_H