• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
27 #define LOG_LABEL UserIam::Common::LABEL_PIN_AUTH_SA
28 
29 namespace OHOS {
30 namespace UserIam {
31 namespace PinAuth {
PinAuthDriverHdi(const std::shared_ptr<PinAuthInterfaceAdapter> & pinAuthInterfaceAdapter)32 PinAuthDriverHdi::PinAuthDriverHdi(const std::shared_ptr<PinAuthInterfaceAdapter> &pinAuthInterfaceAdapter)
33     : pinAuthInterfaceAdapter_(pinAuthInterfaceAdapter)
34 {
35 }
36 
GetExecutorList(std::vector<std::shared_ptr<UserAuth::IAuthExecutorHdi>> & executorList)37 void PinAuthDriverHdi::GetExecutorList(std::vector<std::shared_ptr<UserAuth::IAuthExecutorHdi>> &executorList)
38 {
39     IAM_LOGI("start");
40     if (pinAuthInterfaceAdapter_ == nullptr) {
41         IAM_LOGE("pinAuthInterfaceAdapter_ is null");
42         return;
43     }
44     auto pinInterface = pinAuthInterfaceAdapter_->Get();
45     if (pinInterface == nullptr) {
46         IAM_LOGE("IPinAuthInterface is null");
47         return;
48     }
49 
50     std::vector<sptr<HDI::PinAuth::V1_1::IExecutor>> iExecutorList;
51     auto ret = pinInterface->GetExecutorListV1_1(iExecutorList);
52     if (ret != HDF_SUCCESS) {
53         IAM_LOGE("GetExecutorList fail");
54         return;
55     }
56     for (const auto &iExecutor : iExecutorList) {
57         if (iExecutor == nullptr) {
58             IAM_LOGE("iExecutor is nullptr");
59             continue;
60         }
61         auto executor = Common::MakeShared<PinAuthExecutorHdi>(iExecutor);
62         if (executor == nullptr) {
63             IAM_LOGE("make share failed");
64             continue;
65         }
66         executorList.push_back(executor);
67     }
68 }
69 
OnHdiDisconnect()70 void PinAuthDriverHdi::OnHdiDisconnect()
71 {
72     IAM_LOGI("start");
73 }
74 } // namespace PinAuth
75 } // namespace UserIam
76 } // namespace OHOS