blob: b4d92fd62fbae852f65f464b322b3ce496257ee5 [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 Yang274ea0a2020-09-09 17:25:02 -070022#include "GnssPsds.h"
23
24namespace aidl::android::hardware::gnss {
25
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070026std::shared_ptr<IGnssCallback> Gnss::sGnssCallback = nullptr;
27
28ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) {
29 ALOGD("Gnss::setCallback");
30 if (callback == nullptr) {
31 ALOGE("%s: Null callback ignored", __func__);
32 return ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
33 }
34
35 sGnssCallback = callback;
36
37 int capabilities = (int)IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST;
38 auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
39 if (!status.isOk()) {
40 ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__);
41 }
42
43 return ndk::ScopedAStatus::ok();
44}
45
46ndk::ScopedAStatus Gnss::close() {
47 ALOGD("Gnss::close");
48 sGnssCallback = nullptr;
49 return ndk::ScopedAStatus::ok();
50}
51
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070052ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) {
53 ALOGD("Gnss::getExtensionPsds");
54 *iGnssPsds = SharedRefBase::make<GnssPsds>();
55 return ndk::ScopedAStatus::ok();
56}
57
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070058ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration(
59 std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) {
60 ALOGD("Gnss::getExtensionGnssConfiguration");
61 if (mGnssConfiguration == nullptr) {
62 mGnssConfiguration = SharedRefBase::make<GnssConfiguration>();
63 }
64 *iGnssConfiguration = mGnssConfiguration;
65 return ndk::ScopedAStatus::ok();
66}
67
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070068} // namespace aidl::android::hardware::gnss