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" |
| 20 | #include <log/log.h> |
Anil Admal | 3a405c5 | 2018-11-14 09:35:14 -0800 | [diff] [blame] | 21 | #include "AGnss.h" |
Anil Admal | b02bcc1 | 2018-11-14 10:23:45 -0800 | [diff] [blame] | 22 | #include "AGnssRil.h" |
Anil Admal | 4e50a4c | 2018-12-19 15:22:13 -0800 | [diff] [blame] | 23 | #include "GnssConfiguration.h" |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 24 | #include "GnssMeasurement.h" |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 25 | |
Anil Admal | 3a405c5 | 2018-11-14 09:35:14 -0800 | [diff] [blame] | 26 | using ::android::hardware::Status; |
| 27 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 28 | namespace android { |
| 29 | namespace hardware { |
| 30 | namespace gnss { |
| 31 | namespace V2_0 { |
| 32 | namespace implementation { |
| 33 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 34 | sp<V2_0::IGnssCallback> Gnss::sGnssCallback_2_0 = nullptr; |
| 35 | sp<V1_1::IGnssCallback> Gnss::sGnssCallback_1_1 = nullptr; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 36 | |
| 37 | // Methods from V1_0::IGnss follow. |
| 38 | Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>&) { |
| 39 | // TODO implement |
| 40 | return bool{}; |
| 41 | } |
| 42 | |
| 43 | Return<bool> Gnss::start() { |
| 44 | // TODO implement |
| 45 | return bool{}; |
| 46 | } |
| 47 | |
| 48 | Return<bool> Gnss::stop() { |
| 49 | // TODO implement |
| 50 | return bool{}; |
| 51 | } |
| 52 | |
| 53 | Return<void> Gnss::cleanup() { |
| 54 | // TODO implement |
| 55 | return Void(); |
| 56 | } |
| 57 | |
| 58 | Return<bool> Gnss::injectTime(int64_t, int64_t, int32_t) { |
| 59 | // TODO implement |
| 60 | return bool{}; |
| 61 | } |
| 62 | |
| 63 | Return<bool> Gnss::injectLocation(double, double, float) { |
| 64 | // TODO implement |
| 65 | return bool{}; |
| 66 | } |
| 67 | |
| 68 | Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData) { |
| 69 | // TODO implement |
| 70 | return Void(); |
| 71 | } |
| 72 | |
| 73 | Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode, |
| 74 | V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t, |
| 75 | uint32_t) { |
| 76 | // TODO implement |
| 77 | return bool{}; |
| 78 | } |
| 79 | |
| 80 | Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() { |
| 81 | // TODO implement |
| 82 | return sp<V1_0::IAGnssRil>{}; |
| 83 | } |
| 84 | |
| 85 | Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() { |
| 86 | // TODO implement |
| 87 | return sp<V1_0::IGnssGeofencing>{}; |
| 88 | } |
| 89 | |
| 90 | Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() { |
| 91 | // TODO implement |
| 92 | return sp<V1_0::IAGnss>{}; |
| 93 | } |
| 94 | |
| 95 | Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() { |
| 96 | // TODO implement |
| 97 | return sp<V1_0::IGnssNi>{}; |
| 98 | } |
| 99 | |
| 100 | Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() { |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 101 | // Not supported |
| 102 | return nullptr; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | Return<sp<V1_0::IGnssNavigationMessage>> Gnss::getExtensionGnssNavigationMessage() { |
| 106 | // TODO implement |
| 107 | return sp<V1_0::IGnssNavigationMessage>{}; |
| 108 | } |
| 109 | |
| 110 | Return<sp<V1_0::IGnssXtra>> Gnss::getExtensionXtra() { |
| 111 | // TODO implement |
| 112 | return sp<V1_0::IGnssXtra>{}; |
| 113 | } |
| 114 | |
| 115 | Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() { |
| 116 | // TODO implement |
| 117 | return sp<V1_0::IGnssConfiguration>{}; |
| 118 | } |
| 119 | |
| 120 | Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() { |
| 121 | // TODO implement |
| 122 | return sp<V1_0::IGnssDebug>{}; |
| 123 | } |
| 124 | |
| 125 | Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() { |
| 126 | // TODO implement |
| 127 | return sp<V1_0::IGnssBatching>{}; |
| 128 | } |
| 129 | |
| 130 | // Methods from V1_1::IGnss follow. |
| 131 | Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) { |
| 132 | ALOGD("Gnss::setCallback_1_1"); |
| 133 | if (callback == nullptr) { |
| 134 | ALOGE("%s: Null callback ignored", __func__); |
| 135 | return false; |
| 136 | } |
| 137 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 138 | sGnssCallback_1_1 = callback; |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 139 | |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 140 | uint32_t capabilities = (uint32_t)V1_0::IGnssCallback::Capabilities::MEASUREMENTS; |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 141 | auto ret = sGnssCallback_1_1->gnssSetCapabilitesCb(capabilities); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 142 | if (!ret.isOk()) { |
| 143 | ALOGE("%s: Unable to invoke callback", __func__); |
| 144 | } |
| 145 | |
| 146 | V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019}; |
| 147 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 148 | ret = sGnssCallback_1_1->gnssSetSystemInfoCb(gnssInfo); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 149 | if (!ret.isOk()) { |
| 150 | ALOGE("%s: Unable to invoke callback", __func__); |
| 151 | } |
| 152 | |
| 153 | auto gnssName = "Google Mock GNSS Implementation v2.0"; |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 154 | ret = sGnssCallback_1_1->gnssNameCb(gnssName); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 155 | if (!ret.isOk()) { |
| 156 | ALOGE("%s: Unable to invoke callback", __func__); |
| 157 | } |
| 158 | |
| 159 | return true; |
| 160 | } |
| 161 | |
| 162 | Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode, |
| 163 | V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t, |
| 164 | uint32_t, bool) { |
| 165 | // TODO implement |
| 166 | return bool{}; |
| 167 | } |
| 168 | |
| 169 | Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() { |
| 170 | // TODO implement |
| 171 | return sp<V1_1::IGnssConfiguration>{}; |
| 172 | } |
| 173 | |
| 174 | Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() { |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 175 | ALOGD("Gnss::getExtensionGnssMeasurement_1_1"); |
| 176 | return new GnssMeasurement(); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | Return<bool> Gnss::injectBestLocation(const V1_0::GnssLocation&) { |
| 180 | // TODO implement |
| 181 | return bool{}; |
| 182 | } |
| 183 | |
| 184 | // Methods from V2_0::IGnss follow. |
Anil Admal | 4e50a4c | 2018-12-19 15:22:13 -0800 | [diff] [blame] | 185 | Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() { |
| 186 | return new GnssConfiguration{}; |
| 187 | } |
| 188 | |
Anil Admal | 3a405c5 | 2018-11-14 09:35:14 -0800 | [diff] [blame] | 189 | Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() { |
| 190 | return new AGnss{}; |
| 191 | } |
| 192 | |
Anil Admal | b02bcc1 | 2018-11-14 10:23:45 -0800 | [diff] [blame] | 193 | Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() { |
| 194 | return new AGnssRil{}; |
| 195 | } |
| 196 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 197 | Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() { |
Yu-Han Yang | 030d033 | 2018-12-09 10:47:42 -0800 | [diff] [blame] | 198 | ALOGD("Gnss::getExtensionGnssMeasurement_2_0"); |
| 199 | return new GnssMeasurement(); |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 200 | } |
| 201 | |
gomo | 1da4b5c | 2018-12-02 02:49:10 -0800 | [diff] [blame] | 202 | Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>> |
| 203 | Gnss::getExtensionMeasurementCorrections() { |
| 204 | // TODO implement |
| 205 | return sp<measurement_corrections::V1_0::IMeasurementCorrections>{}; |
| 206 | } |
| 207 | |
| 208 | Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) { |
| 209 | ALOGD("Gnss::setCallback_2_0"); |
| 210 | if (callback == nullptr) { |
| 211 | ALOGE("%s: Null callback ignored", __func__); |
| 212 | return false; |
| 213 | } |
| 214 | |
| 215 | sGnssCallback_2_0 = callback; |
| 216 | |
| 217 | uint32_t capabilities = 0x0; |
| 218 | auto ret = sGnssCallback_2_0->gnssSetCapabilitesCb(capabilities); |
| 219 | if (!ret.isOk()) { |
| 220 | ALOGE("%s: Unable to invoke callback", __func__); |
| 221 | } |
| 222 | |
| 223 | V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019}; |
| 224 | |
| 225 | ret = sGnssCallback_2_0->gnssSetSystemInfoCb(gnssInfo); |
| 226 | if (!ret.isOk()) { |
| 227 | ALOGE("%s: Unable to invoke callback", __func__); |
| 228 | } |
| 229 | |
| 230 | auto gnssName = "Google Mock GNSS Implementation v2.0"; |
| 231 | ret = sGnssCallback_2_0->gnssNameCb(gnssName); |
| 232 | if (!ret.isOk()) { |
| 233 | ALOGE("%s: Unable to invoke callback", __func__); |
| 234 | } |
| 235 | |
| 236 | return true; |
| 237 | } |
| 238 | |
Yu-Han Yang | 9c6c20b | 2018-11-06 14:12:49 -0800 | [diff] [blame] | 239 | } // namespace implementation |
| 240 | } // namespace V2_0 |
| 241 | } // namespace gnss |
| 242 | } // namespace hardware |
| 243 | } // namespace android |