• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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_stub.h"
17 
18 #include "iam_logger.h"
19 #include "iam_common_defines.h"
20 
21 #define LOG_LABEL OHOS::UserIam::Common::LABEL_PIN_AUTH_SDK
22 
23 namespace OHOS {
24 namespace UserIam {
25 namespace PinAuth {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)26 int32_t InputerGetDataStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
27     MessageOption &option)
28 {
29     IAM_LOGI("cmd = %{public}u, flags = %{public}d", code, option.GetFlags());
30     if (InputerGetDataStub::GetDescriptor() != data.ReadInterfaceToken()) {
31         IAM_LOGE("descriptor is not matched");
32         return UserAuth::GENERAL_ERROR;
33     }
34     switch (code) {
35         case InputerGetDataInterfaceCode::ON_GET_DATA:
36             OnGetDataStub(data, reply);
37             return UserAuth::SUCCESS;
38         default:
39             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40     }
41 }
42 
OnGetDataStub(MessageParcel & data,MessageParcel & reply)43 void InputerGetDataStub::OnGetDataStub(MessageParcel &data, MessageParcel &reply)
44 {
45     int32_t authSubType;
46     std::vector<uint8_t> salt;
47 
48     if (!data.ReadInt32(authSubType)) {
49         IAM_LOGE("failed to read authSubType");
50         return;
51     }
52     if (!data.ReadUInt8Vector(&salt)) {
53         IAM_LOGE("failed to read salt");
54         return;
55     }
56     sptr<IRemoteObject> obj = data.ReadRemoteObject();
57     if (obj == nullptr) {
58         IAM_LOGE("failed to read remote object");
59         return;
60     }
61     sptr<InputerSetData> inputerSetData = iface_cast<InputerSetData>(obj);
62     if (inputerSetData == nullptr) {
63         IAM_LOGE("inputerSetData is nullptr");
64         return;
65     }
66 
67     OnGetData(authSubType, salt, inputerSetData);
68 }
69 } // namespace PinAuth
70 } // namespace UserIam
71 } // namespace OHOS
72