1 /*
2  * Copyright (C) 2021 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 FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_PROXY_H
17 #define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_PROXY_H
18 
19 #include <cstdint>
20 #include <functional>
21 #include <string>
22 #include <vector>
23 
24 #include "global.h"
25 #include "element_name.h"
26 #include "i_input_method_system_ability.h"
27 #include "input_attribute.h"
28 #include "input_client_stub.h"
29 #include "input_method_info.h"
30 #include "input_window_info.h"
31 #include "iremote_broker.h"
32 #include "iremote_object.h"
33 #include "iremote_proxy.h"
34 #include "itypes_util.h"
35 #include "message_parcel.h"
36 #include "nocopyable.h"
37 #include "refbase.h"
38 
39 namespace OHOS {
40 namespace MiscServices {
41 class InputMethodSystemAbilityProxy : public IRemoteProxy<IInputMethodSystemAbility> {
42 public:
43     explicit InputMethodSystemAbilityProxy(const sptr<IRemoteObject> &object);
44     ~InputMethodSystemAbilityProxy() = default;
45     DISALLOW_COPY_AND_MOVE(InputMethodSystemAbilityProxy);
46 
47     int32_t StartInput(InputClientInfo &inputClientInfo, sptr<IRemoteObject> &agent) override;
48     int32_t ShowCurrentInput() override;
49     int32_t HideCurrentInput() override;
50     int32_t StopInputSession() override;
51     int32_t ShowInput(sptr<IInputClient> client) override;
52     int32_t HideInput(sptr<IInputClient> client) override;
53     int32_t ReleaseInput(sptr<IInputClient> client) override;
54     int32_t RequestShowInput() override;
55     int32_t RequestHideInput() override;
56     std::shared_ptr<Property> GetCurrentInputMethod() override;
57     std::shared_ptr<SubProperty> GetCurrentInputMethodSubtype() override;
58     int32_t GetDefaultInputMethod(std::shared_ptr<Property> &prop, bool isBrief) override;
59     int32_t GetInputMethodConfig(OHOS::AppExecFwk::ElementName &inputMethodConfig) override;
60     int32_t ListInputMethod(InputMethodStatus status, std::vector<Property> &props) override;
61     int32_t SwitchInputMethod(const std::string &name, const std::string &subName, SwitchTrigger trigger) override;
62     int32_t DisplayOptionalInputMethod() override;
63     int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent) override;
64     int32_t InitConnect() override;
65     int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr<IInputMethodCore> &core) override;
66     int32_t ListCurrentInputMethodSubtype(std::vector<SubProperty> &subProps) override;
67     int32_t ListInputMethodSubtype(const std::string &name, std::vector<SubProperty> &subProps) override;
68     int32_t PanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override;
69     int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag) override;
70     bool IsCurrentIme() override;
71     bool IsInputTypeSupported(InputType type) override;
72     bool IsCurrentImeByPid(int32_t pid) override;
73     int32_t StartInputType(InputType type) override;
74     int32_t ExitCurrentInputType() override;
75     int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override;
76     int32_t GetSecurityMode(int32_t &security) override;
77     int32_t IsDefaultIme() override;
78     int32_t ConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent) override;
79     // Deprecated because of no permission check, kept for compatibility
80     int32_t HideCurrentInputDeprecated() override;
81     int32_t ShowCurrentInputDeprecated() override;
82     bool IsDefaultImeSet() override;
83     bool EnableIme(const std::string &bundleName) override;
84 
85 private:
86     static inline BrokerDelegator<InputMethodSystemAbilityProxy> delegator_;
87     using ParcelHandler = std::function<bool(MessageParcel &)>;
88     int32_t SendRequest(int code, ParcelHandler input = nullptr, ParcelHandler output = nullptr);
89     void GetMessageOption(int32_t code, MessageOption &option);
90 };
91 } // namespace MiscServices
92 } // namespace OHOS
93 #endif // FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_SYSTEM_ABILITY_PROXY_H
94