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