1 /*
2  * Copyright (c) 2021-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 MULTIMODAL_INPUT_CONNECT_PROXY_H
17 #define MULTIMODAL_INPUT_CONNECT_PROXY_H
18 
19 #include "iremote_object.h"
20 #include "iremote_proxy.h"
21 #include "nocopyable.h"
22 #include "system_ability.h"
23 
24 #include "i_multimodal_input_connect.h"
25 #include "mmi_event_observer.h"
26 #include "multimodalinput_ipc_interface_code.h"
27 
28 namespace OHOS {
29 namespace MMI {
30 class MultimodalInputConnectProxy final : public IRemoteProxy<IMultimodalInputConnect> {
31 public:
32     explicit MultimodalInputConnectProxy(const sptr<IRemoteObject> &impl);
33     DISALLOW_COPY_AND_MOVE(MultimodalInputConnectProxy);
34     ~MultimodalInputConnectProxy() override;
35 
36     int32_t AllocSocketFd(const std::string &programName, const int32_t moduleType,
37         int32_t &socketFd, int32_t &tokenType) override;
38     int32_t AddInputEventFilter(sptr<IEventFilter> filter, int32_t filterId, int32_t priority,
39         uint32_t deviceTags) override;
40     int32_t NotifyNapOnline() override;
41     int32_t RemoveInputEventObserver() override;
42     int32_t RemoveInputEventFilter(int32_t filterId) override;
43     int32_t SetMouseScrollRows(int32_t rows) override;
44     int32_t GetMouseScrollRows(int32_t &rows) override;
45     int32_t SetPointerSize(int32_t size) override;
46     int32_t SetNapStatus(int32_t pid, int32_t uid, std::string bundleName, int32_t napStatus) override;
47     int32_t GetPointerSize(int32_t &size) override;
48     int32_t SetCustomCursor(int32_t pid, int32_t windowId, int32_t focusX, int32_t focusY, void* pixelMap) override;
49     int32_t SetMouseIcon(int32_t windowId, void* pixelMap) override;
50     int32_t ClearWindowPointerStyle(int32_t pid, int32_t windowId) override;
51     int32_t SetMouseHotSpot(int32_t pid, int32_t windowId, int32_t hotSpotX, int32_t hotSpotY) override;
52     int32_t SetMousePrimaryButton(int32_t primaryButton) override;
53     int32_t GetMousePrimaryButton(int32_t &primaryButton) override;
54     int32_t SetHoverScrollState(bool state) override;
55     int32_t GetHoverScrollState(bool &state) override;
56     int32_t SetPointerVisible(bool visible, int32_t priority) override;
57     int32_t IsPointerVisible(bool &visible) override;
58     int32_t MarkProcessed(int32_t eventType, int32_t eventId) override;
59     int32_t SetPointerColor(int32_t color) override;
60     int32_t GetPointerColor(int32_t &color) override;
61     int32_t SetPointerSpeed(int32_t speed) override;
62     int32_t GetPointerSpeed(int32_t &speed) override;
63     int32_t SetPointerStyle(int32_t windowId, PointerStyle pointerStyle, bool isUiExtension = false) override;
64     int32_t GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle, bool isUiExtension = false) override;
65     int32_t SupportKeys(int32_t deviceId, std::vector<int32_t> &keys, std::vector<bool> &keystroke) override;
66     int32_t GetDeviceIds(std::vector<int32_t> &ids) override;
67     int32_t GetDevice(int32_t deviceId, std::shared_ptr<InputDevice> &inputDevice) override;
68     int32_t RegisterDevListener() override;
69     int32_t UnregisterDevListener() override;
70     int32_t GetKeyboardType(int32_t deviceId, int32_t &keyboardType) override;
71     int32_t SetKeyboardRepeatDelay(int32_t delay) override;
72     int32_t SetKeyboardRepeatRate(int32_t rate) override;
73     int32_t GetKeyboardRepeatDelay(int32_t &delay) override;
74     int32_t GetKeyboardRepeatRate(int32_t &rate) override;
75     int32_t AddInputHandler(InputHandlerType handlerType, HandleEventType eventType,
76         int32_t priority, uint32_t deviceTags) override;
77     int32_t RemoveInputHandler(InputHandlerType handlerType, HandleEventType eventType,
78         int32_t priority, uint32_t deviceTags) override;
79     int32_t MarkEventConsumed(int32_t eventId) override;
80     int32_t MoveMouseEvent(int32_t offsetX, int32_t offsetY) override;
81     int32_t InjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent, bool isNativeInject) override;
82     int32_t SubscribeKeyEvent(int32_t subscribeId, const std::shared_ptr<KeyOption> option) override;
83     int32_t UnsubscribeKeyEvent(int32_t subscribeId) override;
84     int32_t SubscribeSwitchEvent(int32_t subscribeId, int32_t switchType) override;
85     int32_t UnsubscribeSwitchEvent(int32_t subscribeId) override;
86     int32_t InjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent, bool isNativeInject) override;
87     int32_t SetAnrObserver() override;
88     int32_t GetDisplayBindInfo(DisplayBindInfos &infos) override;
89     int32_t GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t, int32_t, std::string>, int32_t> &datas) override;
90     int32_t SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg) override;
91     int32_t GetFunctionKeyState(int32_t funcKey, bool &state) override;
92     int32_t SetFunctionKeyState(int32_t funcKey, bool enable) override;
93     int32_t SetPointerLocation(int32_t x, int32_t y) override;
94     virtual int32_t SetMouseCaptureMode(int32_t windowId, bool isCaptureMode) override;
95     int32_t GetWindowPid(int32_t windowId) override;
96     int32_t AppendExtraData(const ExtraData& extraData) override;
97     int32_t EnableCombineKey(bool enable) override;
98     int32_t EnableInputDevice(bool enable) override;
99     int32_t SetKeyDownDuration(const std::string &businessId, int32_t delay) override;
100     int32_t SetTouchpadScrollSwitch(bool switchFlag) override;
101     int32_t GetTouchpadScrollSwitch(bool &switchFlag) override;
102     int32_t SetTouchpadScrollDirection(bool state) override;
103     int32_t GetTouchpadScrollDirection(bool &state) override;
104     int32_t SetTouchpadTapSwitch(bool switchFlag) override;
105     int32_t GetTouchpadTapSwitch(bool &switchFlag) override;
106     int32_t SetTouchpadPointerSpeed(int32_t speed) override;
107     int32_t GetTouchpadPointerSpeed(int32_t &speed) override;
108     int32_t SetTouchpadPinchSwitch(bool switchFlag) override;
109     int32_t GetTouchpadPinchSwitch(bool &switchFlag) override;
110     int32_t SetTouchpadSwipeSwitch(bool switchFlag) override;
111     int32_t GetTouchpadSwipeSwitch(bool &switchFlag) override;
112     int32_t SetTouchpadRightClickType(int32_t type) override;
113     int32_t GetTouchpadRightClickType(int32_t &type) override;
114     int32_t SetTouchpadRotateSwitch(bool rotateSwitch) override;
115     int32_t GetTouchpadRotateSwitch(bool &rotateSwitch) override;
116     int32_t SetTouchpadDoubleTapAndDragState(bool switchFlag) override;
117     int32_t GetTouchpadDoubleTapAndDragState(bool &switchFlag) override;
118     int32_t SetShieldStatus(int32_t shieldMode, bool isShield) override;
119     int32_t GetShieldStatus(int32_t shieldMode, bool &isShield) override;
120     int32_t GetKeyState(std::vector<int32_t> &pressedKeys, std::map<int32_t, int32_t> &specialKeysState) override;
121     int32_t Authorize(bool isAuthorize) override;
122     int32_t CancelInjection() override;
123     int32_t SetPixelMapData(int32_t infoId, void* pixelMap) override;
124     int32_t HasIrEmitter(bool &hasIrEmitter) override;
125     int32_t GetInfraredFrequencies(std::vector<InfraredFrequency>& requencys) override;
126     int32_t TransmitInfrared(int64_t number, std::vector<int64_t>& pattern) override;
127     int32_t SetCurrentUser(int32_t userId) override;
128     int32_t AddVirtualInputDevice(std::shared_ptr<InputDevice> device, int32_t &deviceId) override;
129     int32_t RemoveVirtualInputDevice(int32_t deviceId) override;
130     int32_t EnableHardwareCursorStats(bool enable) override;
131     int32_t GetHardwareCursorStats(uint32_t &frameCount, uint32_t &vsyncCount) override;
132     int32_t GetIntervalSinceLastInput(int64_t &timeInterval) override;
133 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
134     int32_t GetPointerSnapshot(void *pixelMapPtr) override;
135 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
136 #ifdef OHOS_BUILD_ENABLE_ANCO
137     int32_t AncoAddChannel(sptr<IAncoChannel> channel) override;
138     int32_t AncoRemoveChannel(sptr<IAncoChannel> channel) override;
139 #endif // OHOS_BUILD_ENABLE_ANCO
140 	int32_t TransferBinderClientSrv(const sptr<IRemoteObject> &binderClientObject) override;
141     int32_t SkipPointerLayer(bool isSkip) override;
142 
143 private:
144     static inline BrokerDelegator<MultimodalInputConnectProxy> delegator_;
145     int32_t SetTouchpadBoolData(bool date, int32_t type);
146     int32_t GetTouchpadBoolData(bool &date, int32_t type);
147     int32_t SetTouchpadInt32Data(int32_t date, int32_t type);
148     int32_t GetTouchpadInt32Data(int32_t &date, int32_t type);
149 };
150 } // namespace MMI
151 } // namespace OHOS
152 #endif // MULTIMODAL_INPUT_CONNECT_PROXY_H
153