GnssMeasurement.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_1_GNSSMEASUREMENT_H
  21. #define ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H
  22. #include <android/hardware/gnss/1.1/IGnssMeasurement.h>
  23. #include <hidl/MQDescriptor.h>
  24. #include <hidl/Status.h>
  25. namespace android {
  26. namespace hardware {
  27. namespace gnss {
  28. namespace V1_1 {
  29. namespace implementation {
  30. using ::android::hardware::gnss::V1_1::IGnssMeasurement;
  31. using ::android::hardware::gnss::V1_1::IGnssMeasurementCallback;
  32. using ::android::hardware::Return;
  33. using ::android::hardware::Void;
  34. using ::android::hardware::hidl_vec;
  35. using ::android::hardware::hidl_string;
  36. using ::android::sp;
  37. class MeasurementAPIClient;
  38. struct GnssMeasurement : public IGnssMeasurement {
  39. GnssMeasurement(const sp<GnssMeasurement>& self);
  40. ~GnssMeasurement();
  41. /*
  42. * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
  43. * These declarations were generated from IGnssMeasurement.hal.
  44. */
  45. Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
  46. const sp<V1_0::IGnssMeasurementCallback>& callback) override;
  47. Return<void> close() override;
  48. // Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
  49. Return<GnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
  50. const sp<IGnssMeasurementCallback>& callback,
  51. bool enableFullTracking) override;
  52. private:
  53. struct GnssMeasurementDeathRecipient : hidl_death_recipient {
  54. GnssMeasurementDeathRecipient(const sp<GnssMeasurement>& gnssMeasurement) :
  55. mGnssMeasurement(gnssMeasurement) {
  56. }
  57. ~GnssMeasurementDeathRecipient() = default;
  58. virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
  59. const wp<GnssMeasurement> mGnssMeasurement;
  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<GnssMeasurement>& mSelf;
  66. sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
  67. sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
  68. sp<IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1 = nullptr;
  69. MeasurementAPIClient* mApi;
  70. };
  71. } // namespace implementation
  72. } // namespace V1_1
  73. } // namespace gnss
  74. } // namespace hardware
  75. } // namespace android
  76. #endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H