• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #ifndef SERVICES_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_STUB_H
17 #define SERVICES_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_STUB_H
18 
19 #include <errors.h>
20 
21 #include "global.h"
22 #include "i_input_method_system_ability.h"
23 #include "inputmethod_service_ipc_interface_code.h"
24 #include "iremote_stub.h"
25 #include "message_parcel.h"
26 #include "refbase.h"
27 
28 namespace OHOS ::MiscServices {
29 class InputMethodSystemAbilityStub : public IRemoteStub<IInputMethodSystemAbility> {
30 public:
31     int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
32 
33 private:
34     int32_t PrepareInputOnRemote(MessageParcel &data, MessageParcel &reply);
35 
36     int32_t StartInputOnRemote(MessageParcel &data, MessageParcel &reply);
37 
38     int32_t ShowCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply);
39 
40     int32_t HideCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply);
41 
42     int32_t StopInputSessionOnRemote(MessageParcel &data, MessageParcel &reply);
43 
44     int32_t StopInputOnRemote(MessageParcel &data, MessageParcel &reply);
45 
46     int32_t ReleaseInputOnRemote(MessageParcel &data, MessageParcel &reply);
47 
48     int32_t GetCurrentInputMethodOnRemote(MessageParcel &data, MessageParcel &reply);
49 
50     int32_t GetCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply);
51 
52     int32_t ListInputMethodOnRemote(MessageParcel &data, MessageParcel &reply);
53 
54     int32_t SwitchInputMethodOnRemote(MessageParcel &data, MessageParcel &reply);
55 
56     int32_t DisplayOptionalInputMethodOnRemote(MessageParcel &data, MessageParcel &reply);
57 
58     int32_t SetCoreAndAgentOnRemote(MessageParcel &data, MessageParcel &reply);
59 
60     int32_t ListInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply);
61 
62     int32_t ListCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply);
63 
64     int32_t PanelStatusChangeOnRemote(MessageParcel &data, MessageParcel &reply);
65 
66     int32_t UpdateListenEventFlagOnRemote(MessageParcel &data, MessageParcel &reply);
67 
68     // Deprecated because of no permission check, kept for compatibility
69     int32_t DisplayInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply);
70 
71     int32_t HideCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply);
72 
73     int32_t ShowCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply);
74 
75     using RequestHandler = int32_t (InputMethodSystemAbilityStub::*)(MessageParcel &, MessageParcel &);
76     static constexpr RequestHandler HANDLERS[static_cast<uint32_t>(InputMethodInterfaceCode::IMS_CMD_LAST)] = {
77         [static_cast<uint32_t>(InputMethodInterfaceCode::PREPARE_INPUT)] =
78             &InputMethodSystemAbilityStub::PrepareInputOnRemote,
79         [static_cast<uint32_t>(InputMethodInterfaceCode::START_INPUT)] =
80             &InputMethodSystemAbilityStub::StartInputOnRemote,
81         [static_cast<uint32_t>(InputMethodInterfaceCode::SHOW_CURRENT_INPUT)] =
82             &InputMethodSystemAbilityStub::ShowCurrentInputOnRemote,
83         [static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_CURRENT_INPUT)] =
84             &InputMethodSystemAbilityStub::HideCurrentInputOnRemote,
85         [static_cast<uint32_t>(InputMethodInterfaceCode::STOP_INPUT)] =
86             &InputMethodSystemAbilityStub::StopInputOnRemote,
87         [static_cast<uint32_t>(InputMethodInterfaceCode::RELEASE_INPUT)] =
88             &InputMethodSystemAbilityStub::ReleaseInputOnRemote,
89         [static_cast<uint32_t>(InputMethodInterfaceCode::GET_CURRENT_INPUT_METHOD)] =
90             &InputMethodSystemAbilityStub::GetCurrentInputMethodOnRemote,
91         [static_cast<uint32_t>(InputMethodInterfaceCode::GET_CURRENT_INPUT_METHOD_SUBTYPE)] =
92             &InputMethodSystemAbilityStub::GetCurrentInputMethodSubtypeOnRemote,
93         [static_cast<uint32_t>(InputMethodInterfaceCode::LIST_INPUT_METHOD)] =
94             &InputMethodSystemAbilityStub::ListInputMethodOnRemote,
95         [static_cast<uint32_t>(InputMethodInterfaceCode::LIST_INPUT_METHOD_SUBTYPE)] =
96             &InputMethodSystemAbilityStub::ListInputMethodSubtypeOnRemote,
97         [static_cast<uint32_t>(InputMethodInterfaceCode::LIST_CURRENT_INPUT_METHOD_SUBTYPE)] =
98             &InputMethodSystemAbilityStub::ListCurrentInputMethodSubtypeOnRemote,
99         [static_cast<uint32_t>(InputMethodInterfaceCode::SWITCH_INPUT_METHOD)] =
100             &InputMethodSystemAbilityStub::SwitchInputMethodOnRemote,
101         [static_cast<uint32_t>(InputMethodInterfaceCode::DISPLAY_OPTIONAL_INPUT_METHOD)] =
102             &InputMethodSystemAbilityStub::DisplayOptionalInputMethodOnRemote,
103         [static_cast<uint32_t>(InputMethodInterfaceCode::SET_CORE_AND_AGENT)] =
104             &InputMethodSystemAbilityStub::SetCoreAndAgentOnRemote,
105         [static_cast<uint32_t>(InputMethodInterfaceCode::SHOW_CURRENT_INPUT_DEPRECATED)] =
106             &InputMethodSystemAbilityStub::ShowCurrentInputOnRemoteDeprecated,
107         [static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_CURRENT_INPUT_DEPRECATED)] =
108             &InputMethodSystemAbilityStub::HideCurrentInputOnRemoteDeprecated,
109         [static_cast<uint32_t>(InputMethodInterfaceCode::DISPLAY_OPTIONAL_INPUT_DEPRECATED)] =
110             &InputMethodSystemAbilityStub::DisplayInputOnRemoteDeprecated,
111         [static_cast<uint32_t>(InputMethodInterfaceCode::STOP_INPUT_SESSION)] =
112             &InputMethodSystemAbilityStub::StopInputSessionOnRemote,
113         [static_cast<uint32_t>(InputMethodInterfaceCode::PANEL_STATUS_CHANGE)] =
114             &InputMethodSystemAbilityStub::PanelStatusChangeOnRemote,
115         [static_cast<uint32_t>(InputMethodInterfaceCode::UPDATE_LISTEN_EVENT_FLAG)] =
116             &InputMethodSystemAbilityStub::UpdateListenEventFlagOnRemote,
117     };
118 };
119 } // namespace OHOS::MiscServices
120 
121 #endif // SERVICES_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_STUB_H
122