Hridya Valsaraju | 29dc1e0 | 2016-10-21 14:41:12 -0700 | [diff] [blame] | 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_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 | |
| 25 | namespace android { |
| 26 | namespace hardware { |
| 27 | namespace gnss { |
| 28 | namespace V1_0 { |
| 29 | namespace implementation { |
| 30 | |
| 31 | using ::android::hardware::gnss::V1_0::IGnssXtra; |
| 32 | using ::android::hardware::gnss::V1_0::IGnssXtraCallback; |
| 33 | using ::android::hardware::Return; |
| 34 | using ::android::hardware::Void; |
| 35 | using ::android::hardware::hidl_vec; |
| 36 | using ::android::hardware::hidl_string; |
| 37 | using ::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 | */ |
| 44 | struct 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_ |