1 /* 2 * Copyright (c) 2017-2020, 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_V2_1_GNSS_H 22 #define ANDROID_HARDWARE_GNSS_V2_1_GNSS_H 23 24 #include <AGnss.h> 25 #include <AGnssRil.h> 26 #include <GnssConfiguration.h> 27 #include <GnssMeasurement.h> 28 #include <GnssBatching.h> 29 #include <GnssGeofencing.h> 30 #include <GnssNi.h> 31 #include <GnssDebug.h> 32 #include <GnssAntennaInfo.h> 33 34 #include <android/hardware/gnss/2.1/IGnss.h> 35 #include <android/hardware/gnss/measurement_corrections/1.1/IMeasurementCorrections.h> 36 #include <MeasurementCorrections.h> 37 #include <GnssVisibilityControl.h> 38 #include <hidl/MQDescriptor.h> 39 #include <hidl/Status.h> 40 41 #include "GnssAPIClient.h" 42 43 namespace android { 44 namespace hardware { 45 namespace gnss { 46 namespace V2_1 { 47 namespace implementation { 48 49 using ::android::hardware::hidl_array; 50 using ::android::hardware::hidl_memory; 51 using ::android::hardware::hidl_string; 52 using ::android::hardware::hidl_vec; 53 using ::android::hardware::Return; 54 using ::android::hardware::Void; 55 using ::android::sp; 56 using ::android::hardware::gnss::V1_0::GnssLocation; 57 using IMeasurementCorrectionsV1_0 = 58 ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections; 59 using IMeasurementCorrectionsV1_1 = 60 ::android::hardware::gnss::measurement_corrections::V1_1::IMeasurementCorrections; 61 using ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl; 62 63 struct Gnss : public IGnss { 64 Gnss(); 65 ~Gnss(); 66 67 68 /* 69 * Methods from ::android::hardware::gnss::V1_0::IGnss follow. 70 * These declarations were generated from Gnss.hal. 71 */ 72 Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override; 73 Return<bool> start() override; 74 Return<bool> stop() override; 75 Return<void> cleanup() override; 76 Return<bool> injectLocation(double latitudeDegrees, 77 double longitudeDegrees, 78 float accuracyMeters) override; 79 Return<bool> injectTime(int64_t timeMs, 80 int64_t timeReferenceMs, 81 int32_t uncertaintyMs) override; 82 Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override; 83 Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode, 84 V1_0::IGnss::GnssPositionRecurrence recurrence, 85 uint32_t minIntervalMs, 86 uint32_t preferredAccuracyMeters, 87 uint32_t preferredTimeMs) override; 88 Return<sp<V1_0::IAGnss>> getExtensionAGnss() override; 89 Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override; 90 Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override; 91 Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override; 92 Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override; 93 Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override; 94 95 Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override; 96 getExtensionGnssNavigationMessageGnss97 inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override { 98 return nullptr; 99 } 100 getExtensionXtraGnss101 inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override { 102 return nullptr; 103 } 104 105 Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override; 106 107 // Methods from ::android::hardware::gnss::V1_1::IGnss follow. 108 Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override; 109 Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode, 110 V1_0::IGnss::GnssPositionRecurrence recurrence, 111 uint32_t minIntervalMs, uint32_t preferredAccuracyMeters, 112 uint32_t preferredTimeMs, bool lowPowerMode) override; 113 Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override; 114 Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override; 115 Return<bool> injectBestLocation(const GnssLocation& location) override; 116 117 // Methods from ::android::hardware::gnss::V2_0::IGnss follow. 118 Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override; 119 Return<sp<V2_0::IAGnss>> getExtensionAGnss_2_0() override; 120 Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override; 121 122 Return<sp<V2_0::IGnssConfiguration>> getExtensionGnssConfiguration_2_0() override; 123 Return<sp<IMeasurementCorrectionsV1_0>> getExtensionMeasurementCorrections() override; 124 Return<sp<IMeasurementCorrectionsV1_1>> getExtensionMeasurementCorrections_1_1() override; 125 Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override; 126 127 Return<bool> injectBestLocation_2_0( 128 const ::android::hardware::gnss::V2_0::GnssLocation& location) override; 129 130 Return<sp<V2_0::IGnssBatching>> getExtensionGnssBatching_2_0() override; 131 Return<sp<V2_0::IGnssDebug>> getExtensionGnssDebug_2_0() override; 132 Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>> 133 getExtensionVisibilityControl() override; 134 135 // Methods from ::android::hardware::gnss::V2_1::IGnss follow. 136 Return<bool> setCallback_2_1(const sp<V2_1::IGnssCallback>& callback) override; 137 Return<sp<V2_1::IGnssMeasurement>> getExtensionGnssMeasurement_2_1() override; 138 Return<sp<V2_1::IGnssConfiguration>> getExtensionGnssConfiguration_2_1() override; 139 Return<sp<V2_1::IGnssAntennaInfo>> getExtensionGnssAntennaInfo() override; 140 141 // These methods are not part of the IGnss base class. 142 GnssAPIClient* getApi(); 143 Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb); 144 Return<bool> updateConfiguration(GnssConfig& gnssConfig); 145 const GnssInterface* getGnssInterface(); 146 147 // Callback for ODCPI request 148 void odcpiRequestCb(const OdcpiRequestInfo& request); 149 150 private: 151 struct GnssDeathRecipient : hidl_death_recipient { GnssDeathRecipientGnss::GnssDeathRecipient152 GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) { 153 } 154 ~GnssDeathRecipient() = default; 155 virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override; 156 sp<Gnss> mGnss; 157 }; 158 159 private: 160 sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr; 161 162 sp<V1_0::IGnssNi> mGnssNi = nullptr; 163 sp<V1_0::IGnssGeofencing> mGnssGeofencingIface = nullptr; 164 sp<V1_0::IAGnss> mAGnssIface = nullptr; 165 sp<V1_0::IGnssCallback> mGnssCbIface = nullptr; 166 sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr; 167 sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr; 168 sp<V2_0::IAGnss> mAGnssIface_2_0 = nullptr; 169 sp<V2_0::IAGnssRil> mGnssRil = nullptr; 170 sp<V2_0::IGnssBatching> mGnssBatching = nullptr; 171 sp<V2_0::IGnssDebug> mGnssDebug = nullptr; 172 sp<V2_0::IGnssCallback> mGnssCbIface_2_0 = nullptr; 173 sp<V2_1::IGnssCallback> mGnssCbIface_2_1 = nullptr; 174 sp<V2_1::IGnssMeasurement> mGnssMeasurement = nullptr; 175 sp<V2_1::IGnssConfiguration> mGnssConfig = nullptr; 176 sp<V2_1::IGnssAntennaInfo> mGnssAntennaInfo = nullptr; 177 sp<IMeasurementCorrectionsV1_1> mGnssMeasCorr = nullptr; 178 sp<IGnssVisibilityControl> mVisibCtrl = nullptr; 179 180 GnssAPIClient* mApi = nullptr; 181 GnssConfig mPendingConfig; 182 const GnssInterface* mGnssInterface = nullptr; 183 }; 184 185 extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name); 186 187 } // namespace implementation 188 } // namespace V2_1 189 } // namespace gnss 190 } // namespace hardware 191 } // namespace android 192 193 #endif // ANDROID_HARDWARE_GNSS_V2_1_GNSS_H 194