blob: e21fb175a6c40f76e7753c50be0e69bff3588f11 [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#define LOG_TAG "Gnss"
18
19#include "Gnss.h"
20#include <log/log.h>
21
22namespace android {
23namespace hardware {
24namespace gnss {
25namespace V2_0 {
26namespace implementation {
27
gomo1da4b5c2018-12-02 02:49:10 -080028sp<V2_0::IGnssCallback> Gnss::sGnssCallback_2_0 = nullptr;
29sp<V1_1::IGnssCallback> Gnss::sGnssCallback_1_1 = nullptr;
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -080030
31// Methods from V1_0::IGnss follow.
32Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>&) {
33 // TODO implement
34 return bool{};
35}
36
37Return<bool> Gnss::start() {
38 // TODO implement
39 return bool{};
40}
41
42Return<bool> Gnss::stop() {
43 // TODO implement
44 return bool{};
45}
46
47Return<void> Gnss::cleanup() {
48 // TODO implement
49 return Void();
50}
51
52Return<bool> Gnss::injectTime(int64_t, int64_t, int32_t) {
53 // TODO implement
54 return bool{};
55}
56
57Return<bool> Gnss::injectLocation(double, double, float) {
58 // TODO implement
59 return bool{};
60}
61
62Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData) {
63 // TODO implement
64 return Void();
65}
66
67Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode,
68 V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t,
69 uint32_t) {
70 // TODO implement
71 return bool{};
72}
73
74Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
75 // TODO implement
76 return sp<V1_0::IAGnssRil>{};
77}
78
79Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
80 // TODO implement
81 return sp<V1_0::IGnssGeofencing>{};
82}
83
84Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() {
85 // TODO implement
86 return sp<V1_0::IAGnss>{};
87}
88
89Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() {
90 // TODO implement
91 return sp<V1_0::IGnssNi>{};
92}
93
94Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
95 // TODO implement
96 return sp<V1_0::IGnssMeasurement>{};
97}
98
99Return<sp<V1_0::IGnssNavigationMessage>> Gnss::getExtensionGnssNavigationMessage() {
100 // TODO implement
101 return sp<V1_0::IGnssNavigationMessage>{};
102}
103
104Return<sp<V1_0::IGnssXtra>> Gnss::getExtensionXtra() {
105 // TODO implement
106 return sp<V1_0::IGnssXtra>{};
107}
108
109Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
110 // TODO implement
111 return sp<V1_0::IGnssConfiguration>{};
112}
113
114Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
115 // TODO implement
116 return sp<V1_0::IGnssDebug>{};
117}
118
119Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() {
120 // TODO implement
121 return sp<V1_0::IGnssBatching>{};
122}
123
124// Methods from V1_1::IGnss follow.
125Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
126 ALOGD("Gnss::setCallback_1_1");
127 if (callback == nullptr) {
128 ALOGE("%s: Null callback ignored", __func__);
129 return false;
130 }
131
gomo1da4b5c2018-12-02 02:49:10 -0800132 sGnssCallback_1_1 = callback;
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -0800133
134 uint32_t capabilities = 0x0;
gomo1da4b5c2018-12-02 02:49:10 -0800135 auto ret = sGnssCallback_1_1->gnssSetCapabilitesCb(capabilities);
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -0800136 if (!ret.isOk()) {
137 ALOGE("%s: Unable to invoke callback", __func__);
138 }
139
140 V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019};
141
gomo1da4b5c2018-12-02 02:49:10 -0800142 ret = sGnssCallback_1_1->gnssSetSystemInfoCb(gnssInfo);
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -0800143 if (!ret.isOk()) {
144 ALOGE("%s: Unable to invoke callback", __func__);
145 }
146
147 auto gnssName = "Google Mock GNSS Implementation v2.0";
gomo1da4b5c2018-12-02 02:49:10 -0800148 ret = sGnssCallback_1_1->gnssNameCb(gnssName);
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -0800149 if (!ret.isOk()) {
150 ALOGE("%s: Unable to invoke callback", __func__);
151 }
152
153 return true;
154}
155
156Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode,
157 V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t,
158 uint32_t, bool) {
159 // TODO implement
160 return bool{};
161}
162
163Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
164 // TODO implement
165 return sp<V1_1::IGnssConfiguration>{};
166}
167
168Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() {
169 // TODO implement
170 return sp<V1_1::IGnssMeasurement>{};
171}
172
173Return<bool> Gnss::injectBestLocation(const V1_0::GnssLocation&) {
174 // TODO implement
175 return bool{};
176}
177
178// Methods from V2_0::IGnss follow.
179Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
180 // TODO implement
181 return sp<V2_0::IGnssMeasurement>{};
182}
183
gomo1da4b5c2018-12-02 02:49:10 -0800184Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
185Gnss::getExtensionMeasurementCorrections() {
186 // TODO implement
187 return sp<measurement_corrections::V1_0::IMeasurementCorrections>{};
188}
189
190Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
191 ALOGD("Gnss::setCallback_2_0");
192 if (callback == nullptr) {
193 ALOGE("%s: Null callback ignored", __func__);
194 return false;
195 }
196
197 sGnssCallback_2_0 = callback;
198
199 uint32_t capabilities = 0x0;
200 auto ret = sGnssCallback_2_0->gnssSetCapabilitesCb(capabilities);
201 if (!ret.isOk()) {
202 ALOGE("%s: Unable to invoke callback", __func__);
203 }
204
205 V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019};
206
207 ret = sGnssCallback_2_0->gnssSetSystemInfoCb(gnssInfo);
208 if (!ret.isOk()) {
209 ALOGE("%s: Unable to invoke callback", __func__);
210 }
211
212 auto gnssName = "Google Mock GNSS Implementation v2.0";
213 ret = sGnssCallback_2_0->gnssNameCb(gnssName);
214 if (!ret.isOk()) {
215 ALOGE("%s: Unable to invoke callback", __func__);
216 }
217
218 return true;
219}
220
Yu-Han Yang9c6c20b2018-11-06 14:12:49 -0800221} // namespace implementation
222} // namespace V2_0
223} // namespace gnss
224} // namespace hardware
225} // namespace android