blob: 45d6b1d2f4a28e39bee5b1025c588fdaad963598 [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>
Shinru Han7f31c142021-11-05 11:56:40 +080021#include "AGnss.h"
Yu-Han Yang3a75dc02021-09-27 01:01:06 -070022#include "GnssBatching.h"
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070023#include "GnssConfiguration.h"
Joe Huang202b02d2021-11-16 23:09:11 +080024#include "GnssDebug.h"
Yu-Han Yang3089df32021-09-29 21:31:23 -070025#include "GnssGeofence.h"
Yu-Han Yang04832302020-11-20 09:51:18 -080026#include "GnssMeasurementInterface.h"
Yu-Han Yang10cf7362021-10-03 22:32:04 -070027#include "GnssNavigationMessageInterface.h"
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070028#include "GnssPsds.h"
29
30namespace aidl::android::hardware::gnss {
31
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070032std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr;
33
34ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) {
35 ALOGD("Gnss::setCallback");
36 if (callback == nullptr) {
37 ALOGE("%s: Null callback ignored", __func__);
38 return ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
39 }
40
41 sGnssCallback = callback;
42
Joe Huang0d203ba2020-12-07 23:57:48 +080043 int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
Shinru Han4abab502020-12-09 15:07:18 +080044 IGnssCallback::CAPABILITY_SATELLITE_PVT |
45 IGnssCallback::CAPABILITY_CORRELATION_VECTOR);
46
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070047 auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
48 if (!status.isOk()) {
49 ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__);
50 }
51
52 return ndk::ScopedAStatus::ok();
53}
54
55ndk::ScopedAStatus Gnss::close() {
56 ALOGD("Gnss::close");
57 sGnssCallback = nullptr;
58 return ndk::ScopedAStatus::ok();
59}
60
Shinru Han7f31c142021-11-05 11:56:40 +080061ndk::ScopedAStatus Gnss::getExtensionAGnss(std::shared_ptr<IAGnss>* iAGnss) {
62 ALOGD("Gnss::getExtensionAGnss");
63 *iAGnss = SharedRefBase::make<AGnss>();
64 return ndk::ScopedAStatus::ok();
65}
66
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070067ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) {
68 ALOGD("Gnss::getExtensionPsds");
69 *iGnssPsds = SharedRefBase::make<GnssPsds>();
70 return ndk::ScopedAStatus::ok();
71}
72
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070073ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration(
74 std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) {
75 ALOGD("Gnss::getExtensionGnssConfiguration");
76 if (mGnssConfiguration == nullptr) {
77 mGnssConfiguration = SharedRefBase::make<GnssConfiguration>();
78 }
79 *iGnssConfiguration = mGnssConfiguration;
80 return ndk::ScopedAStatus::ok();
81}
82
Yu-Han Yang24753612020-10-27 14:42:14 -070083ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
84 std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
85 ALOGD("Gnss::getExtensionGnssPowerIndication");
Yu-Han Yang669be842021-04-26 20:17:53 -070086 if (mGnssPowerIndication == nullptr) {
87 mGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
88 }
Yu-Han Yang24753612020-10-27 14:42:14 -070089
Yu-Han Yang669be842021-04-26 20:17:53 -070090 *iGnssPowerIndication = mGnssPowerIndication;
Yu-Han Yang24753612020-10-27 14:42:14 -070091 return ndk::ScopedAStatus::ok();
92}
93
Yu-Han Yang04832302020-11-20 09:51:18 -080094ndk::ScopedAStatus Gnss::getExtensionGnssMeasurement(
95 std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) {
96 ALOGD("Gnss::getExtensionGnssMeasurement");
97
98 *iGnssMeasurement = SharedRefBase::make<GnssMeasurementInterface>();
99 return ndk::ScopedAStatus::ok();
100}
101
Yu-Han Yang3a75dc02021-09-27 01:01:06 -0700102ndk::ScopedAStatus Gnss::getExtensionGnssBatching(std::shared_ptr<IGnssBatching>* iGnssBatching) {
103 ALOGD("Gnss::getExtensionGnssBatching");
104
105 *iGnssBatching = SharedRefBase::make<GnssBatching>();
106 return ndk::ScopedAStatus::ok();
107}
108
Yu-Han Yang3089df32021-09-29 21:31:23 -0700109ndk::ScopedAStatus Gnss::getExtensionGnssGeofence(std::shared_ptr<IGnssGeofence>* iGnssGeofence) {
110 ALOGD("Gnss::getExtensionGnssGeofence");
111
112 *iGnssGeofence = SharedRefBase::make<GnssGeofence>();
113 return ndk::ScopedAStatus::ok();
114}
115
Yu-Han Yang10cf7362021-10-03 22:32:04 -0700116ndk::ScopedAStatus Gnss::getExtensionGnssNavigationMessage(
117 std::shared_ptr<IGnssNavigationMessageInterface>* iGnssNavigationMessage) {
118 ALOGD("Gnss::getExtensionGnssNavigationMessage");
119
120 *iGnssNavigationMessage = SharedRefBase::make<GnssNavigationMessageInterface>();
121 return ndk::ScopedAStatus::ok();
122}
123
Joe Huang202b02d2021-11-16 23:09:11 +0800124ndk::ScopedAStatus Gnss::getExtensionGnssDebug(std::shared_ptr<IGnssDebug>* iGnssDebug) {
125 ALOGD("Gnss::getExtensionGnssDebug");
126
127 *iGnssDebug = SharedRefBase::make<GnssDebug>();
128 return ndk::ScopedAStatus::ok();
129}
130
Yu-Han Yang274ea0a2020-09-09 17:25:02 -0700131} // namespace aidl::android::hardware::gnss