blob: 435afa35763b3eb2042a4908da6d698dfcec4816 [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
Joe Huang0d203ba2020-12-07 23:57:48 +080039 int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
Shinru Han4abab502020-12-09 15:07:18 +080040 IGnssCallback::CAPABILITY_SATELLITE_PVT |
41 IGnssCallback::CAPABILITY_CORRELATION_VECTOR);
42
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070043 auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
44 if (!status.isOk()) {
45 ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__);
46 }
47
48 return ndk::ScopedAStatus::ok();
49}
50
51ndk::ScopedAStatus Gnss::close() {
52 ALOGD("Gnss::close");
53 sGnssCallback = nullptr;
54 return ndk::ScopedAStatus::ok();
55}
56
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070057ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) {
58 ALOGD("Gnss::getExtensionPsds");
59 *iGnssPsds = SharedRefBase::make<GnssPsds>();
60 return ndk::ScopedAStatus::ok();
61}
62
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070063ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration(
64 std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) {
65 ALOGD("Gnss::getExtensionGnssConfiguration");
66 if (mGnssConfiguration == nullptr) {
67 mGnssConfiguration = SharedRefBase::make<GnssConfiguration>();
68 }
69 *iGnssConfiguration = mGnssConfiguration;
70 return ndk::ScopedAStatus::ok();
71}
72
Yu-Han Yang24753612020-10-27 14:42:14 -070073ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
74 std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
75 ALOGD("Gnss::getExtensionGnssPowerIndication");
76
77 *iGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
78 return ndk::ScopedAStatus::ok();
79}
80
Yu-Han Yang04832302020-11-20 09:51:18 -080081ndk::ScopedAStatus Gnss::getExtensionGnssMeasurement(
82 std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) {
83 ALOGD("Gnss::getExtensionGnssMeasurement");
84
85 *iGnssMeasurement = SharedRefBase::make<GnssMeasurementInterface>();
86 return ndk::ScopedAStatus::ok();
87}
88
Yu-Han Yang274ea0a2020-09-09 17:25:02 -070089} // namespace aidl::android::hardware::gnss