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_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
35 if (code == InputerGetData::ON_GET_DATA) {
36 OnGetDataStub(data, reply);
37 return UserAuth::SUCCESS;
38 }
39 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40 }
41
OnGetDataStub(MessageParcel & data,MessageParcel & reply)42 void InputerGetDataStub::OnGetDataStub(MessageParcel &data, MessageParcel &reply)
43 {
44 int32_t authSubType;
45 std::vector<uint8_t> salt;
46
47 if (!data.ReadInt32(authSubType)) {
48 IAM_LOGE("failed to read authSubType");
49 return;
50 }
51 if (!data.ReadUInt8Vector(&salt)) {
52 IAM_LOGE("failed to read salt");
53 return;
54 }
55 sptr<IRemoteObject> obj = data.ReadRemoteObject();
56 if (obj == nullptr) {
57 IAM_LOGE("failed to read remote object");
58 return;
59 }
60 sptr<InputerSetData> inputerSetData = iface_cast<InputerSetData>(obj);
61 if (inputerSetData == nullptr) {
62 IAM_LOGE("inputerSetData is nullptr");
63 return;
64 }
65
66 OnGetData(authSubType, salt, inputerSetData.GetRefPtr());
67 }
68 } // namespace PinAuth
69 } // namespace UserIam
70 } // namespace OHOS
71