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: InvalidRequest(MessageParcel & data,MessageParcel & reply)34 int32_t InvalidRequest(MessageParcel &data, MessageParcel &reply) 35 { 36 return ERR_UNKNOWN_TRANSACTION; 37 }; 38 39 int32_t StartInputOnRemote(MessageParcel &data, MessageParcel &reply); 40 41 int32_t ShowCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply); 42 43 int32_t HideCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply); 44 45 int32_t StopInputSessionOnRemote(MessageParcel &data, MessageParcel &reply); 46 47 int32_t ShowInputOnRemote(MessageParcel &data, MessageParcel &reply); 48 49 int32_t HideInputOnRemote(MessageParcel &data, MessageParcel &reply); 50 51 int32_t ReleaseInputOnRemote(MessageParcel &data, MessageParcel &reply); 52 53 int32_t RequestShowInputOnRemote(MessageParcel &data, MessageParcel &reply); 54 55 int32_t RequestHideInputOnRemote(MessageParcel &data, MessageParcel &reply); 56 57 int32_t GetCurrentInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 58 59 int32_t GetCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply); 60 61 int32_t ListInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 62 63 int32_t SwitchInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 64 65 int32_t DisplayOptionalInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 66 67 int32_t SetCoreAndAgentOnRemote(MessageParcel &data, MessageParcel &reply); 68 69 int32_t UnRegisteredProxyImeOnRemote(MessageParcel &data, MessageParcel &reply); 70 71 int32_t ListInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply); 72 73 int32_t ListCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply); 74 75 int32_t PanelStatusChangeOnRemote(MessageParcel &data, MessageParcel &reply); 76 77 int32_t UpdateListenEventFlagOnRemote(MessageParcel &data, MessageParcel &reply); 78 79 int32_t IsCurrentImeOnRemote(MessageParcel &data, MessageParcel &reply); 80 81 int32_t IsInputTypeSupportedOnRemote(MessageParcel &data, MessageParcel &reply); 82 83 int32_t StartInputTypeOnRemote(MessageParcel &data, MessageParcel &reply); 84 85 int32_t ExitCurrentInputTypeOnRemote(MessageParcel &data, MessageParcel &reply); 86 87 // Deprecated because of no permission check, kept for compatibility 88 int32_t HideCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply); 89 90 int32_t ShowCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply); 91 92 int32_t GetDefaultInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 93 94 int32_t IsDefaultImeSetOnRemote(MessageParcel &data, MessageParcel &reply); 95 96 int32_t EnableImeOnRemote(MessageParcel &data, MessageParcel &reply); 97 98 int32_t GetInputMethodConfigOnRemote(MessageParcel &data, MessageParcel &reply); 99 100 int32_t IsPanelShownOnRemote(MessageParcel &data, MessageParcel &reply); 101 102 int32_t GetSecurityModeOnRemote(MessageParcel &data, MessageParcel &reply); 103 104 int32_t IsDefaultImeOnRemote(MessageParcel &data, MessageParcel &reply); 105 106 int32_t ConnectSystemCmdOnRemote(MessageParcel &data, MessageParcel &reply); 107 108 int32_t IsCurrentImeByPidOnRemote(MessageParcel &data, MessageParcel &reply); 109 110 int32_t InitConnectOnRemote(MessageParcel &data, MessageParcel &reply); 111 112 using RequestHandler = int32_t (InputMethodSystemAbilityStub::*)(MessageParcel &, MessageParcel &); 113 static inline constexpr RequestHandler HANDLERS[static_cast<uint32_t>(InputMethodInterfaceCode::IMS_CMD_END)] = { 114 &InputMethodSystemAbilityStub::InvalidRequest, 115 [static_cast<uint32_t>(InputMethodInterfaceCode::START_INPUT)] = 116 &InputMethodSystemAbilityStub::StartInputOnRemote, 117 [static_cast<uint32_t>(InputMethodInterfaceCode::SHOW_CURRENT_INPUT)] = 118 &InputMethodSystemAbilityStub::ShowCurrentInputOnRemote, 119 [static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_CURRENT_INPUT)] = 120 &InputMethodSystemAbilityStub::HideCurrentInputOnRemote, 121 [static_cast<uint32_t>(InputMethodInterfaceCode::SHOW_INPUT)] = 122 &InputMethodSystemAbilityStub::ShowInputOnRemote, 123 [static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_INPUT)] = 124 &InputMethodSystemAbilityStub::HideInputOnRemote, 125 [static_cast<uint32_t>(InputMethodInterfaceCode::STOP_INPUT_SESSION)] = 126 &InputMethodSystemAbilityStub::StopInputSessionOnRemote, 127 [static_cast<uint32_t>(InputMethodInterfaceCode::RELEASE_INPUT)] = 128 &InputMethodSystemAbilityStub::ReleaseInputOnRemote, 129 [static_cast<uint32_t>(InputMethodInterfaceCode::REQUEST_SHOW_INPUT)] = 130 &InputMethodSystemAbilityStub::RequestShowInputOnRemote, 131 [static_cast<uint32_t>(InputMethodInterfaceCode::REQUEST_HIDE_INPUT)] = 132 &InputMethodSystemAbilityStub::RequestHideInputOnRemote, 133 [static_cast<uint32_t>(InputMethodInterfaceCode::GET_CURRENT_INPUT_METHOD)] = 134 &InputMethodSystemAbilityStub::GetCurrentInputMethodOnRemote, 135 [static_cast<uint32_t>(InputMethodInterfaceCode::GET_CURRENT_INPUT_METHOD_SUBTYPE)] = 136 &InputMethodSystemAbilityStub::GetCurrentInputMethodSubtypeOnRemote, 137 [static_cast<uint32_t>(InputMethodInterfaceCode::LIST_INPUT_METHOD)] = 138 &InputMethodSystemAbilityStub::ListInputMethodOnRemote, 139 [static_cast<uint32_t>(InputMethodInterfaceCode::LIST_INPUT_METHOD_SUBTYPE)] = 140 &InputMethodSystemAbilityStub::ListInputMethodSubtypeOnRemote, 141 [static_cast<uint32_t>(InputMethodInterfaceCode::LIST_CURRENT_INPUT_METHOD_SUBTYPE)] = 142 &InputMethodSystemAbilityStub::ListCurrentInputMethodSubtypeOnRemote, 143 [static_cast<uint32_t>(InputMethodInterfaceCode::SWITCH_INPUT_METHOD)] = 144 &InputMethodSystemAbilityStub::SwitchInputMethodOnRemote, 145 [static_cast<uint32_t>(InputMethodInterfaceCode::DISPLAY_OPTIONAL_INPUT_METHOD)] = 146 &InputMethodSystemAbilityStub::DisplayOptionalInputMethodOnRemote, 147 [static_cast<uint32_t>(InputMethodInterfaceCode::SET_CORE_AND_AGENT)] = 148 &InputMethodSystemAbilityStub::SetCoreAndAgentOnRemote, 149 [static_cast<uint32_t>(InputMethodInterfaceCode::SHOW_CURRENT_INPUT_DEPRECATED)] = 150 &InputMethodSystemAbilityStub::ShowCurrentInputOnRemoteDeprecated, 151 [static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_CURRENT_INPUT_DEPRECATED)] = 152 &InputMethodSystemAbilityStub::HideCurrentInputOnRemoteDeprecated, 153 [static_cast<uint32_t>(InputMethodInterfaceCode::PANEL_STATUS_CHANGE)] = 154 &InputMethodSystemAbilityStub::PanelStatusChangeOnRemote, 155 [static_cast<uint32_t>(InputMethodInterfaceCode::UPDATE_LISTEN_EVENT_FLAG)] = 156 &InputMethodSystemAbilityStub::UpdateListenEventFlagOnRemote, 157 [static_cast<uint32_t>(InputMethodInterfaceCode::IS_CURRENT_IME)] = 158 &InputMethodSystemAbilityStub::IsCurrentImeOnRemote, 159 [static_cast<uint32_t>(InputMethodInterfaceCode::UNREGISTERED_PROXY_IME)] = 160 &InputMethodSystemAbilityStub::UnRegisteredProxyImeOnRemote, 161 [static_cast<uint32_t>(InputMethodInterfaceCode::IS_INPUT_TYPE_SUPPORTED)] = 162 &InputMethodSystemAbilityStub::IsInputTypeSupportedOnRemote, 163 [static_cast<uint32_t>(InputMethodInterfaceCode::START_INPUT_TYPE)] = 164 &InputMethodSystemAbilityStub::StartInputTypeOnRemote, 165 [static_cast<uint32_t>(InputMethodInterfaceCode::EXIT_CURRENT_INPUT_TYPE)] = 166 &InputMethodSystemAbilityStub::ExitCurrentInputTypeOnRemote, 167 [static_cast<uint32_t>(InputMethodInterfaceCode::GET_DEFAULT_INPUT_METHOD)] = 168 &InputMethodSystemAbilityStub::GetDefaultInputMethodOnRemote, 169 [static_cast<uint32_t>(InputMethodInterfaceCode::GET_INPUT_METHOD_SETTINGS)] = 170 &InputMethodSystemAbilityStub::GetInputMethodConfigOnRemote, 171 [static_cast<uint32_t>(InputMethodInterfaceCode::IS_PANEL_SHOWN)] = 172 &InputMethodSystemAbilityStub::IsPanelShownOnRemote, 173 [static_cast<uint32_t>(InputMethodInterfaceCode::GET_SECURITY_MODE)] = 174 &InputMethodSystemAbilityStub::GetSecurityModeOnRemote, 175 [static_cast<uint32_t>(InputMethodInterfaceCode::IS_DEFAULT_IME)] = 176 &InputMethodSystemAbilityStub::IsDefaultImeOnRemote, 177 [static_cast<uint32_t>(InputMethodInterfaceCode::CONNECT_SYSTEM_CMD)] = 178 &InputMethodSystemAbilityStub::ConnectSystemCmdOnRemote, 179 [static_cast<uint32_t>(InputMethodInterfaceCode::IS_CURRENT_IME_BY_PID)] = 180 &InputMethodSystemAbilityStub::IsCurrentImeByPidOnRemote, 181 [static_cast<uint32_t>(InputMethodInterfaceCode::INIT_CONNECT)] = 182 &InputMethodSystemAbilityStub::InitConnectOnRemote, 183 [static_cast<uint32_t>(InputMethodInterfaceCode::IS_DEFAULT_IME_SET)] = 184 &InputMethodSystemAbilityStub::IsDefaultImeSetOnRemote, 185 [static_cast<uint32_t>(InputMethodInterfaceCode::ENABLE_IME)] = 186 &InputMethodSystemAbilityStub::EnableImeOnRemote, 187 }; 188 }; 189 } // namespace OHOS::MiscServices 190 191 #endif // SERVICES_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_STUB_H 192