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" |
| 20 | //#include <android/hardware/gnss/1.0/IGnssCallback.h> |
| 21 | |
| 22 | namespace aidl::android::hardware::gnss { |
| 23 | |
| 24 | namespace V1_0 = ::android::hardware::gnss::V1_0; |
| 25 | |
| 26 | GnssHidlHal::GnssHidlHal(const std::shared_ptr<Gnss>& gnssAidl) : mGnssAidl(gnssAidl) { |
| 27 | Gnss* iGnss = mGnssAidl.get(); |
| 28 | std::shared_ptr<IGnssConfiguration> iGnssConfiguration; |
| 29 | auto status = iGnss->getExtensionGnssConfiguration(&iGnssConfiguration); |
| 30 | if (!status.isOk()) { |
| 31 | ALOGE("Failed to getExtensionGnssConfiguration."); |
| 32 | } else { |
| 33 | mGnssConfigurationAidl = iGnss->mGnssConfiguration; |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | hidl_vec<GnssSvInfo> GnssHidlHal::filterBlocklistedSatellitesV2_1( |
| 38 | hidl_vec<GnssSvInfo> gnssSvInfoList) { |
| 39 | ALOGD("filterBlocklistSatellitesV2_1 - overridden by GnssHidlHal class"); |
| 40 | if (mGnssConfigurationAidl == nullptr) { |
| 41 | ALOGE("Handle to AIDL GnssConfiguration is not available."); |
| 42 | return gnssSvInfoList; |
| 43 | } |
| 44 | for (uint32_t i = 0; i < gnssSvInfoList.size(); i++) { |
| 45 | if (mGnssConfigurationAidl->isBlocklistedV2_1(gnssSvInfoList[i])) { |
| 46 | ALOGD("Blocklisted constellation: %d, svid: %d", |
| 47 | (int)gnssSvInfoList[i].v2_0.constellation, gnssSvInfoList[i].v2_0.v1_0.svid); |
| 48 | gnssSvInfoList[i].v2_0.v1_0.svFlag &= |
| 49 | ~static_cast<uint8_t>(V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX); |
| 50 | } |
| 51 | } |
| 52 | return gnssSvInfoList; |
| 53 | } |
| 54 | |
| 55 | } // namespace aidl::android::hardware::gnss |