blob: 8d58a207541597378ddd75cfc47cdbaad5846fa9 [file] [log] [blame]
Yu-Han Yang274ea0a2020-09-09 17:25:02 -07001/*
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 Yang3a75dc02021-09-27 01:01:06 -070021#include "GnssBatching.h"
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070022#include "GnssConfiguration.h"
Yu-Han Yang3089df32021-09-29 21:31:23 -070023#include "GnssGeofence.h"
Yu-Han Yang04832302020-11-20 09:51:18 -080024#include "GnssMeasurementInterface.h"
Yu-Han Yang10cf7362021-10-03 22:32:04 -070025#include "GnssNavigationMessageInterface.h"
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070026#include "GnssPsds.h"
27
28namespace aidl::android::hardware::gnss {
29
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070030std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr;
31
32ndk::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 Huang0d203ba2020-12-07 23:57:48 +080041 int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
Shinru Han4abab502020-12-09 15:07:18 +080042 IGnssCallback::CAPABILITY_SATELLITE_PVT |
43 IGnssCallback::CAPABILITY_CORRELATION_VECTOR);
44
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070045 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
53ndk::ScopedAStatus Gnss::close() {
54 ALOGD("Gnss::close");
55 sGnssCallback = nullptr;
56 return ndk::ScopedAStatus::ok();
57}
58
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070059ndk::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 Yang1e1a6762020-09-30 17:01:53 -070065ndk::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 Yang24753612020-10-27 14:42:14 -070075ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
76 std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
77 ALOGD("Gnss::getExtensionGnssPowerIndication");
Yu-Han Yang669be842021-04-26 20:17:53 -070078 if (mGnssPowerIndication == nullptr) {
79 mGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
80 }
Yu-Han Yang24753612020-10-27 14:42:14 -070081
Yu-Han Yang669be842021-04-26 20:17:53 -070082 *iGnssPowerIndication = mGnssPowerIndication;
Yu-Han Yang24753612020-10-27 14:42:14 -070083 return ndk::ScopedAStatus::ok();
84}
85
Yu-Han Yang04832302020-11-20 09:51:18 -080086ndk::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 Yang3a75dc02021-09-27 01:01:06 -070094ndk::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 Yang3089df32021-09-29 21:31:23 -0700101ndk::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 Yang10cf7362021-10-03 22:32:04 -0700108ndk::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 Yang274ea0a2020-09-09 17:25:02 -0700116} // namespace aidl::android::hardware::gnss