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