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