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