Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 1 | /* |
| 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 Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 20 | |
| 21 | namespace aidl::android::hardware::gnss { |
| 22 | |
Yu-Han Yang | 0483230 | 2020-11-20 09:51:18 -0800 | [diff] [blame] | 23 | using GnssSvInfo = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo; |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 24 | |
| 25 | GnssHidlHal::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 Yang | 669be84 | 2021-04-26 20:17:53 -0700 | [diff] [blame] | 34 | |
| 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 Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | hidl_vec<GnssSvInfo> GnssHidlHal::filterBlocklistedSatellitesV2_1( |
| 45 | hidl_vec<GnssSvInfo> gnssSvInfoList) { |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 46 | 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 Yang | 0483230 | 2020-11-20 09:51:18 -0800 | [diff] [blame] | 54 | gnssSvInfoList[i].v2_0.v1_0.svFlag &= ~static_cast<uint8_t>( |
| 55 | ::android::hardware::gnss::V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX); |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 56 | } |
| 57 | } |
| 58 | return gnssSvInfoList; |
| 59 | } |
| 60 | |
Yu-Han Yang | 669be84 | 2021-04-26 20:17:53 -0700 | [diff] [blame] | 61 | void GnssHidlHal::notePowerConsumption() { |
| 62 | mGnssPowerIndicationAidl->notePowerConsumption(); |
| 63 | } |
| 64 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 65 | } // namespace aidl::android::hardware::gnss |