blob: 0e3cdd3a6a8716d980fe15c49b96135069a410ab [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"
Yu-Han Yang3089df32021-09-29 21:31:23 -070024#include "GnssGeofence.h"
Yu-Han Yang04832302020-11-20 09:51:18 -080025#include "GnssMeasurementInterface.h"
Yu-Han Yang10cf7362021-10-03 22:32:04 -070026#include "GnssNavigationMessageInterface.h"
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070027#include "GnssPsds.h"
28
29namespace aidl::android::hardware::gnss {
30
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070031std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr;
32
33ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) {
34 ALOGD("Gnss::setCallback");
35 if (callback == nullptr) {
36 ALOGE("%s: Null callback ignored", __func__);
37 return ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
38 }
39
40 sGnssCallback = callback;
41
Joe Huang0d203ba2020-12-07 23:57:48 +080042 int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
Shinru Han4abab502020-12-09 15:07:18 +080043 IGnssCallback::CAPABILITY_SATELLITE_PVT |
44 IGnssCallback::CAPABILITY_CORRELATION_VECTOR);
45
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070046 auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
47 if (!status.isOk()) {
48 ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__);
49 }
50
51 return ndk::ScopedAStatus::ok();
52}
53
54ndk::ScopedAStatus Gnss::close() {
55 ALOGD("Gnss::close");
56 sGnssCallback = nullptr;
57 return ndk::ScopedAStatus::ok();
58}
59
Shinru Han7f31c142021-11-05 11:56:40 +080060ndk::ScopedAStatus Gnss::getExtensionAGnss(std::shared_ptr<IAGnss>* iAGnss) {
61 ALOGD("Gnss::getExtensionAGnss");
62 *iAGnss = SharedRefBase::make<AGnss>();
63 return ndk::ScopedAStatus::ok();
64}
65
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070066ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) {
67 ALOGD("Gnss::getExtensionPsds");
68 *iGnssPsds = SharedRefBase::make<GnssPsds>();
69 return ndk::ScopedAStatus::ok();
70}
71
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070072ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration(
73 std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) {
74 ALOGD("Gnss::getExtensionGnssConfiguration");
75 if (mGnssConfiguration == nullptr) {
76 mGnssConfiguration = SharedRefBase::make<GnssConfiguration>();
77 }
78 *iGnssConfiguration = mGnssConfiguration;
79 return ndk::ScopedAStatus::ok();
80}
81
Yu-Han Yang24753612020-10-27 14:42:14 -070082ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
83 std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
84 ALOGD("Gnss::getExtensionGnssPowerIndication");
Yu-Han Yang669be842021-04-26 20:17:53 -070085 if (mGnssPowerIndication == nullptr) {
86 mGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
87 }
Yu-Han Yang24753612020-10-27 14:42:14 -070088
Yu-Han Yang669be842021-04-26 20:17:53 -070089 *iGnssPowerIndication = mGnssPowerIndication;
Yu-Han Yang24753612020-10-27 14:42:14 -070090 return ndk::ScopedAStatus::ok();
91}
92
Yu-Han Yang04832302020-11-20 09:51:18 -080093ndk::ScopedAStatus Gnss::getExtensionGnssMeasurement(
94 std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) {
95 ALOGD("Gnss::getExtensionGnssMeasurement");
96
97 *iGnssMeasurement = SharedRefBase::make<GnssMeasurementInterface>();
98 return ndk::ScopedAStatus::ok();
99}
100
Yu-Han Yang3a75dc02021-09-27 01:01:06 -0700101ndk::ScopedAStatus Gnss::getExtensionGnssBatching(std::shared_ptr<IGnssBatching>* iGnssBatching) {
102 ALOGD("Gnss::getExtensionGnssBatching");
103
104 *iGnssBatching = SharedRefBase::make<GnssBatching>();
105 return ndk::ScopedAStatus::ok();
106}
107
Yu-Han Yang3089df32021-09-29 21:31:23 -0700108ndk::ScopedAStatus Gnss::getExtensionGnssGeofence(std::shared_ptr<IGnssGeofence>* iGnssGeofence) {
109 ALOGD("Gnss::getExtensionGnssGeofence");
110
111 *iGnssGeofence = SharedRefBase::make<GnssGeofence>();
112 return ndk::ScopedAStatus::ok();
113}
114
Yu-Han Yang10cf7362021-10-03 22:32:04 -0700115ndk::ScopedAStatus Gnss::getExtensionGnssNavigationMessage(
116 std::shared_ptr<IGnssNavigationMessageInterface>* iGnssNavigationMessage) {
117 ALOGD("Gnss::getExtensionGnssNavigationMessage");
118
119 *iGnssNavigationMessage = SharedRefBase::make<GnssNavigationMessageInterface>();
120 return ndk::ScopedAStatus::ok();
121}
122
Yu-Han Yang274ea0a2020-09-09 17:25:02 -0700123} // namespace aidl::android::hardware::gnss