• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 "input_control_channel_stub.h"
17 
18 #include "i_input_control_channel.h"
19 #include "input_channel.h"
20 #include "input_method_agent_proxy.h"
21 #include "ipc_skeleton.h"
22 #include "message_handler.h"
23 #include "message_parcel.h"
24 
25 namespace OHOS {
26 namespace MiscServices {
InputControlChannelStub(int32_t userId)27 InputControlChannelStub::InputControlChannelStub(int32_t userId)
28 {
29     userId_ = userId;
30 }
31 
~InputControlChannelStub()32 InputControlChannelStub::~InputControlChannelStub()
33 {
34 }
35 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)36 int32_t InputControlChannelStub::OnRemoteRequest(
37     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
38 {
39     IMSA_HILOGD("InputControlChannelStub, code = %{public}u, callingPid:%{public}d, callingUid:%{public}d", code,
40         IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid());
41     auto descriptorToken = data.ReadInterfaceToken();
42     if (descriptorToken != GetDescriptor()) {
43         return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
44     }
45     switch (code) {
46         case HIDE_KEYBOARD_SELF: {
47             reply.WriteInt32(HideKeyboardSelf());
48             break;
49         }
50         default: {
51             return IRemoteStub::OnRemoteRequest(code, data, reply, option);
52         }
53     }
54     return NO_ERROR;
55 }
56 
HideKeyboardSelf()57 int32_t InputControlChannelStub::HideKeyboardSelf()
58 {
59     IMSA_HILOGI("InputControlChannelStub run in.");
60     Message *msg = new (std::nothrow) Message(MessageID::MSG_ID_HIDE_KEYBOARD_SELF, nullptr);
61     if (msg == nullptr) {
62         return ErrorCode::ERROR_NULL_POINTER;
63     }
64     MessageHandler::Instance()->SendMessage(msg);
65     return ErrorCode::NO_ERROR;
66 }
67 } // namespace MiscServices
68 } // namespace OHOS
69