1 /*
2 * Copyright (c) 2024 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 "modal_callback_stub.h"
17
18 #include <cinttypes>
19
20 #include "iam_logger.h"
21 #include "user_auth_interface.h"
22
23 #define LOG_TAG "USER_AUTH_SDK"
24
25 namespace OHOS {
26 namespace UserIam {
27 namespace UserAuth {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int32_t ModalCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
29 MessageOption &option)
30 {
31 IAM_LOGI("code = %{public}u, flags = %{public}d", code, option.GetFlags());
32 if (ModalCallbackStub::GetDescriptor() != data.ReadInterfaceToken()) {
33 IAM_LOGE("descriptor is not matched");
34 return GENERAL_ERROR;
35 }
36
37 switch (code) {
38 case UserAuthInterfaceCode::USER_AUTH_AUTH_MODAL_SEND_COMMAND:
39 return OnSendCommandStub(data, reply);
40 default:
41 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
42 }
43 }
44
OnSendCommandStub(MessageParcel & data,MessageParcel & reply)45 int32_t ModalCallbackStub::OnSendCommandStub(MessageParcel &data, MessageParcel &reply)
46 {
47 IAM_LOGI("start");
48 uint64_t contextId = data.ReadUint64();
49 std::string cmdData = data.ReadString();
50 SendCommand(contextId, cmdData);
51 return SUCCESS;
52 }
53 } // namespace UserAuth
54 } // namespace UserIam
55 } // namespace OHOS