GnssConfiguration.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  3. * Not a Contribution
  4. */
  5. /*
  6. * Copyright (C) 2020 The Android Open Source Project
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. #include <aidl/android/hardware/gnss/BnGnssConfiguration.h>
  21. #include <aidl/android/hardware/gnss/GnssConstellationType.h>
  22. #include <aidl/android/hardware/gnss/BlocklistedSource.h>
  23. #include <mutex>
  24. #include <unordered_set>
  25. #include <vector>
  26. namespace android {
  27. namespace hardware {
  28. namespace gnss {
  29. namespace aidl {
  30. namespace implementation {
  31. using ::aidl::android::hardware::gnss::GnssConstellationType;
  32. using ::aidl::android::hardware::gnss::BlocklistedSource;
  33. using ::aidl::android::hardware::gnss::BnGnssConfiguration;
  34. struct BlocklistedSourceHash {
  35. inline int operator()(const BlocklistedSource& source) const {
  36. return int(source.constellation) * 1000 + int(source.svid);
  37. }
  38. };
  39. struct BlocklistedSourceEqual {
  40. inline bool operator()(const BlocklistedSource& s1, const BlocklistedSource& s2) const {
  41. return (s1.constellation == s2.constellation) && (s1.svid == s2.svid);
  42. }
  43. };
  44. using std::vector;
  45. using BlocklistedSourceSet =
  46. std::unordered_set<BlocklistedSource, BlocklistedSourceHash, BlocklistedSourceEqual>;
  47. using BlocklistedConstellationSet = std::unordered_set<GnssConstellationType>;
  48. struct Gnss;
  49. struct GnssConfiguration : public BnGnssConfiguration {
  50. public:
  51. GnssConfiguration(Gnss* gnss);
  52. ndk::ScopedAStatus setSuplVersion(int) override;
  53. ndk::ScopedAStatus setSuplMode(int) override;
  54. ndk::ScopedAStatus setLppProfile(int) override;
  55. ndk::ScopedAStatus setGlonassPositioningProtocol(int) override;
  56. ndk::ScopedAStatus setEmergencySuplPdn(bool) override;
  57. ndk::ScopedAStatus setEsExtensionSec(int) override;
  58. ndk::ScopedAStatus setBlocklist(const vector<BlocklistedSource>& blocklist) override;
  59. private:
  60. Gnss* mGnss = nullptr;
  61. bool setBlocklistedSource(GnssSvIdSource& copyToSource,
  62. const BlocklistedSource& copyFromSource);
  63. BlocklistedSourceSet mBlocklistedSourceSet;
  64. BlocklistedConstellationSet mBlocklistedConstellationSet;
  65. mutable std::recursive_mutex mMutex;
  66. };
  67. } // namespace implementation
  68. } // namespace aidl
  69. } // namespace gnss
  70. } // namespace hardware
  71. } // namespace android