1 /*
2 * Copyright (c) 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 "widget_callback_stub.h"
17
18 #include <cinttypes>
19
20 #include "iam_logger.h"
21 #include "user_auth_interface.h"
22
23 #define LOG_LABEL UserIam::Common::LABEL_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 WidgetCallbackStub::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 (WidgetCallbackStub::GetDescriptor() != data.ReadInterfaceToken()) {
33 IAM_LOGE("descriptor is not matched");
34 return GENERAL_ERROR;
35 }
36
37 switch (code) {
38 case UserAuthInterfaceCode::USER_AUTH_ON_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 WidgetCallbackStub::OnSendCommandStub(MessageParcel &data, MessageParcel &reply)
46 {
47 IAM_LOGI("start");
48 std::string cmdData = data.ReadString();
49 SendCommand(cmdData);
50 return SUCCESS;
51 }
52 } // namespace UserAuth
53 } // namespace UserIam
54 } // namespace OHOS