• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
18 #define ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
19 
20 #include <android/hardware/gnss/2.1/IGnssCallback.h>
21 #include <android/hardware/gnss/2.1/IGnssConfiguration.h>
22 #include <hidl/MQDescriptor.h>
23 #include <hidl/Status.h>
24 #include <mutex>
25 #include <unordered_set>
26 
27 namespace android {
28 namespace hardware {
29 namespace gnss {
30 namespace V2_1 {
31 namespace implementation {
32 
33 using ::android::sp;
34 using ::android::hardware::hidl_array;
35 using ::android::hardware::hidl_memory;
36 using ::android::hardware::hidl_string;
37 using ::android::hardware::hidl_vec;
38 using ::android::hardware::Return;
39 using ::android::hardware::Void;
40 
41 using BlacklistedSourceV2_1 =
42         ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource;
43 using GnssConstellationTypeV2_0 = V2_0::GnssConstellationType;
44 using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
45 
46 struct BlacklistedSourceHashV2_1 {
operatorBlacklistedSourceHashV2_147     inline int operator()(const BlacklistedSourceV2_1& source) const {
48         return int(source.constellation) * 1000 + int(source.svid);
49     }
50 };
51 
52 struct BlacklistedSourceEqualV2_1 {
operatorBlacklistedSourceEqualV2_153     inline bool operator()(const BlacklistedSourceV2_1& s1, const BlacklistedSourceV2_1& s2) const {
54         return (s1.constellation == s2.constellation) && (s1.svid == s2.svid);
55     }
56 };
57 
58 using BlacklistedSourceSetV2_1 =
59         std::unordered_set<BlacklistedSourceV2_1, BlacklistedSourceHashV2_1,
60                            BlacklistedSourceEqualV2_1>;
61 using BlacklistedConstellationSetV2_1 = std::unordered_set<GnssConstellationTypeV2_0>;
62 
63 struct GnssConfiguration : public IGnssConfiguration {
64     // Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
65     Return<bool> setSuplEs(bool enabled) override;
66     Return<bool> setSuplVersion(uint32_t version) override;
67     Return<bool> setSuplMode(hidl_bitfield<SuplMode> mode) override;
68     Return<bool> setGpsLock(hidl_bitfield<GpsLock> lock) override;
69     Return<bool> setLppProfile(hidl_bitfield<LppProfile> lppProfile) override;
70     Return<bool> setGlonassPositioningProtocol(hidl_bitfield<GlonassPosProtocol> protocol) override;
71     Return<bool> setEmergencySuplPdn(bool enable) override;
72 
73     // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
74     Return<bool> setBlacklist(
75             const hidl_vec<V1_1::IGnssConfiguration::BlacklistedSource>& blacklist) override;
76 
77     std::recursive_mutex& getMutex() const;
78 
79     // Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow.
80     Return<bool> setEsExtensionSec(uint32_t emergencyExtensionSeconds) override;
81 
82     // Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow.
83     Return<bool> setBlacklist_2_1(
84             const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& blacklist) override;
85 
86     Return<bool> isBlacklistedV2_1(const GnssSvInfoV2_1& gnssSvInfo) const;
87 
88   private:
89     mutable std::recursive_mutex mMutex;
90 
91     BlacklistedSourceSetV2_1 mBlacklistedSourceSet;
92     BlacklistedConstellationSetV2_1 mBlacklistedConstellationSet;
93 };
94 
95 }  // namespace implementation
96 }  // namespace V2_1
97 }  // namespace gnss
98 }  // namespace hardware
99 }  // namespace android
100 
101 #endif  // ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H