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