blob: 03d9e31f30371906a1881e970ce01e3094e54df7 [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 Yang274ea0a2020-09-09 17:25:02 -070025#include "GnssPsds.h"
26
27namespace aidl::android::hardware::gnss {
28
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070029std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr;
30
31ndk::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 Huang0d203ba2020-12-07 23:57:48 +080040 int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
Shinru Han4abab502020-12-09 15:07:18 +080041 IGnssCallback::CAPABILITY_SATELLITE_PVT |
42 IGnssCallback::CAPABILITY_CORRELATION_VECTOR);
43
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070044 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
52ndk::ScopedAStatus Gnss::close() {
53 ALOGD("Gnss::close");
54 sGnssCallback = nullptr;
55 return ndk::ScopedAStatus::ok();
56}
57
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070058ndk::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 Yang1e1a6762020-09-30 17:01:53 -070064ndk::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 Yang24753612020-10-27 14:42:14 -070074ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
75 std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
76 ALOGD("Gnss::getExtensionGnssPowerIndication");
Yu-Han Yang669be842021-04-26 20:17:53 -070077 if (mGnssPowerIndication == nullptr) {
78 mGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
79 }
Yu-Han Yang24753612020-10-27 14:42:14 -070080
Yu-Han Yang669be842021-04-26 20:17:53 -070081 *iGnssPowerIndication = mGnssPowerIndication;
Yu-Han Yang24753612020-10-27 14:42:14 -070082 return ndk::ScopedAStatus::ok();
83}
84
Yu-Han Yang04832302020-11-20 09:51:18 -080085ndk::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 Yang3a75dc02021-09-27 01:01:06 -070093ndk::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 Yang3089df32021-09-29 21:31:23 -0700100ndk::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 Yang274ea0a2020-09-09 17:25:02 -0700107} // namespace aidl::android::hardware::gnss