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