GnssBatching.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  3. * Not a Contribution
  4. */
  5. /*
  6. * Copyright (C) 2016 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. #ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
  21. #define ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
  22. #include <android/hardware/gnss/1.0/IGnssBatching.h>
  23. #include <hidl/Status.h>
  24. namespace android {
  25. namespace hardware {
  26. namespace gnss {
  27. namespace V1_0 {
  28. namespace implementation {
  29. using ::android::hardware::gnss::V1_0::IGnssBatching;
  30. using ::android::hardware::gnss::V1_0::IGnssBatchingCallback;
  31. using ::android::hidl::base::V1_0::IBase;
  32. using ::android::hardware::hidl_array;
  33. using ::android::hardware::hidl_memory;
  34. using ::android::hardware::hidl_string;
  35. using ::android::hardware::hidl_vec;
  36. using ::android::hardware::Return;
  37. using ::android::hardware::Void;
  38. using ::android::sp;
  39. class BatchingAPIClient;
  40. struct GnssBatching : public IGnssBatching {
  41. inline GnssBatching(const sp<GnssBatching>& self) : mSelf(self), mApi(nullptr) {}
  42. ~GnssBatching();
  43. // Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
  44. Return<bool> init(const sp<IGnssBatchingCallback>& callback) override;
  45. Return<uint16_t> getBatchSize() override;
  46. Return<bool> start(const IGnssBatching::Options& options ) override;
  47. Return<void> flush() override;
  48. Return<bool> stop() override;
  49. Return<void> cleanup() override;
  50. private:
  51. struct GnssBatchingDeathRecipient : hidl_death_recipient {
  52. GnssBatchingDeathRecipient(const sp<GnssBatching>& gnssBatching) :
  53. mGnssBatching(gnssBatching) {
  54. }
  55. ~GnssBatchingDeathRecipient() = default;
  56. virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
  57. const wp<GnssBatching> mGnssBatching;
  58. };
  59. void handleClientDeath();
  60. private:
  61. // this has to be a reference, not a copy
  62. // because the pointer is not set when mSelf is assigned
  63. const sp<GnssBatching>& mSelf;
  64. sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
  65. sp<IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
  66. BatchingAPIClient* mApi = nullptr;
  67. };
  68. } // namespace implementation
  69. } // namespace V1_0
  70. } // namespace gnss
  71. } // namespace hardware
  72. } // namespace android
  73. #endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H