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