Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 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 | #define LOG_TAG "GnssAidl" |
| 18 | |
| 19 | #include "Gnss.h" |
| 20 | #include <log/log.h> |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 21 | #include "GnssConfiguration.h" |
Yu-Han Yang | 0483230 | 2020-11-20 09:51:18 -0800 | [diff] [blame] | 22 | #include "GnssMeasurementInterface.h" |
Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 23 | #include "GnssPsds.h" |
| 24 | |
| 25 | namespace aidl::android::hardware::gnss { |
| 26 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 27 | std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr; |
| 28 | |
| 29 | ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) { |
| 30 | ALOGD("Gnss::setCallback"); |
| 31 | if (callback == nullptr) { |
| 32 | ALOGE("%s: Null callback ignored", __func__); |
| 33 | return ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION); |
| 34 | } |
| 35 | |
| 36 | sGnssCallback = callback; |
| 37 | |
Joe Huang | 0d203ba | 2020-12-07 23:57:48 +0800 | [diff] [blame] | 38 | int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST | |
Shinru Han | 4abab50 | 2020-12-09 15:07:18 +0800 | [diff] [blame] | 39 | IGnssCallback::CAPABILITY_SATELLITE_PVT | |
| 40 | IGnssCallback::CAPABILITY_CORRELATION_VECTOR); |
| 41 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 42 | auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities); |
| 43 | if (!status.isOk()) { |
| 44 | ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__); |
| 45 | } |
| 46 | |
| 47 | return ndk::ScopedAStatus::ok(); |
| 48 | } |
| 49 | |
| 50 | ndk::ScopedAStatus Gnss::close() { |
| 51 | ALOGD("Gnss::close"); |
| 52 | sGnssCallback = nullptr; |
| 53 | return ndk::ScopedAStatus::ok(); |
| 54 | } |
| 55 | |
Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 56 | ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) { |
| 57 | ALOGD("Gnss::getExtensionPsds"); |
| 58 | *iGnssPsds = SharedRefBase::make<GnssPsds>(); |
| 59 | return ndk::ScopedAStatus::ok(); |
| 60 | } |
| 61 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 62 | ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration( |
| 63 | std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) { |
| 64 | ALOGD("Gnss::getExtensionGnssConfiguration"); |
| 65 | if (mGnssConfiguration == nullptr) { |
| 66 | mGnssConfiguration = SharedRefBase::make<GnssConfiguration>(); |
| 67 | } |
| 68 | *iGnssConfiguration = mGnssConfiguration; |
| 69 | return ndk::ScopedAStatus::ok(); |
| 70 | } |
| 71 | |
Yu-Han Yang | 2475361 | 2020-10-27 14:42:14 -0700 | [diff] [blame] | 72 | ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication( |
| 73 | std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) { |
| 74 | ALOGD("Gnss::getExtensionGnssPowerIndication"); |
Yu-Han Yang | 669be84 | 2021-04-26 20:17:53 -0700 | [diff] [blame] | 75 | if (mGnssPowerIndication == nullptr) { |
| 76 | mGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>(); |
| 77 | } |
Yu-Han Yang | 2475361 | 2020-10-27 14:42:14 -0700 | [diff] [blame] | 78 | |
Yu-Han Yang | 669be84 | 2021-04-26 20:17:53 -0700 | [diff] [blame] | 79 | *iGnssPowerIndication = mGnssPowerIndication; |
Yu-Han Yang | 2475361 | 2020-10-27 14:42:14 -0700 | [diff] [blame] | 80 | return ndk::ScopedAStatus::ok(); |
| 81 | } |
| 82 | |
Yu-Han Yang | 0483230 | 2020-11-20 09:51:18 -0800 | [diff] [blame] | 83 | ndk::ScopedAStatus Gnss::getExtensionGnssMeasurement( |
| 84 | std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) { |
| 85 | ALOGD("Gnss::getExtensionGnssMeasurement"); |
| 86 | |
| 87 | *iGnssMeasurement = SharedRefBase::make<GnssMeasurementInterface>(); |
| 88 | return ndk::ScopedAStatus::ok(); |
| 89 | } |
| 90 | |
Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 91 | } // namespace aidl::android::hardware::gnss |