GnssMeasurement.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (c) 2017-2020, 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_1_GNSSMEASUREMENT_H
  21. #define ANDROID_HARDWARE_GNSS_V2_1_GNSSMEASUREMENT_H
  22. #include <android/hardware/gnss/2.1/IGnssMeasurement.h>
  23. #include <hidl/MQDescriptor.h>
  24. #include <hidl/Status.h>
  25. namespace android {
  26. namespace hardware {
  27. namespace gnss {
  28. namespace V2_1 {
  29. namespace implementation {
  30. using ::android::hardware::Return;
  31. using ::android::hardware::Void;
  32. using ::android::hardware::hidl_vec;
  33. using ::android::hardware::hidl_string;
  34. using ::android::sp;
  35. class MeasurementAPIClient;
  36. struct GnssMeasurement : public V2_1::IGnssMeasurement {
  37. GnssMeasurement(const sp<GnssMeasurement>& self);
  38. ~GnssMeasurement();
  39. /*
  40. * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
  41. * These declarations were generated from IGnssMeasurement.hal.
  42. */
  43. Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback(
  44. const sp<V1_0::IGnssMeasurementCallback>& callback) override;
  45. Return<void> close() override;
  46. // Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
  47. Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
  48. const sp<V1_1::IGnssMeasurementCallback>& callback,
  49. bool enableFullTracking) override;
  50. // Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow.
  51. Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_2_0(
  52. const sp<V2_0::IGnssMeasurementCallback>& callback,
  53. bool enableFullTracking) override;
  54. // Methods from ::android::hardware::gnss::V2_1::IGnssMeasurement follow.
  55. Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_2_1(
  56. const sp<::android::hardware::gnss::V2_1::IGnssMeasurementCallback>& callback,
  57. bool enableFullTracking) override;
  58. private:
  59. struct GnssMeasurementDeathRecipient : hidl_death_recipient {
  60. GnssMeasurementDeathRecipient(const sp<GnssMeasurement>& gnssMeasurement) :
  61. mGnssMeasurement(gnssMeasurement) {
  62. }
  63. ~GnssMeasurementDeathRecipient() = default;
  64. virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
  65. const wp<GnssMeasurement> mGnssMeasurement;
  66. };
  67. void handleClientDeath();
  68. private:
  69. // this has to be a reference, not a copy
  70. // because the pointer is not set when mSelf is assigned
  71. const sp<GnssMeasurement>& mSelf;
  72. sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
  73. sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
  74. sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1 = nullptr;
  75. sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0 = nullptr;
  76. sp<V2_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_1 = nullptr;
  77. MeasurementAPIClient* mApi;
  78. void clearInterfaces();
  79. };
  80. } // namespace implementation
  81. } // namespace V2_1
  82. } // namespace gnss
  83. } // namespace hardware
  84. } // namespace android
  85. #endif // ANDROID_HARDWARE_GNSS_V2_1_GNSSMEASUREMENT_H