Gnss.h 7.4 KB

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