Gnss.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. #ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSS_H
  21. #define ANDROID_HARDWARE_GNSS_V1_0_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.0/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_0 {
  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. // These methods are not part of the IGnss base class.
  86. GnssAPIClient* getApi();
  87. Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
  88. Return<bool> updateConfiguration(GnssConfig& gnssConfig);
  89. const GnssInterface* getGnssInterface();
  90. // Callback for ODCPI request
  91. void odcpiRequestCb(const OdcpiRequestInfo& request);
  92. private:
  93. struct GnssDeathRecipient : hidl_death_recipient {
  94. GnssDeathRecipient(const sp<Gnss>& gnss) : mGnss(gnss) {
  95. }
  96. ~GnssDeathRecipient() = default;
  97. virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
  98. const wp<Gnss> mGnss;
  99. };
  100. void handleClientDeath();
  101. private:
  102. sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
  103. sp<AGnss> mAGnssIface = nullptr;
  104. sp<GnssNi> mGnssNi = nullptr;
  105. sp<GnssMeasurement> mGnssMeasurement = nullptr;
  106. sp<GnssConfiguration> mGnssConfig = nullptr;
  107. sp<GnssGeofencing> mGnssGeofencingIface = nullptr;
  108. sp<GnssBatching> mGnssBatching = nullptr;
  109. sp<IGnssDebug> mGnssDebug = nullptr;
  110. sp<AGnssRil> mGnssRil = nullptr;
  111. GnssAPIClient* mApi = nullptr;
  112. sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
  113. sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
  114. GnssConfig mPendingConfig;
  115. const GnssInterface* mGnssInterface = nullptr;
  116. };
  117. extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
  118. } // namespace implementation
  119. } // namespace V1_0
  120. } // namespace gnss
  121. } // namespace hardware
  122. } // namespace android
  123. #endif // ANDROID_HARDWARE_GNSS_V1_0_GNSS_H