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 21 namespace aidl::android::hardware::gnss { 22 23 using GnssSvInfo = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo; 24 GnssHidlHal(const std::shared_ptr<Gnss> & gnssAidl)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 } 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 } 42 }; 43 filterBlocklistedSatellitesV2_1(hidl_vec<GnssSvInfo> gnssSvInfoList)44hidl_vec<GnssSvInfo> GnssHidlHal::filterBlocklistedSatellitesV2_1( 45 hidl_vec<GnssSvInfo> gnssSvInfoList) { 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); 54 gnssSvInfoList[i].v2_0.v1_0.svFlag &= ~static_cast<uint8_t>( 55 ::android::hardware::gnss::V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX); 56 } 57 } 58 return gnssSvInfoList; 59 } 60 notePowerConsumption()61void GnssHidlHal::notePowerConsumption() { 62 mGnssPowerIndicationAidl->notePowerConsumption(); 63 } 64 65 } // namespace aidl::android::hardware::gnss 66