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