1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef android_hardware_gnss_V1_0_GnssNavigationMessage_H_
18 #define android_hardware_gnss_V1_0_GnssNavigationMessage_H_
19 
20 #include <android/hardware/gnss/1.0/IGnssNavigationMessage.h>
21 #include <hidl/Status.h>
22 #include <hardware/gps.h>
23 
24 namespace android {
25 namespace hardware {
26 namespace gnss {
27 namespace V1_0 {
28 namespace implementation {
29 
30 using ::android::hardware::gnss::V1_0::IGnssNavigationMessage;
31 using ::android::hardware::gnss::V1_0::IGnssNavigationMessageCallback;
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 
38 using LegacyGnssNavigationMessage = ::GnssNavigationMessage;
39 
40 /*
41  * Extended interface for GNSS navigation message reporting support. Also contains wrapper methods
42  * to allow methods from IGnssNavigationMessageCallback interface to be passed into the conventional
43  * implementation of the GNSS HAL.
44  */
45 struct GnssNavigationMessage : public IGnssNavigationMessage {
46     GnssNavigationMessage(const GpsNavigationMessageInterface* gpsNavigationMessageIface);
47 
48     /*
49      * Methods from ::android::hardware::gnss::V1_0::IGnssNavigationMessage follow.
50      * These declarations were generated from IGnssNavigationMessage.hal.
51      */
52     Return<GnssNavigationMessageStatus> setCallback(
53         const sp<IGnssNavigationMessageCallback>& callback) override;
54     Return<void> close() override;
55 
56     /*
57      * Callback methods to be passed into the conventional GNSS HAL by the default implementation.
58      * These methods are not part of the IGnssNavigationMessage base class.
59      */
60     static void gnssNavigationMessageCb(LegacyGnssNavigationMessage* message);
61 
62     /*
63      * Holds function pointers to the callback methods.
64      */
65     static GpsNavigationMessageCallbacks sGnssNavigationMessageCb;
66  private:
67     const GpsNavigationMessageInterface* mGnssNavigationMessageIface = nullptr;
68     static sp<IGnssNavigationMessageCallback> sGnssNavigationMsgCbIface;
69 };
70 
71 }  // namespace implementation
72 }  // namespace V1_0
73 }  // namespace gnss
74 }  // namespace hardware
75 }  // namespace android
76 
77 #endif  // android_hardware_gnss_V1_0_GnssNavigationMessage_H_
78