1 /* 2 * Copyright (c) 2017-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_0_GNSS_H 22 #define ANDROID_HARDWARE_GNSS_V1_0_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.0/IGnss.h> 34 #include <hidl/MQDescriptor.h> 35 #include <hidl/Status.h> 36 37 #include <GnssAPIClient.h> 38 #include <location_interface.h> 39 40 namespace android { 41 namespace hardware { 42 namespace gnss { 43 namespace V1_0 { 44 namespace implementation { 45 46 using ::android::hardware::hidl_array; 47 using ::android::hardware::hidl_memory; 48 using ::android::hardware::hidl_string; 49 using ::android::hardware::hidl_vec; 50 using ::android::hardware::Return; 51 using ::android::hardware::Void; 52 using ::android::sp; 53 using ::android::hardware::gnss::V1_0::GnssLocation; 54 55 struct 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 getExtensionGnssNavigationMessageGnss88 inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override { 89 return nullptr; 90 } 91 getExtensionXtraGnss92 inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override { 93 return nullptr; 94 } 95 96 Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override; 97 98 // These methods are not part of the IGnss base class. 99 GnssAPIClient* getApi(); 100 Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb); 101 Return<bool> updateConfiguration(GnssConfig& gnssConfig); 102 const GnssInterface* getGnssInterface(); 103 104 // Callback for ODCPI request 105 void odcpiRequestCb(const OdcpiRequestInfo& request); 106 107 private: 108 struct GnssDeathRecipient : hidl_death_recipient { GnssDeathRecipientGnss::GnssDeathRecipient109 GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) { 110 } 111 ~GnssDeathRecipient() = default; 112 virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override; 113 sp<Gnss> mGnss; 114 }; 115 116 private: 117 sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr; 118 119 sp<AGnss> mAGnssIface = nullptr; 120 sp<GnssNi> mGnssNi = nullptr; 121 sp<GnssMeasurement> mGnssMeasurement = nullptr; 122 sp<GnssConfiguration> mGnssConfig = nullptr; 123 sp<GnssGeofencing> mGnssGeofencingIface = nullptr; 124 sp<GnssBatching> mGnssBatching = nullptr; 125 sp<IGnssDebug> mGnssDebug = nullptr; 126 sp<AGnssRil> mGnssRil = nullptr; 127 128 GnssAPIClient* mApi = nullptr; 129 sp<V1_0::IGnssCallback> mGnssCbIface = nullptr; 130 sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr; 131 GnssConfig mPendingConfig; 132 const GnssInterface* mGnssInterface = nullptr; 133 }; 134 135 extern "C" IGnss* HIDL_FETCH_IGnss(const char* name); 136 137 } // namespace implementation 138 } // namespace V1_0 139 } // namespace gnss 140 } // namespace hardware 141 } // namespace android 142 143 #endif // ANDROID_HARDWARE_GNSS_V1_0_GNSS_H 144