• 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 "v1_1/pin_auth_interface_service.h"
17 
18 #include <hdf_base.h>
19 
20 #include "iam_logger.h"
21 #include "iam_ptr.h"
22 
23 #include "pin_auth_hdi.h"
24 #include "pin_auth.h"
25 #include "executor_impl.h"
26 
27 #define LOG_LABEL OHOS::UserIam::Common::LABEL_PIN_AUTH_HDI
28 
29 namespace OHOS {
30 namespace HDI {
31 namespace PinAuth {
PinAuthInterfaceImplGetInstance(void)32 extern "C" IPinAuthInterface *PinAuthInterfaceImplGetInstance(void)
33 {
34     auto pinAuthInterfaceService = new (std::nothrow) PinAuthInterfaceService();
35     if (pinAuthInterfaceService == nullptr) {
36         IAM_LOGE("pinAuthInterfaceService is nullptr");
37         return nullptr;
38     }
39     return pinAuthInterfaceService;
40 }
41 
GetExecutorList(std::vector<sptr<IExecutorV1_0>> & executorList)42 int32_t PinAuthInterfaceService::GetExecutorList(std::vector<sptr<IExecutorV1_0>> &executorList)
43 {
44     std::vector<sptr<IExecutor>> executorListV1_1;
45     int32_t result = GetExecutorListV1_1(executorListV1_1);
46     for (auto &executor : executorListV1_1) {
47         executorList.push_back(executor);
48     }
49     return result;
50 }
51 
GetExecutorListV1_1(std::vector<sptr<IExecutor>> & executorList)52 int32_t PinAuthInterfaceService::GetExecutorListV1_1(std::vector<sptr<IExecutor>> &executorList)
53 {
54     IAM_LOGI("start");
55     std::shared_ptr<OHOS::UserIam::PinAuth::PinAuth> pinHdi =
56         OHOS::UserIam::Common::MakeShared<OHOS::UserIam::PinAuth::PinAuth>();
57     if (pinHdi == nullptr) {
58         IAM_LOGE("Generate pinHdi failed");
59         return HDF_FAILURE;
60     }
61     sptr<IExecutor> executor = new (std::nothrow) ExecutorImpl(pinHdi);
62     if (executor == nullptr) {
63         IAM_LOGE("Generate executor failed");
64         return HDF_FAILURE;
65     }
66     executorList.push_back(executor);
67     IAM_LOGI("end");
68     return HDF_SUCCESS;
69 }
70 } // PinAuth
71 } // HDI
72 } // OHOS