• 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 "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 
35     if (code == InputerSetData::ON_SET_DATA) {
36         OnSetDataStub(data, reply);
37         return UserAuth::SUCCESS;
38     }
39     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40 }
41 
OnSetDataStub(MessageParcel & data,MessageParcel & reply)42 void InputerSetDataStub::OnSetDataStub(MessageParcel &data, MessageParcel &reply)
43 {
44     IAM_LOGI("start");
45     int32_t subType;
46     std::vector<uint8_t> param;
47 
48     if (!data.ReadInt32(subType)) {
49         IAM_LOGE("failed to read subType");
50         return;
51     }
52     if (!data.ReadUInt8Vector(&param)) {
53         IAM_LOGE("failed to read param");
54         return;
55     }
56 
57     OnSetData(subType, param);
58 }
59 } // namespace PinAuth
60 } // namespace UserIam
61 } // namespace OHOS
62