• 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_service_impl.h"
17 
18 #include "ipc_skeleton.h"
19 #include "inputmethod_message_handler.h"
20 #include "message_parcel.h"
21 #include "os_account_adapter.h"
22 
23 namespace OHOS {
24 namespace MiscServices {
InputControlChannelServiceImpl(int32_t userId)25 InputControlChannelServiceImpl::InputControlChannelServiceImpl(int32_t userId)
26 {
27     userId_ = userId;
28 }
29 
~InputControlChannelServiceImpl()30 InputControlChannelServiceImpl::~InputControlChannelServiceImpl() {}
31 
HideKeyboardSelf()32 ErrCode InputControlChannelServiceImpl::HideKeyboardSelf()
33 {
34     auto userId = OsAccountAdapter::GetOsAccountLocalIdFromUid(IPCSkeleton::GetCallingUid());
35     if (userId == OsAccountAdapter::INVALID_USER_ID) {
36         return ErrorCode::ERROR_EX_ILLEGAL_STATE;
37     }
38     MessageParcel *parcel = new (std::nothrow) MessageParcel();
39     if (parcel == nullptr) {
40         return ErrorCode::ERROR_NULL_POINTER;
41     }
42     parcel->WriteInt32(userId);
43     Message *msg = new (std::nothrow) Message(MessageID::MSG_ID_HIDE_KEYBOARD_SELF, parcel);
44     if (msg == nullptr) {
45         delete parcel;
46         return ErrorCode::ERROR_NULL_POINTER;
47     }
48     MessageHandler::Instance()->SendMessage(msg);
49     return ERR_OK;
50 }
51 } // namespace MiscServices
52 } // namespace OHOS