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 "iremote_stub.h" 24 #include "message_parcel.h" 25 #include "refbase.h" 26 27 namespace OHOS ::MiscServices { 28 class InputMethodSystemAbilityStub : public IRemoteStub<IInputMethodSystemAbility> { 29 public: 30 int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 31 32 private: 33 int32_t PrepareInputOnRemote(MessageParcel &data, MessageParcel &reply); 34 35 int32_t StartInputOnRemote(MessageParcel &data, MessageParcel &reply); 36 37 int32_t ShowCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply); 38 39 int32_t HideCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply); 40 41 int32_t StopInputSessionOnRemote(MessageParcel &data, MessageParcel &reply); 42 43 int32_t StopInputOnRemote(MessageParcel &data, MessageParcel &reply); 44 45 int32_t ReleaseInputOnRemote(MessageParcel &data, MessageParcel &reply); 46 47 int32_t GetCurrentInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 48 49 int32_t GetCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply); 50 51 int32_t ListInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 52 53 int32_t SwitchInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 54 55 int32_t DisplayOptionalInputMethodOnRemote(MessageParcel &data, MessageParcel &reply); 56 57 int32_t SetCoreAndAgentOnRemote(MessageParcel &data, MessageParcel &reply); 58 59 int32_t ListInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply); 60 61 int32_t ListCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply); 62 63 // Deprecated because of no permission check, kept for compatibility 64 int32_t DisplayInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply); 65 66 int32_t HideCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply); 67 68 int32_t ShowCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply); 69 70 using RequestHandler = int32_t (InputMethodSystemAbilityStub::*)(MessageParcel &, MessageParcel &); 71 static constexpr RequestHandler HANDLERS[INPUT_SERVICE_CMD_LAST] = { 72 [PREPARE_INPUT] = &InputMethodSystemAbilityStub::PrepareInputOnRemote, 73 [START_INPUT] = &InputMethodSystemAbilityStub::StartInputOnRemote, 74 [SHOW_CURRENT_INPUT] = &InputMethodSystemAbilityStub::ShowCurrentInputOnRemote, 75 [HIDE_CURRENT_INPUT] = &InputMethodSystemAbilityStub::HideCurrentInputOnRemote, 76 [STOP_INPUT] = &InputMethodSystemAbilityStub::StopInputOnRemote, 77 [RELEASE_INPUT] = &InputMethodSystemAbilityStub::ReleaseInputOnRemote, 78 [GET_CURRENT_INPUT_METHOD] = &InputMethodSystemAbilityStub::GetCurrentInputMethodOnRemote, 79 [GET_CURRENT_INPUT_METHOD_SUBTYPE] = &InputMethodSystemAbilityStub::GetCurrentInputMethodSubtypeOnRemote, 80 [LIST_INPUT_METHOD] = &InputMethodSystemAbilityStub::ListInputMethodOnRemote, 81 [LIST_INPUT_METHOD_SUBTYPE] =&InputMethodSystemAbilityStub::ListInputMethodSubtypeOnRemote, 82 [LIST_CURRENT_INPUT_METHOD_SUBTYPE] =&InputMethodSystemAbilityStub::ListCurrentInputMethodSubtypeOnRemote, 83 [SWITCH_INPUT_METHOD] = &InputMethodSystemAbilityStub::SwitchInputMethodOnRemote, 84 [DISPLAY_OPTIONAL_INPUT_METHOD] = &InputMethodSystemAbilityStub::DisplayOptionalInputMethodOnRemote, 85 [SET_CORE_AND_AGENT] = &InputMethodSystemAbilityStub::SetCoreAndAgentOnRemote, 86 [SHOW_CURRENT_INPUT_DEPRECATED] = &InputMethodSystemAbilityStub::ShowCurrentInputOnRemoteDeprecated, 87 [HIDE_CURRENT_INPUT_DEPRECATED] = &InputMethodSystemAbilityStub::HideCurrentInputOnRemoteDeprecated, 88 [DISPLAY_OPTIONAL_INPUT_DEPRECATED] = &InputMethodSystemAbilityStub::DisplayInputOnRemoteDeprecated, 89 [STOP_INPUT_SESSION] = &InputMethodSystemAbilityStub::StopInputSessionOnRemote, 90 }; 91 }; 92 } // namespace OHOS::MiscServices 93 94 #endif // SERVICES_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_STUB_H 95