blob: 9b2699b6e207ba0372b622309ff51cd28b03b9d3 [file] [log] [blame]
Yu-Han Yang73f16ad2018-02-24 10:05:32 -08001#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
2#define ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
3
Yu-Han Yanga2f77322018-03-06 10:12:55 -08004#include <android/hardware/gnss/1.1/IGnssCallback.h>
Yu-Han Yang73f16ad2018-02-24 10:05:32 -08005#include <android/hardware/gnss/1.1/IGnssConfiguration.h>
6#include <hidl/MQDescriptor.h>
7#include <hidl/Status.h>
Yu-Han Yanga2f77322018-03-06 10:12:55 -08008#include <mutex>
9#include <unordered_set>
Yu-Han Yang73f16ad2018-02-24 10:05:32 -080010
11namespace android {
12namespace hardware {
13namespace gnss {
14namespace V1_1 {
15namespace implementation {
16
17using ::android::hardware::hidl_array;
18using ::android::hardware::hidl_memory;
19using ::android::hardware::hidl_string;
20using ::android::hardware::hidl_vec;
21using ::android::hardware::Return;
22using ::android::hardware::Void;
23using ::android::sp;
24
Yu-Han Yanga2f77322018-03-06 10:12:55 -080025using BlacklistedSource = ::android::hardware::gnss::V1_1::IGnssConfiguration::BlacklistedSource;
26using GnssConstellationType = V1_0::GnssConstellationType;
27using GnssSvInfo = V1_0::IGnssCallback::GnssSvInfo;
28
29struct BlacklistedSourceHash {
30 inline int operator()(const BlacklistedSource& source) const {
31 return int(source.constellation) * 1000 + int(source.svid);
32 }
33};
34
35struct 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
41using BlacklistedSourceSet =
42 std::unordered_set<BlacklistedSource, BlacklistedSourceHash, BlacklistedSourceEqual>;
43using BlacklistedConstellationSet = std::unordered_set<GnssConstellationType>;
44
Yu-Han Yang73f16ad2018-02-24 10:05:32 -080045struct 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 Yanga2f77322018-03-06 10:12:55 -080056 Return<bool> setBlacklist(const hidl_vec<BlacklistedSource>& blacklist) override;
Yu-Han Yang73f16ad2018-02-24 10:05:32 -080057
Yu-Han Yanga2f77322018-03-06 10:12:55 -080058 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 Yang73f16ad2018-02-24 10:05:32 -080065};
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