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 ACCESSIBILITY_ABILITY_MANAGER_SERVICE_CLIENT_PROXY_H 17 #define ACCESSIBILITY_ABILITY_MANAGER_SERVICE_CLIENT_PROXY_H 18 19 #include <cstdint> 20 #include <memory> 21 #include "accessible_ability_manager_service_interface.h" 22 #include "accessible_ability_manager_service_state_interface.h" 23 #include "accessible_ability_manager_service_caption_property_interface.h" 24 #include "accessibility_event_info.h" 25 #include "iremote_proxy.h" 26 #include "iremote_object.h" 27 28 namespace OHOS { 29 namespace Accessibility { 30 /* 31 * The class define the interface to call ABMS API. 32 */ 33 class AccessibleAbilityManagerServiceClientProxy : public IRemoteProxy<IAccessibleAbilityManagerServiceClient> { 34 public: 35 /** 36 * @brief construct function 37 * @param object The object of IPC 38 * @return 39 */ 40 explicit AccessibleAbilityManagerServiceClientProxy(const sptr<IRemoteObject>& object); 41 42 /** 43 * @brief destruct function 44 * @param 45 * @return 46 */ 47 virtual ~AccessibleAbilityManagerServiceClientProxy() override; 48 49 /** 50 * @brief Sends information about an accessibility event. 51 * @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo. 52 * @param accountId The user id. 53 * @return true: send ok; otherwise is refused. 54 */ 55 virtual void SendEvent(const AccessibilityEventInfo& uiEvent, const int accountId) override; 56 57 /** 58 * @brief Register the state observer of AAMS. 59 * @param callback state observer 60 * @param accountId The user id. 61 * @return 0: Register ok; otherwise is refused. 62 */ 63 virtual uint32_t RegisterStateCallback( 64 const sptr<IAccessibleAbilityManagerServiceState>& callback, const int accountId) override; 65 66 virtual uint32_t RegisterCaptionPropertyCallback( 67 const sptr<IAccessibleAbilityManagerServiceCaptionProperty>& callback, const int accountId) override; 68 69 /** 70 * @brief Queries the list of accessibility abilities. 71 * @param accessibilityAbilityTypes Indicates the accessibility type specified by 72 * AccessibilityAbilityInfo#ACCESSIBILITY_ABILITY_TYPE_SPOKEN. 73 * @param stateType Indicates the accessibility ability status. 1 indicates that the ability is enabled; 74 * 2 indicates that the ability is disabled; 4 indicates that the ability has been installed. 75 * @return 76 */ 77 virtual std::vector<AccessibilityAbilityInfo> GetAbilityList( 78 const uint32_t abilityTypes, const int32_t stateType) override; 79 80 /** 81 * @brief Register the interaction operation, so the AA can get node info from ACE. 82 * @param windowId Window ID 83 * @param operation The callback object. 84 * @param accountId User ID 85 * @return 0: Succeed ; otherwise is failed. 86 */ 87 virtual void RegisterElementOperator( 88 const int windowId, const sptr<IAccessibilityElementOperator>& operation, const int accountId) override; 89 90 /** 91 * @brief Deregister the interaction operation. 92 * @param windowId Window ID 93 * @return 94 */ 95 virtual void DeregisterElementOperator(const int windowId) override; 96 97 virtual CaptionProperty GetCaptionProperty() override; 98 virtual bool SetCaptionProperty(const CaptionProperty& caption) override; 99 virtual bool SetCaptionState(const bool state) override; 100 virtual bool SetEnabled(const bool state) override; 101 102 virtual bool GetEnabledState() override; 103 virtual bool GetCaptionState() override; 104 virtual bool GetTouchGuideState() override; 105 virtual bool GetGestureState() override; 106 virtual bool GetKeyEventObserverState() override; 107 108 virtual bool SetTouchGuideState(const bool state) override; 109 virtual bool SetGestureState(const bool state) override; 110 virtual bool SetKeyEventObserverState(const bool state) override; 111 112 virtual bool SetEnabledObj(std::map<std::string, AppExecFwk::ElementName> it) override; 113 virtual std::map<std::string, AppExecFwk::ElementName> GetEnabledAbilities() override; 114 virtual std::vector<AccessibilityAbilityInfo> GetInstalledAbilities() override; 115 116 virtual bool DisableAbilities(std::map<std::string, AppExecFwk::ElementName> it) override; 117 virtual int GetActiveWindow() override; 118 119 virtual bool RegisterUITestAbilityConnectionClient(const sptr<IRemoteObject>& obj) override; 120 virtual bool DeregisterUITestAbilityConnectionClient() override; 121 122 /** 123 * @brief Get IPC object. 124 * @param 125 * @return IPC object 126 */ 127 sptr<IRemoteObject> GetObject(); 128 private: 129 /** 130 * @brief Write the descriptor of IPC. 131 * @param data It is include the descriptor of IPC. 132 * @return true: Write the descriptor successfully; otherwise is not. 133 */ 134 bool WriteInterfaceToken(MessageParcel& data); 135 static inline BrokerDelegator<AccessibleAbilityManagerServiceClientProxy> delegator; 136 }; 137 } // namespace Accessibility 138 } // namespace OHOS 139 #endif