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