• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
50     // Guarded by mMutex
51     static sp<IGnssAntennaInfoCallback> sCallback;
52 
53     std::atomic<long> mMinIntervalMillis;
54     std::atomic<bool> mIsActive;
55     std::thread mThread;
56 
57     // Synchronization lock for sCallback
58     mutable std::mutex mMutex;
59 };
60 
61 }  // namespace implementation
62 }  // namespace V2_1
63 }  // namespace gnss
64 }  // namespace hardware
65 }  // namespace android
66 
67 #endif  // ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
68