blob: 10b0106f327fecf5ddc20a6fa9db6b1bf43e2a29 [file] [log] [blame]
Yu-Han Yang1e1a6762020-09-30 17:01:53 -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 "GnssHidlHal"
18
19#include "GnssHidlHal.h"
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070020
21namespace aidl::android::hardware::gnss {
22
Yu-Han Yang04832302020-11-20 09:51:18 -080023using GnssSvInfo = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo;
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070024
25GnssHidlHal::GnssHidlHal(const std::shared_ptr<Gnss>& gnssAidl) : mGnssAidl(gnssAidl) {
26 Gnss* iGnss = mGnssAidl.get();
27 std::shared_ptr<IGnssConfiguration> iGnssConfiguration;
28 auto status = iGnss->getExtensionGnssConfiguration(&iGnssConfiguration);
29 if (!status.isOk()) {
30 ALOGE("Failed to getExtensionGnssConfiguration.");
31 } else {
32 mGnssConfigurationAidl = iGnss->mGnssConfiguration;
33 }
Yu-Han Yang669be842021-04-26 20:17:53 -070034
35 std::shared_ptr<IGnssPowerIndication> iGnssPowerIndication;
36 status = iGnss->getExtensionGnssPowerIndication(&iGnssPowerIndication);
37 if (!status.isOk()) {
38 ALOGE("Failed to getExtensionGnssPowerIndication.");
39 } else {
40 mGnssPowerIndicationAidl = iGnss->mGnssPowerIndication;
41 }
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070042};
43
44hidl_vec<GnssSvInfo> GnssHidlHal::filterBlocklistedSatellitesV2_1(
45 hidl_vec<GnssSvInfo> gnssSvInfoList) {
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070046 if (mGnssConfigurationAidl == nullptr) {
47 ALOGE("Handle to AIDL GnssConfiguration is not available.");
48 return gnssSvInfoList;
49 }
50 for (uint32_t i = 0; i < gnssSvInfoList.size(); i++) {
51 if (mGnssConfigurationAidl->isBlocklistedV2_1(gnssSvInfoList[i])) {
52 ALOGD("Blocklisted constellation: %d, svid: %d",
53 (int)gnssSvInfoList[i].v2_0.constellation, gnssSvInfoList[i].v2_0.v1_0.svid);
Yu-Han Yang04832302020-11-20 09:51:18 -080054 gnssSvInfoList[i].v2_0.v1_0.svFlag &= ~static_cast<uint8_t>(
55 ::android::hardware::gnss::V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX);
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070056 }
57 }
58 return gnssSvInfoList;
59}
60
Yu-Han Yang669be842021-04-26 20:17:53 -070061void GnssHidlHal::notePowerConsumption() {
62 mGnssPowerIndicationAidl->notePowerConsumption();
63}
64
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070065} // namespace aidl::android::hardware::gnss