blob: 669372b374acd19832472addb2d96b3f86b323dc [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 Yang24753612020-10-27 14:42:14 -070022#include "GnssPowerIndication.h"
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070023#include "GnssPsds.h"
24
25namespace aidl::android::hardware::gnss {
26
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070027std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr;
28
29ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) {
30 ALOGD("Gnss::setCallback");
31 if (callback == nullptr) {
32 ALOGE("%s: Null callback ignored", __func__);
33 return ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
34 }
35
36 sGnssCallback = callback;
37
38 int capabilities = (int)IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST;
39 auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
40 if (!status.isOk()) {
41 ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__);
42 }
43
44 return ndk::ScopedAStatus::ok();
45}
46
47ndk::ScopedAStatus Gnss::close() {
48 ALOGD("Gnss::close");
49 sGnssCallback = nullptr;
50 return ndk::ScopedAStatus::ok();
51}
52
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070053ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) {
54 ALOGD("Gnss::getExtensionPsds");
55 *iGnssPsds = SharedRefBase::make<GnssPsds>();
56 return ndk::ScopedAStatus::ok();
57}
58
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070059ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration(
60 std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) {
61 ALOGD("Gnss::getExtensionGnssConfiguration");
62 if (mGnssConfiguration == nullptr) {
63 mGnssConfiguration = SharedRefBase::make<GnssConfiguration>();
64 }
65 *iGnssConfiguration = mGnssConfiguration;
66 return ndk::ScopedAStatus::ok();
67}
68
Yu-Han Yang24753612020-10-27 14:42:14 -070069ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
70 std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
71 ALOGD("Gnss::getExtensionGnssPowerIndication");
72
73 *iGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
74 return ndk::ScopedAStatus::ok();
75}
76
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070077} // namespace aidl::android::hardware::gnss