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_set_data_stub.h"
17
18 #include "iam_logger.h"
19 #include "iam_common_defines.h"
20
21 #define LOG_LABEL UserIam::Common::LABEL_PIN_AUTH_SA
22
23 namespace OHOS {
24 namespace UserIam {
25 namespace PinAuth {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)26 int32_t InputerSetDataStub::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 (InputerSetDataStub::GetDescriptor() != data.ReadInterfaceToken()) {
31 IAM_LOGE("descriptor is not matched");
32 return UserAuth::GENERAL_ERROR;
33 }
34 switch (code) {
35 case InputerSetDataInterfaceCode::ON_SET_DATA:
36 OnSetDataStub(data, reply);
37 return UserAuth::SUCCESS;
38 default:
39 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40 }
41 }
42
OnSetDataStub(MessageParcel & data,MessageParcel & reply)43 void InputerSetDataStub::OnSetDataStub(MessageParcel &data, MessageParcel &reply)
44 {
45 IAM_LOGI("start");
46 int32_t subType;
47 std::vector<uint8_t> param;
48
49 if (!data.ReadInt32(subType)) {
50 IAM_LOGE("failed to read subType");
51 return;
52 }
53 if (!data.ReadUInt8Vector(¶m)) {
54 IAM_LOGE("failed to read param");
55 return;
56 }
57
58 OnSetData(subType, param);
59 }
60 } // namespace PinAuth
61 } // namespace UserIam
62 } // namespace OHOS
63