blob: 02bad6031dc014aae381d43e3e0c74f07629d1f1 [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 Yang1e1a6762020-09-30 17:01:53 -070021#include "GnssConfiguration.h"
Yu-Han Yang04832302020-11-20 09:51:18 -080022#include "GnssMeasurementInterface.h"
Yu-Han Yang24753612020-10-27 14:42:14 -070023#include "GnssPowerIndication.h"
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070024#include "GnssPsds.h"
25
26namespace aidl::android::hardware::gnss {
27
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070028std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr;
29
30ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) {
31 ALOGD("Gnss::setCallback");
32 if (callback == nullptr) {
33 ALOGE("%s: Null callback ignored", __func__);
34 return ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
35 }
36
37 sGnssCallback = callback;
38
39 int capabilities = (int)IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST;
40 auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
41 if (!status.isOk()) {
42 ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__);
43 }
44
45 return ndk::ScopedAStatus::ok();
46}
47
48ndk::ScopedAStatus Gnss::close() {
49 ALOGD("Gnss::close");
50 sGnssCallback = nullptr;
51 return ndk::ScopedAStatus::ok();
52}
53
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070054ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) {
55 ALOGD("Gnss::getExtensionPsds");
56 *iGnssPsds = SharedRefBase::make<GnssPsds>();
57 return ndk::ScopedAStatus::ok();
58}
59
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070060ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration(
61 std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) {
62 ALOGD("Gnss::getExtensionGnssConfiguration");
63 if (mGnssConfiguration == nullptr) {
64 mGnssConfiguration = SharedRefBase::make<GnssConfiguration>();
65 }
66 *iGnssConfiguration = mGnssConfiguration;
67 return ndk::ScopedAStatus::ok();
68}
69
Yu-Han Yang24753612020-10-27 14:42:14 -070070ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
71 std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
72 ALOGD("Gnss::getExtensionGnssPowerIndication");
73
74 *iGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
75 return ndk::ScopedAStatus::ok();
76}
77
Yu-Han Yang04832302020-11-20 09:51:18 -080078ndk::ScopedAStatus Gnss::getExtensionGnssMeasurement(
79 std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) {
80 ALOGD("Gnss::getExtensionGnssMeasurement");
81
82 *iGnssMeasurement = SharedRefBase::make<GnssMeasurementInterface>();
83 return ndk::ScopedAStatus::ok();
84}
85
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070086} // namespace aidl::android::hardware::gnss