1 /* 2 * Copyright (C) 2020 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 #define LOG_TAG "GnssConfigurationAidl" 18 19 #include "GnssConfiguration.h" 20 #include <log/log.h> 21 22 namespace aidl::android::hardware::gnss { 23 setBlocklist(const vector<BlocklistedSource> & sourceList)24ndk::ScopedAStatus GnssConfiguration::setBlocklist(const vector<BlocklistedSource>& sourceList) { 25 ALOGD("GnssConfiguration::setBlocklist"); 26 std::unique_lock<std::recursive_mutex> lock(mMutex); 27 mBlocklistedConstellationSet.clear(); 28 mBlocklistedSourceSet.clear(); 29 for (const auto& source : sourceList) { 30 if (source.svid == 0) { 31 // Wildcard blocklist, i.e., blocklist entire constellation. 32 mBlocklistedConstellationSet.insert(source.constellation); 33 } else { 34 mBlocklistedSourceSet.insert(source); 35 } 36 } 37 return ndk::ScopedAStatus::ok(); 38 } 39 isBlocklistedV2_1(const GnssSvInfoV2_1 & gnssSvInfo) const40bool GnssConfiguration::isBlocklistedV2_1(const GnssSvInfoV2_1& gnssSvInfo) const { 41 std::unique_lock<std::recursive_mutex> lock(mMutex); 42 if (mBlocklistedConstellationSet.find(static_cast<GnssConstellationType>( 43 gnssSvInfo.v2_0.constellation)) != mBlocklistedConstellationSet.end()) { 44 return true; 45 } 46 BlocklistedSource source = { 47 .constellation = static_cast<GnssConstellationType>(gnssSvInfo.v2_0.constellation), 48 .svid = gnssSvInfo.v2_0.v1_0.svid}; 49 return (mBlocklistedSourceSet.find(source) != mBlocklistedSourceSet.end()); 50 } 51 52 } // namespace aidl::android::hardware::gnss 53