blob: 7a0733a2b75e92f9b7ea7a9fee4cdcbc04e22dd1 [file] [log] [blame]
Arne Coucheron08f00002020-05-18 06:18:45 +02001/*
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_GnssXtra_H_
18#define android_hardware_gnss_V1_0_GnssXtra_H_
19
20#include <ThreadCreationWrapper.h>
21#include <android/hardware/gnss/1.0/IGnssXtra.h>
22#include <hardware/gps.h>
23#include <hidl/Status.h>
24
25namespace android {
26namespace hardware {
27namespace gnss {
28namespace V1_0 {
29namespace implementation {
30
31using ::android::hardware::gnss::V1_0::IGnssXtra;
32using ::android::hardware::gnss::V1_0::IGnssXtraCallback;
33using ::android::hardware::Return;
34using ::android::hardware::Void;
35using ::android::hardware::hidl_vec;
36using ::android::hardware::hidl_string;
37using ::android::sp;
38
39/*
40 * This interface is used by the GNSS HAL to request the framework to download XTRA data.
41 * Also contains wrapper methods to allow methods from IGnssXtraCallback interface to be passed
42 * into the conventional implementation of the GNSS HAL.
43 */
44struct GnssXtra : public IGnssXtra {
45 GnssXtra(const GpsXtraInterface* xtraIface);
46 ~GnssXtra();
47
48 /*
49 * Methods from ::android::hardware::gnss::V1_0::IGnssXtra follow.
50 * These declarations were generated from IGnssXtra.hal.
51 */
52 Return<bool> setCallback(const sp<IGnssXtraCallback>& callback) override;
53 Return<bool> injectXtraData(const hidl_string& xtraData) override;
54
55 /*
56 * Callback methods to be passed into the conventional GNSS HAL by the default implementation.
57 * These methods are not part of the IGnssXtra base class.
58 */
59 static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
60 static void gnssXtraDownloadRequestCb();
61
62 /*
63 * Holds function pointers to the callback methods.
64 */
65 static GpsXtraCallbacks sGnssXtraCb;
66
67 private:
68 const GpsXtraInterface* mGnssXtraIface = nullptr;
69 static sp<IGnssXtraCallback> sGnssXtraCbIface;
70 static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
71 static bool sInterfaceExists;
72};
73
74} // namespace implementation
75} // namespace V1_0
76} // namespace gnss
77} // namespace hardware
78} // namespace android
79
80#endif // android_hardware_gnss_V1_0_GnssXtra_H_