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 ACCESSIBLE_ABILITY_CLIENT_PROXY_H 17 #define ACCESSIBLE_ABILITY_CLIENT_PROXY_H 18 19 #include "accessibility_ipc_interface_code.h" 20 #include "i_accessible_ability_client.h" 21 #include "iremote_proxy.h" 22 23 namespace OHOS { 24 namespace Accessibility { 25 class AccessibleAbilityClientProxy : public IRemoteProxy<IAccessibleAbilityClient> { 26 public: 27 explicit AccessibleAbilityClientProxy(const sptr<IRemoteObject> &object); 28 virtual ~AccessibleAbilityClientProxy() = default; 29 30 /** 31 * @brief Init accessible ability through the proxy object. 32 * @param channel The object of IAccessibleAbilityChannel. 33 * @param channelId The id of channel. 34 */ 35 virtual void Init(const sptr<IAccessibleAbilityChannel> &channel, const int32_t channelId) override; 36 37 /** 38 * @brief Disconnect accessible ability through the proxy object. 39 * @param channelId The id of channel. 40 */ 41 virtual void Disconnect(const int32_t channelId) override; 42 43 /** 44 * @brief Called when an accessibility event occurs through the proxy object. 45 * @param eventInfo The information of accessible event. 46 */ 47 virtual void OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) override; 48 49 /** 50 * @brief Called when a key event occurs through the proxy object. 51 * @param keyEvent Indicates the key event to send. 52 * @param sequence The sequence of the key event. 53 */ 54 virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int32_t sequence) override; 55 56 private: 57 /** 58 * @brief Send the command data from proxy to stub in IPC mechanism. 59 * @param code The code matched the function called. 60 * @param data Serializable data 61 * @param reply The response of IPC 62 * @param option The option parameter of IPC,such as: async,sync 63 * @return true: Write the descriptor successfully; otherwise is not. 64 */ 65 bool SendTransactCmd(AccessibilityInterfaceCode code, MessageParcel &data, 66 MessageParcel &reply, MessageOption &option); 67 68 bool WriteInterfaceToken(MessageParcel &data); 69 70 static inline BrokerDelegator<AccessibleAbilityClientProxy> delegator; 71 }; 72 } // namespace Accessibility 73 } // namespace OHOS 74 #endif // ACCESSIBLE_ABILITY_CLIENT_PROXY_H