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 | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 22 | #include "GnssPsds.h" |
| 23 | |
| 24 | namespace aidl::android::hardware::gnss { |
| 25 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 26 | std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr; |
| 27 | |
| 28 | ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) { |
| 29 | ALOGD("Gnss::setCallback"); |
| 30 | if (callback == nullptr) { |
| 31 | ALOGE("%s: Null callback ignored", __func__); |
| 32 | return ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION); |
| 33 | } |
| 34 | |
| 35 | sGnssCallback = callback; |
| 36 | |
| 37 | int capabilities = (int)IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST; |
| 38 | auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities); |
| 39 | if (!status.isOk()) { |
| 40 | ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__); |
| 41 | } |
| 42 | |
| 43 | return ndk::ScopedAStatus::ok(); |
| 44 | } |
| 45 | |
| 46 | ndk::ScopedAStatus Gnss::close() { |
| 47 | ALOGD("Gnss::close"); |
| 48 | sGnssCallback = nullptr; |
| 49 | return ndk::ScopedAStatus::ok(); |
| 50 | } |
| 51 | |
Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 52 | ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) { |
| 53 | ALOGD("Gnss::getExtensionPsds"); |
| 54 | *iGnssPsds = SharedRefBase::make<GnssPsds>(); |
| 55 | return ndk::ScopedAStatus::ok(); |
| 56 | } |
| 57 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 58 | ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration( |
| 59 | std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) { |
| 60 | ALOGD("Gnss::getExtensionGnssConfiguration"); |
| 61 | if (mGnssConfiguration == nullptr) { |
| 62 | mGnssConfiguration = SharedRefBase::make<GnssConfiguration>(); |
| 63 | } |
| 64 | *iGnssConfiguration = mGnssConfiguration; |
| 65 | return ndk::ScopedAStatus::ok(); |
| 66 | } |
| 67 | |
Yu-Han Yang | 274ea0a | 2020-09-09 17:25:02 -0700 | [diff] [blame] | 68 | } // namespace aidl::android::hardware::gnss |