Yu-Han Yang | 73f16ad | 2018-02-24 10:05:32 -0800 | [diff] [blame] | 1 | #ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H |
| 2 | #define ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H |
| 3 | |
Yu-Han Yang | a2f7732 | 2018-03-06 10:12:55 -0800 | [diff] [blame] | 4 | #include <android/hardware/gnss/1.1/IGnssCallback.h> |
Yu-Han Yang | 73f16ad | 2018-02-24 10:05:32 -0800 | [diff] [blame] | 5 | #include <android/hardware/gnss/1.1/IGnssConfiguration.h> |
| 6 | #include <hidl/MQDescriptor.h> |
| 7 | #include <hidl/Status.h> |
Yu-Han Yang | a2f7732 | 2018-03-06 10:12:55 -0800 | [diff] [blame] | 8 | #include <mutex> |
| 9 | #include <unordered_set> |
Yu-Han Yang | 73f16ad | 2018-02-24 10:05:32 -0800 | [diff] [blame] | 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 | |
Yu-Han Yang | a2f7732 | 2018-03-06 10:12:55 -0800 | [diff] [blame] | 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 { |
| 30 | inline int operator()(const BlacklistedSource& source) const { |
| 31 | return int(source.constellation) * 1000 + int(source.svid); |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | struct BlacklistedSourceEqual { |
| 36 | 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 | |
Yu-Han Yang | 73f16ad | 2018-02-24 10:05:32 -0800 | [diff] [blame] | 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. |
Yu-Han Yang | a2f7732 | 2018-03-06 10:12:55 -0800 | [diff] [blame] | 56 | Return<bool> setBlacklist(const hidl_vec<BlacklistedSource>& blacklist) override; |
Yu-Han Yang | 73f16ad | 2018-02-24 10:05:32 -0800 | [diff] [blame] | 57 | |
Yu-Han Yang | a2f7732 | 2018-03-06 10:12:55 -0800 | [diff] [blame] | 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; |
Yu-Han Yang | 73f16ad | 2018-02-24 10:05:32 -0800 | [diff] [blame] | 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 |