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 "inputer_get_data_service.h"
17
18 #include "iam_logger.h"
19 #include "iam_ptr.h"
20 #include "inputer_data_impl.h"
21
22 #define LOG_LABEL OHOS::UserIam::Common::LABEL_PIN_AUTH_SDK
23
24 namespace OHOS {
25 namespace UserIam {
26 namespace PinAuth {
InputerGetDataService(const std::shared_ptr<IInputer> & inputer)27 InputerGetDataService::InputerGetDataService(const std::shared_ptr<IInputer> &inputer) : inputer_(inputer)
28 {
29 }
30
OnGetData(int32_t authSubType,const std::vector<uint8_t> & salt,const sptr<InputerSetData> & inputerSetData)31 void InputerGetDataService::OnGetData(int32_t authSubType, const std::vector<uint8_t> &salt,
32 const sptr<InputerSetData> &inputerSetData)
33 {
34 IAM_LOGI("start");
35 if (inputerSetData == nullptr) {
36 IAM_LOGE("inputerSetData is nullptr");
37 return;
38 }
39
40 std::shared_ptr<IInputerData> sharedInputerData = Common::MakeShared<InputerDataImpl>(salt, inputerSetData);
41 if (sharedInputerData == nullptr) {
42 IAM_LOGE("sharedInputerData is nullptr");
43 return;
44 }
45 if (inputer_ == nullptr) {
46 IAM_LOGE("inputer is nullptr");
47 return;
48 }
49 inputer_->OnGetData(authSubType, sharedInputerData);
50 }
51 } // namespace PinAuth
52 } // namespace UserIam
53 } // namespace OHOS
54