• 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_method_ability_connection_stub.h"
17 #include "message_parcel.h"
18 #include "message.h"
19 
20 namespace OHOS {
21 namespace MiscServices {
InputMethodAbilityConnectionStub(const int index)22     InputMethodAbilityConnectionStub::InputMethodAbilityConnectionStub(const int index)
23     {
24         mIndex = index;
25     }
26 
~InputMethodAbilityConnectionStub()27     InputMethodAbilityConnectionStub::~InputMethodAbilityConnectionStub()
28     {
29     }
30 
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)31     void InputMethodAbilityConnectionStub::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
32                                                                 const sptr<IRemoteObject> &remoteObject, int resultCode)
33     {
34         IMSA_HILOGE("ConnectAbility: OnAbilityConnectDone.");
35         if (messageHandler != nullptr) {
36             MessageParcel *data = new MessageParcel();
37             data->WriteParcelable(&element);
38             data->WriteRemoteObject(remoteObject);
39             data->WriteInt32(mIndex);
40             Message *msg = new Message(MessageID::MSG_ID_ABILITY_CONNECT_DONE, data);
41             messageHandler->SendMessage(msg);
42         }
43     }
44 
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int resultCode)45     void InputMethodAbilityConnectionStub::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
46                                                                    int resultCode)
47     {
48         IMSA_HILOGE("ConnectAbility: OnAbilityDisconnectDone.");
49         if (messageHandler != nullptr) {
50             MessageParcel *data = new MessageParcel();
51             data->WriteParcelable(&element);
52             data->WriteInt32(mIndex);
53             Message *msg = new Message(MessageID::MSG_ID_ABILITY_DISCONNECT_DONE, data);
54             messageHandler->SendMessage(msg);
55         }
56     }
57 
SetHandler(MessageHandler * handler)58     void InputMethodAbilityConnectionStub::SetHandler(MessageHandler *handler)
59     {
60         messageHandler = handler;
61     }
62 }
63 }