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