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_GnssMeasurement_H_ |
| 18 | #define android_hardware_gnss_V1_0_GnssMeasurement_H_ |
| 19 | |
| 20 | #include <ThreadCreationWrapper.h> |
| 21 | #include <android/hardware/gnss/1.0/IGnssMeasurement.h> |
| 22 | #include <hidl/Status.h> |
| 23 | #include <hardware/gps.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::IGnssMeasurement; |
| 32 | using ::android::hardware::gnss::V1_0::IGnssMeasurementCallback; |
| 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 | using LegacyGnssData = ::GnssData; |
| 40 | |
| 41 | /* |
| 42 | * Extended interface for GNSS Measurements support. Also contains wrapper methods to allow methods |
| 43 | * from IGnssMeasurementCallback interface to be passed into the conventional implementation of the |
| 44 | * GNSS HAL. |
| 45 | */ |
| 46 | struct GnssMeasurement : public IGnssMeasurement { |
| 47 | GnssMeasurement(const GpsMeasurementInterface* gpsMeasurementIface); |
| 48 | |
| 49 | /* |
| 50 | * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow. |
| 51 | * These declarations were generated from IGnssMeasurement.hal. |
| 52 | */ |
| 53 | Return<GnssMeasurementStatus> setCallback( |
| 54 | const sp<IGnssMeasurementCallback>& callback) override; |
| 55 | Return<void> close() override; |
| 56 | |
| 57 | /* |
| 58 | * Callback methods to be passed into the conventional GNSS HAL by the default |
| 59 | * implementation. These methods are not part of the IGnssMeasurement base class. |
| 60 | */ |
| 61 | static void gnssMeasurementCb(LegacyGnssData* data); |
| 62 | /* |
| 63 | * Deprecated callback added for backward compatibity for devices that do |
| 64 | * not support GnssData measurements. |
| 65 | */ |
| 66 | static void gpsMeasurementCb(GpsData* data); |
| 67 | |
| 68 | /* |
| 69 | * Holds function pointers to the callback methods. |
| 70 | */ |
| 71 | static GpsMeasurementCallbacks sGnssMeasurementCbs; |
| 72 | |
| 73 | private: |
| 74 | const GpsMeasurementInterface* mGnssMeasureIface = nullptr; |
| 75 | static sp<IGnssMeasurementCallback> sGnssMeasureCbIface; |
| 76 | }; |
| 77 | |
| 78 | } // namespace implementation |
| 79 | } // namespace V1_0 |
| 80 | } // namespace gnss |
| 81 | } // namespace hardware |
| 82 | } // namespace android |
| 83 | |
| 84 | #endif // android_hardware_gnss_V1_0_GnssMeasurement_H_ |