Gnss.h 5.7 KB

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