1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "pin_auth_driver_hdi.h" 17 18 #include <vector> 19 20 #include "refbase.h" 21 22 #include "iam_logger.h" 23 #include "iam_ptr.h" 24 25 #include "pin_auth_executor_hdi.h" 26 #include "v1_0/iexecutor.h" 27 #include "v1_0/ipin_auth_interface.h" 28 29 #define LOG_LABEL UserIam::Common::LABEL_PIN_AUTH_SA 30 31 namespace OHOS { 32 namespace UserIam { 33 namespace PinAuth { PinAuthDriverHdi(const std::shared_ptr<PinAuthInterfaceAdapter> & pinAuthInterfaceAdapter)34PinAuthDriverHdi::PinAuthDriverHdi(const std::shared_ptr<PinAuthInterfaceAdapter> &pinAuthInterfaceAdapter) 35 : pinAuthInterfaceAdapter_(pinAuthInterfaceAdapter) 36 { 37 } 38 GetExecutorList(std::vector<std::shared_ptr<UserAuth::IAuthExecutorHdi>> & executorList)39void PinAuthDriverHdi::GetExecutorList(std::vector<std::shared_ptr<UserAuth::IAuthExecutorHdi>> &executorList) 40 { 41 IAM_LOGI("start"); 42 if (pinAuthInterfaceAdapter_ == nullptr) { 43 IAM_LOGE("pinAuthInterfaceAdapter_ is null"); 44 return; 45 } 46 auto pinInterface = pinAuthInterfaceAdapter_->Get(); 47 if (pinInterface == nullptr) { 48 IAM_LOGE("IPinAuthInterface is null"); 49 return; 50 } 51 52 std::vector<sptr<HDI::PinAuth::V1_0::IExecutor>> iExecutorList; 53 auto ret = pinInterface->GetExecutorList(iExecutorList); 54 if (ret != HDF_SUCCESS) { 55 IAM_LOGE("GetExecutorList fail"); 56 return; 57 } 58 for (const auto &iExecutor : iExecutorList) { 59 if (iExecutor == nullptr) { 60 IAM_LOGE("iExecutor is nullptr"); 61 continue; 62 } 63 auto executor = Common::MakeShared<PinAuthExecutorHdi>(iExecutor); 64 if (executor == nullptr) { 65 IAM_LOGE("make share failed"); 66 continue; 67 } 68 executorList.push_back(executor); 69 } 70 } 71 } // PinAuth 72 } // UserIam 73 } // OHOS