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_PROXY_H 17 #define ACCESSIBILITY_ABILITY_MANAGER_SERVICE_PROXY_H 18 19 #include "i_accessible_ability_manager_service.h" 20 #include "iremote_proxy.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 /* 25 * The class define the interface to call ABMS API. 26 */ 27 class AccessibleAbilityManagerServiceProxy : public IRemoteProxy<IAccessibleAbilityManagerService> { 28 public: 29 /** 30 * @brief construct function 31 * @param object The object of IPC 32 */ 33 explicit AccessibleAbilityManagerServiceProxy(const sptr<IRemoteObject> &object); 34 35 /** 36 * @brief destruct function 37 */ 38 virtual ~AccessibleAbilityManagerServiceProxy() override; 39 40 /** 41 * @brief Sends information about an accessibility event. 42 * @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo. 43 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 44 */ 45 virtual RetError SendEvent(const AccessibilityEventInfo &uiEvent) override; 46 47 /** 48 * @brief Register the state observer of AAMS. 49 * @param callback state observer 50 * @return 0: Register ok; otherwise is refused. 51 */ 52 virtual uint32_t RegisterStateObserver(const sptr<IAccessibleAbilityManagerStateObserver> &callback) override; 53 54 virtual uint32_t RegisterCaptionObserver(const sptr<IAccessibleAbilityManagerCaptionObserver> &callback) override; 55 56 virtual void RegisterEnableAbilityListsObserver( 57 const sptr<IAccessibilityEnableAbilityListsObserver> &observer) override; 58 59 /** 60 * @brief Queries the list of accessibility abilities. 61 * @param accessibilityAbilityTypes Indicates the accessibility type specified by AccessibilityAbilityTypes. 62 * @param stateType Indicates the accessibility ability status. 63 * 1 indicates that the ability is enabled; 64 * 2 indicates that the ability is disabled; 65 * 3 indicates that the ability has been installed. 66 * @param infos accessibility ability infos by specified types. 67 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 68 */ 69 virtual RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType, 70 std::vector<AccessibilityAbilityInfo> &infos) override; 71 72 /** 73 * @brief Register the element operator, so the AA can get node info from ACE. 74 * @param windowId Window ID 75 * @param operation The callback object. 76 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 77 */ 78 virtual RetError RegisterElementOperator(const int32_t windowId, 79 const sptr<IAccessibilityElementOperator> &operation) override; 80 81 /** 82 * @brief Deregister the element operator. 83 * @param windowId Window ID 84 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 85 */ 86 virtual RetError DeregisterElementOperator(const int32_t windowId) override; 87 88 virtual RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) override; 89 virtual RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) override; 90 virtual RetError SetCaptionState(const bool state) override; 91 92 virtual bool GetEnabledState() override; 93 virtual RetError GetCaptionState(bool &state) override; 94 virtual bool GetTouchGuideState() override; 95 virtual bool GetGestureState() override; 96 virtual bool GetKeyEventObserverState() override; 97 98 virtual RetError EnableAbility(const std::string &name, const uint32_t capabilities) override; 99 virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override; 100 virtual RetError DisableAbility(const std::string &name) override; 101 virtual int32_t GetActiveWindow() override; 102 103 virtual RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) override; 104 virtual RetError DisableUITestAbility() override; 105 106 virtual RetError SetScreenMagnificationState(const bool state) override; 107 virtual RetError SetShortKeyState(const bool state) override; 108 virtual RetError SetMouseKeyState(const bool state) override; 109 virtual RetError SetMouseAutoClick(const int32_t time) override; 110 virtual RetError SetShortkeyTarget(const std::string &name) override; 111 virtual RetError SetHighContrastTextState(const bool state) override; 112 virtual RetError SetInvertColorState(const bool state) override; 113 virtual RetError SetAnimationOffState(const bool state) override; 114 virtual RetError SetAudioMonoState(const bool state) override; 115 virtual RetError SetDaltonizationColorFilter(const uint32_t filter) override; 116 virtual RetError SetContentTimeout(const uint32_t time) override; 117 virtual RetError SetBrightnessDiscount(const float discount) override; 118 virtual RetError SetAudioBalance(const float balance) override; 119 120 virtual RetError GetScreenMagnificationState(bool &state) override; 121 virtual RetError GetShortKeyState(bool &state) override; 122 virtual RetError GetMouseKeyState(bool &state) override; 123 virtual RetError GetMouseAutoClick(int32_t &time) override; 124 virtual RetError GetShortkeyTarget(std::string &name) override; 125 virtual RetError GetHighContrastTextState(bool &state) override; 126 virtual RetError GetInvertColorState(bool &state) override; 127 virtual RetError GetAnimationOffState(bool &state) override; 128 virtual RetError GetAudioMonoState(bool &state) override; 129 virtual RetError GetDaltonizationColorFilter(uint32_t &type) override; 130 virtual RetError GetContentTimeout(uint32_t &timer) override; 131 virtual RetError GetBrightnessDiscount(float &brightness) override; 132 virtual RetError GetAudioBalance(float &balance) override; 133 virtual void GetAllConfigs(AccessibilityConfigData& configData) override; 134 virtual uint32_t RegisterConfigObserver(const sptr<IAccessibleAbilityManagerConfigObserver> &callback) override; 135 private: 136 /** 137 * @brief Write the descriptor of IPC. 138 * @param data It is include the descriptor of IPC. 139 * @return true: Write the descriptor successfully; otherwise is not. 140 */ 141 bool WriteInterfaceToken(MessageParcel& data); 142 143 /** 144 * @brief Send the command data from proxy to stub in IPC mechanism. 145 * @param code The code matched the function called. 146 * @param data Serializable data 147 * @param reply The response of IPC 148 * @param option The option parameter of IPC,such as: async,sync 149 * @return true: Write the descriptor successfully; otherwise is not. 150 */ 151 bool SendTransactCmd(IAccessibleAbilityManagerService::Message code, MessageParcel &data, 152 MessageParcel &reply, MessageOption &option); 153 static inline BrokerDelegator<AccessibleAbilityManagerServiceProxy> delegator; 154 }; 155 } // namespace Accessibility 156 } // namespace OHOS 157 #endif // ACCESSIBILITY_ABILITY_MANAGER_SERVICE_PROXY_H