Sasha Kuznetsov | 768de57 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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_V2_1_GNSSANTENNAINFO_H |
| 18 | #define ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H |
| 19 | |
| 20 | #include <android/hardware/gnss/2.1/IGnssAntennaInfo.h> |
| 21 | |
| 22 | #include <mutex> |
| 23 | #include <thread> |
| 24 | |
| 25 | namespace android { |
| 26 | namespace hardware { |
| 27 | namespace gnss { |
| 28 | namespace V2_1 { |
| 29 | namespace implementation { |
| 30 | |
| 31 | using ::android::sp; |
| 32 | using ::android::hardware::Return; |
| 33 | using ::android::hardware::Void; |
| 34 | |
| 35 | struct GnssAntennaInfo : public IGnssAntennaInfo { |
| 36 | GnssAntennaInfo(); |
| 37 | ~GnssAntennaInfo(); |
| 38 | |
| 39 | // Methods from ::android::hardware::gnss::V2_1::IGnssAntennaInfo follow. |
| 40 | Return<GnssAntennaInfoStatus> setCallback( |
| 41 | const sp<IGnssAntennaInfoCallback>& callback) override; |
| 42 | Return<void> close() override; |
| 43 | |
| 44 | private: |
| 45 | void start(); |
| 46 | void stop(); |
| 47 | void reportAntennaInfo( |
| 48 | const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& antennaInfo) const; |
| 49 | |
Yu-Han Yang | f3cb556 | 2020-03-05 22:41:23 -0800 | [diff] [blame] | 50 | // Guarded by mMutex |
Sasha Kuznetsov | 768de57 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 51 | static sp<IGnssAntennaInfoCallback> sCallback; |
Yu-Han Yang | f3cb556 | 2020-03-05 22:41:23 -0800 | [diff] [blame] | 52 | |
Sasha Kuznetsov | 768de57 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 53 | std::atomic<long> mMinIntervalMillis; |
| 54 | std::atomic<bool> mIsActive; |
| 55 | std::thread mThread; |
Yu-Han Yang | f3cb556 | 2020-03-05 22:41:23 -0800 | [diff] [blame] | 56 | |
| 57 | // Synchronization lock for sCallback |
Sasha Kuznetsov | 768de57 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 58 | mutable std::mutex mMutex; |
| 59 | }; |
| 60 | |
| 61 | } // namespace implementation |
| 62 | } // namespace V2_1 |
| 63 | } // namespace gnss |
| 64 | } // namespace hardware |
| 65 | } // namespace android |
| 66 | |
Yu-Han Yang | f3cb556 | 2020-03-05 22:41:23 -0800 | [diff] [blame] | 67 | #endif // ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H |