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 #pragma once 18 19 #include <android/hardware/gnss/2.1/IGnssCallback.h> 20 #include <android/hardware/gnss/2.1/IGnssConfiguration.h> 21 #include <hidl/MQDescriptor.h> 22 #include <hidl/Status.h> 23 #include <mutex> 24 #include <unordered_set> 25 26 namespace android::hardware::gnss::V2_1::implementation { 27 28 struct BlacklistedSourceHashV2_1 { operatorBlacklistedSourceHashV2_129 inline int operator()( 30 const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& source) 31 const { 32 return int(source.constellation) * 1000 + int(source.svid); 33 } 34 }; 35 36 struct BlacklistedSourceEqualV2_1 { operatorBlacklistedSourceEqualV2_137 inline bool operator()( 38 const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& s1, 39 const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& s2) 40 const { 41 return (s1.constellation == s2.constellation) && (s1.svid == s2.svid); 42 } 43 }; 44 45 using BlacklistedSourceSetV2_1 = 46 std::unordered_set<::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource, 47 BlacklistedSourceHashV2_1, BlacklistedSourceEqualV2_1>; 48 using BlacklistedConstellationSetV2_1 = std::unordered_set<V2_0::GnssConstellationType>; 49 50 struct GnssConfiguration : public IGnssConfiguration { 51 // Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow. 52 Return<bool> setSuplEs(bool enabled) override; 53 Return<bool> setSuplVersion(uint32_t version) override; 54 Return<bool> setSuplMode(hidl_bitfield<SuplMode> mode) override; 55 Return<bool> setGpsLock(hidl_bitfield<GpsLock> lock) override; 56 Return<bool> setLppProfile(hidl_bitfield<LppProfile> lppProfile) override; 57 Return<bool> setGlonassPositioningProtocol(hidl_bitfield<GlonassPosProtocol> protocol) override; 58 Return<bool> setEmergencySuplPdn(bool enable) override; 59 60 // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow. 61 Return<bool> setBlacklist( 62 const hidl_vec<V1_1::IGnssConfiguration::BlacklistedSource>& blacklist) override; 63 64 std::recursive_mutex& getMutex() const; 65 66 // Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow. 67 Return<bool> setEsExtensionSec(uint32_t emergencyExtensionSeconds) override; 68 69 // Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow. 70 Return<bool> setBlacklist_2_1( 71 const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& blacklist) override; 72 73 Return<bool> isBlacklistedV2_1(const V2_1::IGnssCallback::GnssSvInfo& gnssSvInfo) const; 74 75 private: 76 mutable std::recursive_mutex mMutex; 77 78 BlacklistedSourceSetV2_1 mBlacklistedSourceSet; 79 BlacklistedConstellationSetV2_1 mBlacklistedConstellationSet; 80 }; 81 82 } // namespace android::hardware::gnss::V2_1::implementation 83