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 | 2475361 | 2020-10-27 14:42:14 -0700 | [diff] [blame] | 22 | #include "GnssPowerIndication.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 | |
| 38 | int capabilities = (int)IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST; |
| 39 | auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities); |
| 40 | if (!status.isOk()) { |
| 41 | ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__); |
| 42 | } |
| 43 | |
| 44 | return ndk::ScopedAStatus::ok(); |
| 45 | } |
| 46 | |
| 47 | ndk::ScopedAStatus Gnss::close() { |
| 48 | ALOGD("Gnss::close"); |
| 49 | sGnssCallback = nullptr; |
| 50 | return ndk::ScopedAStatus::ok(); |
| 51 | } |
| 52 | |
Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 53 | ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) { |
| 54 | ALOGD("Gnss::getExtensionPsds"); |
| 55 | *iGnssPsds = SharedRefBase::make<GnssPsds>(); |
| 56 | return ndk::ScopedAStatus::ok(); |
| 57 | } |
| 58 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 59 | ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration( |
| 60 | std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) { |
| 61 | ALOGD("Gnss::getExtensionGnssConfiguration"); |
| 62 | if (mGnssConfiguration == nullptr) { |
| 63 | mGnssConfiguration = SharedRefBase::make<GnssConfiguration>(); |
| 64 | } |
| 65 | *iGnssConfiguration = mGnssConfiguration; |
| 66 | return ndk::ScopedAStatus::ok(); |
| 67 | } |
| 68 | |
Yu-Han Yang | 2475361 | 2020-10-27 14:42:14 -0700 | [diff] [blame] | 69 | ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication( |
| 70 | std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) { |
| 71 | ALOGD("Gnss::getExtensionGnssPowerIndication"); |
| 72 | |
| 73 | *iGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>(); |
| 74 | return ndk::ScopedAStatus::ok(); |
| 75 | } |
| 76 | |
Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 77 | } // namespace aidl::android::hardware::gnss |