Mock blacklisting satellites in default implementation
- Mock GnssDebug to pass the sanity check.
Bug: 73845705
Test: All Gnss v1.1 VTS tests are passing on gce_x86
Change-Id: I258fb1671d2b682f471207192b8a0feb138c16ab
diff --git a/gnss/1.1/default/GnssConfiguration.cpp b/gnss/1.1/default/GnssConfiguration.cpp
index d05f317..2717571 100644
--- a/gnss/1.1/default/GnssConfiguration.cpp
+++ b/gnss/1.1/default/GnssConfiguration.cpp
@@ -1,4 +1,7 @@
+#define LOG_TAG "GnssConfiguration"
+
#include "GnssConfiguration.h"
+#include <log/log.h>
namespace android {
namespace hardware {
@@ -43,10 +46,33 @@
}
// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
-Return<bool> GnssConfiguration::setBlacklist(
- const hidl_vec<::android::hardware::gnss::V1_1::IGnssConfiguration::BlacklistedSource>&) {
- // TODO implement
- return bool{};
+Return<bool> GnssConfiguration::setBlacklist(const hidl_vec<BlacklistedSource>& sourceList) {
+ std::unique_lock<std::recursive_mutex> lock(mMutex);
+ mBlacklistedConstellationSet.clear();
+ mBlacklistedSourceSet.clear();
+ for (auto source : sourceList) {
+ if (source.svid == 0) {
+ // Wildcard blacklist, i.e., blacklist entire constellation.
+ mBlacklistedConstellationSet.insert(source.constellation);
+ } else {
+ mBlacklistedSourceSet.insert(source);
+ }
+ }
+ return true;
+}
+
+Return<bool> GnssConfiguration::isBlacklisted(const GnssSvInfo& gnssSvInfo) const {
+ std::unique_lock<std::recursive_mutex> lock(mMutex);
+ if (mBlacklistedConstellationSet.find(gnssSvInfo.constellation) !=
+ mBlacklistedConstellationSet.end()) {
+ return true;
+ }
+ BlacklistedSource source = {.constellation = gnssSvInfo.constellation, .svid = gnssSvInfo.svid};
+ return (mBlacklistedSourceSet.find(source) != mBlacklistedSourceSet.end());
+}
+
+std::recursive_mutex& GnssConfiguration::getMutex() const {
+ return mMutex;
}
// Methods from ::android::hidl::base::V1_0::IBase follow.