Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 1 | /* |
| 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" |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 20 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 21 | #include <log/log.h> |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 22 | #include <utils/SystemClock.h> |
| 23 | |
Anil Admal | 3a405c5 | 2018-11-14 09:35:14 -0800 | [diff] [blame] | 24 | #include "AGnss.h" |
Anil Admal | b02bcc1 | 2018-11-14 10:23:45 -0800 | [diff] [blame] | 25 | #include "AGnssRil.h" |
Anil Admal | 704bc61 | 2019-03-21 18:45:30 +0000 | [diff] [blame] | 26 | #include "GnssBatching.h" |
Anil Admal | 4e50a4c | 2018-12-19 15:22:13 -0800 | [diff] [blame] | 27 | #include "GnssConfiguration.h" |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 28 | #include "GnssMeasurement.h" |
Yu-Han Yang | 08642f9 | 2019-03-02 14:22:14 -0800 | [diff] [blame] | 29 | #include "GnssMeasurementCorrections.h" |
Anil Admal | 4d739e7 | 2018-11-14 12:38:57 -0800 | [diff] [blame] | 30 | #include "GnssVisibilityControl.h" |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 31 | #include "Utils.h" |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 32 | |
Anil Admal | 3a405c5 | 2018-11-14 09:35:14 -0800 | [diff] [blame] | 33 | using ::android::hardware::Status; |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 34 | using ::android::hardware::gnss::common::Utils; |
Yu-Han Yang | 08642f9 | 2019-03-02 14:22:14 -0800 | [diff] [blame] | 35 | using ::android::hardware::gnss::measurement_corrections::V1_0::implementation:: |
| 36 | GnssMeasurementCorrections; |
Anil Admal | 4d739e7 | 2018-11-14 12:38:57 -0800 | [diff] [blame] | 37 | using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl; |
Anil Admal | 3a405c5 | 2018-11-14 09:35:14 -0800 | [diff] [blame] | 38 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 39 | namespace android { |
| 40 | namespace hardware { |
| 41 | namespace gnss { |
| 42 | namespace V2_0 { |
| 43 | namespace implementation { |
| 44 | |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 45 | using GnssSvFlags = IGnssCallback::GnssSvFlags; |
| 46 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 47 | sp<V2_0::IGnssCallback> Gnss::sGnssCallback_2_0 = nullptr; |
| 48 | sp<V1_1::IGnssCallback> Gnss::sGnssCallback_1_1 = nullptr; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 49 | |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 50 | namespace { |
| 51 | |
| 52 | V2_0::GnssLocation getMockLocationV2_0() { |
| 53 | const ElapsedRealtime timestamp = { |
| 54 | .flags = ElapsedRealtimeFlags::HAS_TIMESTAMP_NS | |
| 55 | ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS, |
| 56 | .timestampNs = static_cast<uint64_t>(::android::elapsedRealtimeNano()), |
| 57 | // This is an hardcoded value indicating a 1ms of uncertainty between the two clocks. |
| 58 | // In an actual implementation provide an estimate of the synchronization uncertainty |
| 59 | // or don't set the field. |
| 60 | .timeUncertaintyNs = 1000000}; |
| 61 | |
| 62 | V2_0::GnssLocation location = {.v1_0 = Utils::getMockLocation(), .elapsedRealtime = timestamp}; |
| 63 | return location; |
| 64 | } |
| 65 | |
| 66 | } // namespace |
| 67 | |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 68 | Gnss::Gnss() : mMinIntervalMs(1000) {} |
| 69 | |
| 70 | Gnss::~Gnss() { |
| 71 | stop(); |
| 72 | } |
| 73 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 74 | // Methods from V1_0::IGnss follow. |
| 75 | Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>&) { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 76 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 77 | return bool{}; |
| 78 | } |
| 79 | |
| 80 | Return<bool> Gnss::start() { |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 81 | if (mIsActive) { |
| 82 | ALOGW("Gnss has started. Restarting..."); |
| 83 | stop(); |
| 84 | } |
| 85 | |
| 86 | mIsActive = true; |
| 87 | mThread = std::thread([this]() { |
| 88 | while (mIsActive == true) { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 89 | const auto location = getMockLocationV2_0(); |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 90 | this->reportLocation(location); |
| 91 | |
| 92 | std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMs)); |
| 93 | } |
| 94 | }); |
| 95 | return true; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | Return<bool> Gnss::stop() { |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 99 | mIsActive = false; |
| 100 | if (mThread.joinable()) { |
| 101 | mThread.join(); |
| 102 | } |
| 103 | return true; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | Return<void> Gnss::cleanup() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 107 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 108 | return Void(); |
| 109 | } |
| 110 | |
| 111 | Return<bool> Gnss::injectTime(int64_t, int64_t, int32_t) { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 112 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 113 | return bool{}; |
| 114 | } |
| 115 | |
| 116 | Return<bool> Gnss::injectLocation(double, double, float) { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 117 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 118 | return bool{}; |
| 119 | } |
| 120 | |
| 121 | Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData) { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 122 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 123 | return Void(); |
| 124 | } |
| 125 | |
| 126 | Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode, |
| 127 | V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t, |
| 128 | uint32_t) { |
Yu-Han Yang | 99f88da | 2019-02-27 12:36:55 -0800 | [diff] [blame] | 129 | return true; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 133 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 134 | return sp<V1_0::IAGnssRil>{}; |
| 135 | } |
| 136 | |
| 137 | Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 138 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 139 | return sp<V1_0::IGnssGeofencing>{}; |
| 140 | } |
| 141 | |
| 142 | Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 143 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 144 | return sp<V1_0::IAGnss>{}; |
| 145 | } |
| 146 | |
| 147 | Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() { |
Anil Admal | 4d739e7 | 2018-11-14 12:38:57 -0800 | [diff] [blame] | 148 | // The IGnssNi.hal interface is deprecated in 2.0. |
| 149 | return nullptr; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() { |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 153 | // Not supported |
| 154 | return nullptr; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | Return<sp<V1_0::IGnssNavigationMessage>> Gnss::getExtensionGnssNavigationMessage() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 158 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 159 | return sp<V1_0::IGnssNavigationMessage>{}; |
| 160 | } |
| 161 | |
| 162 | Return<sp<V1_0::IGnssXtra>> Gnss::getExtensionXtra() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 163 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 164 | return sp<V1_0::IGnssXtra>{}; |
| 165 | } |
| 166 | |
| 167 | Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 168 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 169 | return sp<V1_0::IGnssConfiguration>{}; |
| 170 | } |
| 171 | |
| 172 | Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 173 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 174 | return sp<V1_0::IGnssDebug>{}; |
| 175 | } |
| 176 | |
| 177 | Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 178 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 179 | return sp<V1_0::IGnssBatching>{}; |
| 180 | } |
| 181 | |
| 182 | // Methods from V1_1::IGnss follow. |
| 183 | Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) { |
| 184 | ALOGD("Gnss::setCallback_1_1"); |
| 185 | if (callback == nullptr) { |
| 186 | ALOGE("%s: Null callback ignored", __func__); |
| 187 | return false; |
| 188 | } |
| 189 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 190 | sGnssCallback_1_1 = callback; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 191 | |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 192 | uint32_t capabilities = (uint32_t)V1_0::IGnssCallback::Capabilities::MEASUREMENTS; |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 193 | auto ret = sGnssCallback_1_1->gnssSetCapabilitesCb(capabilities); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 194 | if (!ret.isOk()) { |
| 195 | ALOGE("%s: Unable to invoke callback", __func__); |
| 196 | } |
| 197 | |
| 198 | V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019}; |
| 199 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 200 | ret = sGnssCallback_1_1->gnssSetSystemInfoCb(gnssInfo); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 201 | if (!ret.isOk()) { |
| 202 | ALOGE("%s: Unable to invoke callback", __func__); |
| 203 | } |
| 204 | |
| 205 | auto gnssName = "Google Mock GNSS Implementation v2.0"; |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 206 | ret = sGnssCallback_1_1->gnssNameCb(gnssName); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 207 | if (!ret.isOk()) { |
| 208 | ALOGE("%s: Unable to invoke callback", __func__); |
| 209 | } |
| 210 | |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode, |
| 215 | V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t, |
| 216 | uint32_t, bool) { |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 217 | return true; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 221 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 222 | return sp<V1_1::IGnssConfiguration>{}; |
| 223 | } |
| 224 | |
| 225 | Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() { |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 226 | ALOGD("Gnss::getExtensionGnssMeasurement_1_1"); |
| 227 | return new GnssMeasurement(); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | Return<bool> Gnss::injectBestLocation(const V1_0::GnssLocation&) { |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 231 | // TODO(b/124012850): Implement function. |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 232 | return bool{}; |
| 233 | } |
| 234 | |
| 235 | // Methods from V2_0::IGnss follow. |
Anil Admal | 4e50a4c | 2018-12-19 15:22:13 -0800 | [diff] [blame] | 236 | Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() { |
| 237 | return new GnssConfiguration{}; |
| 238 | } |
| 239 | |
Yu-Han Yang | 6999a0f | 2019-03-14 11:08:43 -0700 | [diff] [blame] | 240 | Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() { |
| 241 | // TODO(b/124012850): Implement function. |
| 242 | return sp<V2_0::IGnssDebug>{}; |
| 243 | } |
| 244 | |
Anil Admal | 3a405c5 | 2018-11-14 09:35:14 -0800 | [diff] [blame] | 245 | Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() { |
| 246 | return new AGnss{}; |
| 247 | } |
| 248 | |
Anil Admal | b02bcc1 | 2018-11-14 10:23:45 -0800 | [diff] [blame] | 249 | Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() { |
| 250 | return new AGnssRil{}; |
| 251 | } |
| 252 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 253 | Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() { |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 254 | ALOGD("Gnss::getExtensionGnssMeasurement_2_0"); |
| 255 | return new GnssMeasurement(); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 256 | } |
| 257 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 258 | Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>> |
| 259 | Gnss::getExtensionMeasurementCorrections() { |
Yu-Han Yang | 08642f9 | 2019-03-02 14:22:14 -0800 | [diff] [blame] | 260 | ALOGD("Gnss::getExtensionMeasurementCorrections"); |
| 261 | return new GnssMeasurementCorrections(); |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Anil Admal | 4d739e7 | 2018-11-14 12:38:57 -0800 | [diff] [blame] | 264 | Return<sp<visibility_control::V1_0::IGnssVisibilityControl>> Gnss::getExtensionVisibilityControl() { |
| 265 | ALOGD("Gnss::getExtensionVisibilityControl"); |
| 266 | return new GnssVisibilityControl(); |
| 267 | } |
| 268 | |
Anil Admal | 704bc61 | 2019-03-21 18:45:30 +0000 | [diff] [blame] | 269 | Return<sp<V2_0::IGnssBatching>> Gnss::getExtensionGnssBatching_2_0() { |
| 270 | return new GnssBatching(); |
| 271 | } |
| 272 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 273 | Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) { |
| 274 | ALOGD("Gnss::setCallback_2_0"); |
| 275 | if (callback == nullptr) { |
| 276 | ALOGE("%s: Null callback ignored", __func__); |
| 277 | return false; |
| 278 | } |
| 279 | |
| 280 | sGnssCallback_2_0 = callback; |
| 281 | |
Anil Admal | 86450fa | 2019-03-11 15:31:05 -0700 | [diff] [blame] | 282 | using Capabilities = V2_0::IGnssCallback::Capabilities; |
Anil Admal | f45338a | 2019-04-03 14:43:30 -0700 | [diff] [blame^] | 283 | const auto capabilities = Capabilities::MEASUREMENTS | Capabilities::MEASUREMENT_CORRECTIONS | |
| 284 | Capabilities::LOW_POWER_MODE | Capabilities::SATELLITE_BLACKLIST; |
Anil Admal | 86450fa | 2019-03-11 15:31:05 -0700 | [diff] [blame] | 285 | auto ret = sGnssCallback_2_0->gnssSetCapabilitiesCb_2_0(capabilities); |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 286 | if (!ret.isOk()) { |
| 287 | ALOGE("%s: Unable to invoke callback", __func__); |
| 288 | } |
| 289 | |
| 290 | V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019}; |
| 291 | |
| 292 | ret = sGnssCallback_2_0->gnssSetSystemInfoCb(gnssInfo); |
| 293 | if (!ret.isOk()) { |
| 294 | ALOGE("%s: Unable to invoke callback", __func__); |
| 295 | } |
| 296 | |
| 297 | auto gnssName = "Google Mock GNSS Implementation v2.0"; |
| 298 | ret = sGnssCallback_2_0->gnssNameCb(gnssName); |
| 299 | if (!ret.isOk()) { |
| 300 | ALOGE("%s: Unable to invoke callback", __func__); |
| 301 | } |
| 302 | |
| 303 | return true; |
| 304 | } |
| 305 | |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 306 | Return<void> Gnss::reportLocation(const V2_0::GnssLocation& location) const { |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 307 | std::unique_lock<std::mutex> lock(mMutex); |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 308 | if (sGnssCallback_2_0 == nullptr) { |
| 309 | ALOGE("%s: sGnssCallback 2.0 is null.", __func__); |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 310 | return Void(); |
| 311 | } |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 312 | sGnssCallback_2_0->gnssLocationCb_2_0(location); |
Yu-Han Yang | a509861 | 2019-02-08 16:22:07 -0800 | [diff] [blame] | 313 | return Void(); |
| 314 | } |
| 315 | |
Pierre Fite-Georgel | 12ac2b5 | 2019-01-17 16:56:17 -0800 | [diff] [blame] | 316 | Return<bool> Gnss::injectBestLocation_2_0(const V2_0::GnssLocation&) { |
| 317 | // TODO(b/124012850): Implement function. |
| 318 | return bool{}; |
| 319 | } |
| 320 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 321 | } // namespace implementation |
| 322 | } // namespace V2_0 |
| 323 | } // namespace gnss |
| 324 | } // namespace hardware |
| 325 | } // namespace android |