GnssConfiguration.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
  2. #define ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
  3. #include <android/hardware/gnss/1.1/IGnssCallback.h>
  4. #include <android/hardware/gnss/1.1/IGnssConfiguration.h>
  5. #include <hidl/MQDescriptor.h>
  6. #include <hidl/Status.h>
  7. #include <mutex>
  8. #include <unordered_set>
  9. namespace android {
  10. namespace hardware {
  11. namespace gnss {
  12. namespace V1_1 {
  13. namespace implementation {
  14. using ::android::hardware::hidl_array;
  15. using ::android::hardware::hidl_memory;
  16. using ::android::hardware::hidl_string;
  17. using ::android::hardware::hidl_vec;
  18. using ::android::hardware::Return;
  19. using ::android::hardware::Void;
  20. using ::android::sp;
  21. using BlacklistedSource = ::android::hardware::gnss::V1_1::IGnssConfiguration::BlacklistedSource;
  22. using GnssConstellationType = V1_0::GnssConstellationType;
  23. using GnssSvInfo = V1_0::IGnssCallback::GnssSvInfo;
  24. struct BlacklistedSourceHash {
  25. inline int operator()(const BlacklistedSource& source) const {
  26. return int(source.constellation) * 1000 + int(source.svid);
  27. }
  28. };
  29. struct BlacklistedSourceEqual {
  30. inline bool operator()(const BlacklistedSource& s1, const BlacklistedSource& s2) const {
  31. return (s1.constellation == s2.constellation) && (s1.svid == s2.svid);
  32. }
  33. };
  34. using BlacklistedSourceSet =
  35. std::unordered_set<BlacklistedSource, BlacklistedSourceHash, BlacklistedSourceEqual>;
  36. using BlacklistedConstellationSet = std::unordered_set<GnssConstellationType>;
  37. struct GnssConfiguration : public IGnssConfiguration {
  38. // Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
  39. Return<bool> setSuplEs(bool enabled) override;
  40. Return<bool> setSuplVersion(uint32_t version) override;
  41. Return<bool> setSuplMode(hidl_bitfield<SuplMode> mode) override;
  42. Return<bool> setGpsLock(hidl_bitfield<GpsLock> lock) override;
  43. Return<bool> setLppProfile(hidl_bitfield<LppProfile> lppProfile) override;
  44. Return<bool> setGlonassPositioningProtocol(hidl_bitfield<GlonassPosProtocol> protocol) override;
  45. Return<bool> setEmergencySuplPdn(bool enable) override;
  46. // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
  47. Return<bool> setBlacklist(const hidl_vec<BlacklistedSource>& blacklist) override;
  48. Return<bool> isBlacklisted(const GnssSvInfo& gnssSvInfo) const;
  49. std::recursive_mutex& getMutex() const;
  50. private:
  51. BlacklistedSourceSet mBlacklistedSourceSet;
  52. BlacklistedConstellationSet mBlacklistedConstellationSet;
  53. mutable std::recursive_mutex mMutex;
  54. };
  55. } // namespace implementation
  56. } // namespace V1_1
  57. } // namespace gnss
  58. } // namespace hardware
  59. } // namespace android
  60. #endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H