blob: 72f77976e5a08f39d210c5decd7aeebde4eee732 [file] [log] [blame]
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -08001/*
2 * Copyright (C) 2018 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_0_GNSS_H
18#define ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
19
20#include <android/hardware/gnss/2.0/IGnss.h>
21#include <hidl/MQDescriptor.h>
22#include <hidl/Status.h>
Yu-Han Yanga5098612019-02-08 16:22:07 -080023#include <atomic>
24#include <mutex>
25#include <thread>
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -080026
27namespace android {
28namespace hardware {
29namespace gnss {
30namespace V2_0 {
31namespace implementation {
32
33using ::android::sp;
34using ::android::hardware::hidl_array;
35using ::android::hardware::hidl_memory;
36using ::android::hardware::hidl_string;
37using ::android::hardware::hidl_vec;
38using ::android::hardware::Return;
39using ::android::hardware::Void;
40
Yu-Han Yanga5098612019-02-08 16:22:07 -080041using GnssConstellationType = V1_0::GnssConstellationType;
42using GnssLocation = V1_0::GnssLocation;
43using GnssSvInfo = V1_0::IGnssCallback::GnssSvInfo;
44using GnssSvStatus = V1_0::IGnssCallback::GnssSvStatus;
45
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -080046struct Gnss : public IGnss {
Yu-Han Yanga5098612019-02-08 16:22:07 -080047 Gnss();
48 ~Gnss();
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -080049 // Methods from V1_0::IGnss follow.
50 Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override;
51 Return<bool> start() override;
52 Return<bool> stop() override;
53 Return<void> cleanup() override;
54 Return<bool> injectTime(int64_t timeMs, int64_t timeReferenceMs,
55 int32_t uncertaintyMs) override;
56 Return<bool> injectLocation(double latitudeDegrees, double longitudeDegrees,
57 float accuracyMeters) override;
58 Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override;
59 Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
60 V1_0::IGnss::GnssPositionRecurrence recurrence,
61 uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
62 uint32_t preferredTimeMs) override;
63 Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
64 Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
65 Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
66 Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
67 Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
68 Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override;
69 Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override;
70 Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
71 Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
72 Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
73
74 // Methods from V1_1::IGnss follow.
75 Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
76 Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
77 V1_0::IGnss::GnssPositionRecurrence recurrence,
78 uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
79 uint32_t preferredTimeMs, bool lowPowerMode) override;
80 Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
81 Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
Yu-Han Yanga5098612019-02-08 16:22:07 -080082 Return<bool> injectBestLocation(const GnssLocation& location) override;
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -080083
84 // Methods from V2_0::IGnss follow.
Anil Admal4e50a4c2018-12-19 15:22:13 -080085 Return<sp<V2_0::IGnssConfiguration>> getExtensionGnssConfiguration_2_0() override;
Yu-Han Yang6999a0f2019-03-14 11:08:43 -070086 Return<sp<V2_0::IGnssDebug>> getExtensionGnssDebug_2_0() override;
Anil Admal3a405c52018-11-14 09:35:14 -080087 Return<sp<V2_0::IAGnss>> getExtensionAGnss_2_0() override;
Anil Admalb02bcc12018-11-14 10:23:45 -080088 Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override;
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -080089 Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
gomo1da4b5c2018-12-02 02:49:10 -080090 Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
91 Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
92 getExtensionMeasurementCorrections() override;
Anil Admal4d739e72018-11-14 12:38:57 -080093 Return<sp<visibility_control::V1_0::IGnssVisibilityControl>> getExtensionVisibilityControl()
94 override;
Anil Admal704bc612019-03-21 18:45:30 +000095 Return<sp<V2_0::IGnssBatching>> getExtensionGnssBatching_2_0() override;
Pierre Fite-Georgel12ac2b52019-01-17 16:56:17 -080096 Return<bool> injectBestLocation_2_0(const V2_0::GnssLocation& location) override;
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -080097
Pierre Fite-Georgel12ac2b52019-01-17 16:56:17 -080098 private:
99 Return<void> reportLocation(const V2_0::GnssLocation&) const;
100 static sp<V2_0::IGnssCallback> sGnssCallback_2_0;
101 static sp<V1_1::IGnssCallback> sGnssCallback_1_1;
102 std::atomic<long> mMinIntervalMs;
103 std::atomic<bool> mIsActive;
104 std::thread mThread;
105 mutable std::mutex mMutex;
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -0800106};
107
108} // namespace implementation
109} // namespace V2_0
110} // namespace gnss
111} // namespace hardware
112} // namespace android
113
Anil Admal3a405c52018-11-14 09:35:14 -0800114#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSS_H