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_AGnssRil_H_ |
| 18 | #define android_hardware_gnss_V1_0_AGnssRil_H_ |
| 19 | |
| 20 | #include <ThreadCreationWrapper.h> |
| 21 | #include <android/hardware/gnss/1.0/IAGnssRil.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::IAGnssRil; |
| 32 | using ::android::hardware::gnss::V1_0::IAGnssRilCallback; |
| 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 | * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface |
| 41 | * allows the GNSS chipset to request radio interface layer information from Android platform. |
| 42 | * Examples of such information are reference location, unique subscriber ID, phone number string |
| 43 | * and network availability changes. Also contains wrapper methods to allow methods from |
| 44 | * IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL. |
| 45 | */ |
| 46 | struct AGnssRil : public IAGnssRil { |
| 47 | AGnssRil(const AGpsRilInterface* aGpsRilIface); |
| 48 | ~AGnssRil(); |
| 49 | |
| 50 | /* |
| 51 | * Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow. |
| 52 | * These declarations were generated from IAGnssRil.hal. |
| 53 | */ |
| 54 | Return<void> setCallback(const sp<IAGnssRilCallback>& callback) override; |
| 55 | Return<void> setRefLocation(const IAGnssRil::AGnssRefLocation& agnssReflocation) override; |
| 56 | Return<bool> setSetId(IAGnssRil::SetIDType type, const hidl_string& setid) override; |
| 57 | Return<bool> updateNetworkState(bool connected, |
| 58 | IAGnssRil::NetworkType type, |
| 59 | bool roaming) override; |
| 60 | Return<bool> updateNetworkAvailability(bool available, const hidl_string& apn) override; |
| 61 | static void requestSetId(uint32_t flags); |
| 62 | static void requestRefLoc(uint32_t flags); |
| 63 | |
| 64 | /* |
| 65 | * Callback method to be passed into the conventional GNSS HAL by the default |
| 66 | * implementation. This method is not part of the IAGnssRil base class. |
| 67 | */ |
| 68 | static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg); |
| 69 | |
| 70 | /* |
| 71 | * Holds function pointers to the callback methods. |
| 72 | */ |
| 73 | static AGpsRilCallbacks sAGnssRilCb; |
| 74 | |
| 75 | private: |
| 76 | const AGpsRilInterface* mAGnssRilIface = nullptr; |
| 77 | static sp<IAGnssRilCallback> sAGnssRilCbIface; |
| 78 | static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList; |
| 79 | static bool sInterfaceExists; |
| 80 | }; |
| 81 | |
| 82 | } // namespace implementation |
| 83 | } // namespace V1_0 |
| 84 | } // namespace gnss |
| 85 | } // namespace hardware |
| 86 | } // namespace android |
| 87 | |
| 88 | #endif // android_hardware_gnss_V1_0_AGnssRil_H_ |