GnssBatching.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2017-2019, 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_V2_0_GNSSBATCHING_H
  21. #define ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H
  22. #include <android/hardware/gnss/2.0/IGnssBatching.h>
  23. #include <hidl/Status.h>
  24. namespace android {
  25. namespace hardware {
  26. namespace gnss {
  27. namespace V2_0 {
  28. namespace implementation {
  29. using ::android::hardware::gnss::V2_0::IGnssBatching;
  30. using ::android::hardware::gnss::V2_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<V1_0::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. // Methods from ::android::hardware::gnss::V2_0::IGnssBatching follow.
  51. Return<bool> init_2_0(const sp<V2_0::IGnssBatchingCallback>& callback) override;
  52. private:
  53. struct GnssBatchingDeathRecipient : hidl_death_recipient {
  54. GnssBatchingDeathRecipient(const sp<GnssBatching>& gnssBatching) :
  55. mGnssBatching(gnssBatching) {
  56. }
  57. ~GnssBatchingDeathRecipient() = default;
  58. virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
  59. const wp<GnssBatching> mGnssBatching;
  60. };
  61. void handleClientDeath();
  62. private:
  63. // this has to be a reference, not a copy
  64. // because the pointer is not set when mSelf is assigned
  65. const sp<GnssBatching>& mSelf;
  66. sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
  67. sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
  68. BatchingAPIClient* mApi = nullptr;
  69. sp<V2_0::IGnssBatchingCallback> mGnssBatchingCbIface_2_0 = nullptr;
  70. };
  71. } // namespace implementation
  72. } // namespace V2_0
  73. } // namespace gnss
  74. } // namespace hardware
  75. } // namespace android
  76. #endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H