• 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 "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     int32_t SetCoreAndAgentOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply);
71 
72     bool CheckPermission(const std::string &permission);
73 
74     using RequestHandler = int32_t (InputMethodSystemAbilityStub::*)(MessageParcel &, MessageParcel &);
75     static constexpr RequestHandler HANDLERS[INPUT_SERVICE_CMD_LAST] = {
76         [PREPARE_INPUT] = &InputMethodSystemAbilityStub::PrepareInputOnRemote,
77         [START_INPUT] = &InputMethodSystemAbilityStub::StartInputOnRemote,
78         [SHOW_CURRENT_INPUT] = &InputMethodSystemAbilityStub::ShowCurrentInputOnRemote,
79         [HIDE_CURRENT_INPUT] = &InputMethodSystemAbilityStub::HideCurrentInputOnRemote,
80         [STOP_INPUT] = &InputMethodSystemAbilityStub::StopInputOnRemote,
81         [RELEASE_INPUT] = &InputMethodSystemAbilityStub::ReleaseInputOnRemote,
82         [GET_CURRENT_INPUT_METHOD] = &InputMethodSystemAbilityStub::GetCurrentInputMethodOnRemote,
83         [GET_CURRENT_INPUT_METHOD_SUBTYPE] = &InputMethodSystemAbilityStub::GetCurrentInputMethodSubtypeOnRemote,
84         [LIST_INPUT_METHOD] = &InputMethodSystemAbilityStub::ListInputMethodOnRemote,
85         [LIST_INPUT_METHOD_SUBTYPE] =&InputMethodSystemAbilityStub::ListInputMethodSubtypeOnRemote,
86         [LIST_CURRENT_INPUT_METHOD_SUBTYPE] =&InputMethodSystemAbilityStub::ListCurrentInputMethodSubtypeOnRemote,
87         [SWITCH_INPUT_METHOD] = &InputMethodSystemAbilityStub::SwitchInputMethodOnRemote,
88         [DISPLAY_OPTIONAL_INPUT_METHOD] = &InputMethodSystemAbilityStub::DisplayOptionalInputMethodOnRemote,
89         [SET_CORE_AND_AGENT] = &InputMethodSystemAbilityStub::SetCoreAndAgentOnRemote,
90         [SHOW_CURRENT_INPUT_DEPRECATED] = &InputMethodSystemAbilityStub::ShowCurrentInputOnRemoteDeprecated,
91         [HIDE_CURRENT_INPUT_DEPRECATED] = &InputMethodSystemAbilityStub::HideCurrentInputOnRemoteDeprecated,
92         [DISPLAY_OPTIONAL_INPUT_DEPRECATED] = &InputMethodSystemAbilityStub::DisplayInputOnRemoteDeprecated,
93         [SET_CORE_AND_AGENT_DEPRECATED] = &InputMethodSystemAbilityStub::SetCoreAndAgentOnRemoteDeprecated,
94         [STOP_INPUT_SESSION] = &InputMethodSystemAbilityStub::StopInputSessionOnRemote,
95     };
96 };
97 } // namespace OHOS::MiscServices
98 
99 #endif // SERVICES_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_STUB_H
100