GnssPowerIndication.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/BnGnssPowerIndication.h>
  21. #include <location_interface.h>
  22. namespace android {
  23. namespace hardware {
  24. namespace gnss {
  25. namespace aidl {
  26. namespace implementation {
  27. using ::aidl::android::hardware::gnss::BnGnssPowerIndication;
  28. using ::aidl::android::hardware::gnss::IGnssPowerIndicationCallback;
  29. using ::aidl::android::hardware::gnss::GnssPowerStats;
  30. struct GnssPowerIndication : public BnGnssPowerIndication {
  31. public:
  32. GnssPowerIndication();
  33. ~GnssPowerIndication();
  34. ::ndk::ScopedAStatus setCallback(
  35. const std::shared_ptr<IGnssPowerIndicationCallback>& in_callback) override;
  36. ::ndk::ScopedAStatus requestGnssPowerStats() override;
  37. void cleanup();
  38. // callbacks we are interested in
  39. void gnssPowerIndicationCb(GnssPowerStatistics gnssPowerStatistics);
  40. static void piGnssPowerIndicationCb(GnssPowerStatistics gnssPowerStatistics);
  41. private:
  42. std::shared_ptr<IGnssPowerIndicationCallback> mGnssPowerIndicationCb = nullptr;
  43. // Synchronization lock for mGnssPowerIndicationCb
  44. mutable std::mutex mMutex;
  45. AIBinder_DeathRecipient* mDeathRecipient;
  46. const GnssInterface* mGnssInterface = nullptr;
  47. static void gnssPowerIndicationDied(void* cookie);
  48. };
  49. } // namespace implementation
  50. } // namespace aidl
  51. } // namespace gnss
  52. } // namespace hardware
  53. } // namespace android