blob: 263715c47adf9dc00fb27bd8f2b6795842bcd735 [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 Yang669be842021-04-26 20:17:53 -070046 ALOGD("GnssHidlHal::filterBlocklistSatellitesV2_1");
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070047 if (mGnssConfigurationAidl == nullptr) {
48 ALOGE("Handle to AIDL GnssConfiguration is not available.");
49 return gnssSvInfoList;
50 }
51 for (uint32_t i = 0; i < gnssSvInfoList.size(); i++) {
52 if (mGnssConfigurationAidl->isBlocklistedV2_1(gnssSvInfoList[i])) {
53 ALOGD("Blocklisted constellation: %d, svid: %d",
54 (int)gnssSvInfoList[i].v2_0.constellation, gnssSvInfoList[i].v2_0.v1_0.svid);
Yu-Han Yang04832302020-11-20 09:51:18 -080055 gnssSvInfoList[i].v2_0.v1_0.svFlag &= ~static_cast<uint8_t>(
56 ::android::hardware::gnss::V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX);
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070057 }
58 }
59 return gnssSvInfoList;
60}
61
Yu-Han Yang669be842021-04-26 20:17:53 -070062void GnssHidlHal::notePowerConsumption() {
63 mGnssPowerIndicationAidl->notePowerConsumption();
64}
65
Yu-Han Yang1e1a6762020-09-30 17:01:53 -070066} // namespace aidl::android::hardware::gnss