xref: /aosp_15_r20/hardware/interfaces/gnss/1.0/default/GnssXtra.h (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker /*
2*4d7e907cSAndroid Build Coastguard Worker  * Copyright (C) 2016 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker  *
4*4d7e907cSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker  *
8*4d7e907cSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker  *
10*4d7e907cSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker  * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker  */
16*4d7e907cSAndroid Build Coastguard Worker 
17*4d7e907cSAndroid Build Coastguard Worker #ifndef android_hardware_gnss_V1_0_GnssXtra_H_
18*4d7e907cSAndroid Build Coastguard Worker #define android_hardware_gnss_V1_0_GnssXtra_H_
19*4d7e907cSAndroid Build Coastguard Worker 
20*4d7e907cSAndroid Build Coastguard Worker #include <ThreadCreationWrapper.h>
21*4d7e907cSAndroid Build Coastguard Worker #include <android/hardware/gnss/1.0/IGnssXtra.h>
22*4d7e907cSAndroid Build Coastguard Worker #include <hardware/gps.h>
23*4d7e907cSAndroid Build Coastguard Worker #include <hidl/Status.h>
24*4d7e907cSAndroid Build Coastguard Worker 
25*4d7e907cSAndroid Build Coastguard Worker namespace android {
26*4d7e907cSAndroid Build Coastguard Worker namespace hardware {
27*4d7e907cSAndroid Build Coastguard Worker namespace gnss {
28*4d7e907cSAndroid Build Coastguard Worker namespace V1_0 {
29*4d7e907cSAndroid Build Coastguard Worker namespace implementation {
30*4d7e907cSAndroid Build Coastguard Worker 
31*4d7e907cSAndroid Build Coastguard Worker using ::android::hardware::gnss::V1_0::IGnssXtra;
32*4d7e907cSAndroid Build Coastguard Worker using ::android::hardware::gnss::V1_0::IGnssXtraCallback;
33*4d7e907cSAndroid Build Coastguard Worker using ::android::hardware::Return;
34*4d7e907cSAndroid Build Coastguard Worker using ::android::hardware::Void;
35*4d7e907cSAndroid Build Coastguard Worker using ::android::hardware::hidl_vec;
36*4d7e907cSAndroid Build Coastguard Worker using ::android::hardware::hidl_string;
37*4d7e907cSAndroid Build Coastguard Worker using ::android::sp;
38*4d7e907cSAndroid Build Coastguard Worker 
39*4d7e907cSAndroid Build Coastguard Worker /*
40*4d7e907cSAndroid Build Coastguard Worker  * This interface is used by the GNSS HAL to request the framework to download XTRA data.
41*4d7e907cSAndroid Build Coastguard Worker  * Also contains wrapper methods to allow methods from IGnssXtraCallback interface to be passed
42*4d7e907cSAndroid Build Coastguard Worker  * into the conventional implementation of the GNSS HAL.
43*4d7e907cSAndroid Build Coastguard Worker  */
44*4d7e907cSAndroid Build Coastguard Worker struct GnssXtra : public IGnssXtra {
45*4d7e907cSAndroid Build Coastguard Worker     GnssXtra(const GpsXtraInterface* xtraIface);
46*4d7e907cSAndroid Build Coastguard Worker     ~GnssXtra();
47*4d7e907cSAndroid Build Coastguard Worker 
48*4d7e907cSAndroid Build Coastguard Worker     /*
49*4d7e907cSAndroid Build Coastguard Worker      * Methods from ::android::hardware::gnss::V1_0::IGnssXtra follow.
50*4d7e907cSAndroid Build Coastguard Worker      * These declarations were generated from IGnssXtra.hal.
51*4d7e907cSAndroid Build Coastguard Worker      */
52*4d7e907cSAndroid Build Coastguard Worker     Return<bool> setCallback(const sp<IGnssXtraCallback>& callback) override;
53*4d7e907cSAndroid Build Coastguard Worker     Return<bool> injectXtraData(const hidl_string& xtraData) override;
54*4d7e907cSAndroid Build Coastguard Worker 
55*4d7e907cSAndroid Build Coastguard Worker     /*
56*4d7e907cSAndroid Build Coastguard Worker      * Callback methods to be passed into the conventional GNSS HAL by the default implementation.
57*4d7e907cSAndroid Build Coastguard Worker      * These methods are not part of the IGnssXtra base class.
58*4d7e907cSAndroid Build Coastguard Worker      */
59*4d7e907cSAndroid Build Coastguard Worker     static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
60*4d7e907cSAndroid Build Coastguard Worker     static void gnssXtraDownloadRequestCb();
61*4d7e907cSAndroid Build Coastguard Worker 
62*4d7e907cSAndroid Build Coastguard Worker     /*
63*4d7e907cSAndroid Build Coastguard Worker      * Holds function pointers to the callback methods.
64*4d7e907cSAndroid Build Coastguard Worker      */
65*4d7e907cSAndroid Build Coastguard Worker     static GpsXtraCallbacks sGnssXtraCb;
66*4d7e907cSAndroid Build Coastguard Worker 
67*4d7e907cSAndroid Build Coastguard Worker  private:
68*4d7e907cSAndroid Build Coastguard Worker     const GpsXtraInterface* mGnssXtraIface = nullptr;
69*4d7e907cSAndroid Build Coastguard Worker     static sp<IGnssXtraCallback> sGnssXtraCbIface;
70*4d7e907cSAndroid Build Coastguard Worker     static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
71*4d7e907cSAndroid Build Coastguard Worker     static bool sInterfaceExists;
72*4d7e907cSAndroid Build Coastguard Worker };
73*4d7e907cSAndroid Build Coastguard Worker 
74*4d7e907cSAndroid Build Coastguard Worker }  // namespace implementation
75*4d7e907cSAndroid Build Coastguard Worker }  // namespace V1_0
76*4d7e907cSAndroid Build Coastguard Worker }  // namespace gnss
77*4d7e907cSAndroid Build Coastguard Worker }  // namespace hardware
78*4d7e907cSAndroid Build Coastguard Worker }  // namespace android
79*4d7e907cSAndroid Build Coastguard Worker 
80*4d7e907cSAndroid Build Coastguard Worker #endif  // android_hardware_gnss_V1_0_GnssXtra_H_
81