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 INTERFACE_ACCESSIBILITY_ABILITY_MANAGER_SERVICE_H 17 #define INTERFACE_ACCESSIBILITY_ABILITY_MANAGER_SERVICE_H 18 19 #include <map> 20 #include <vector> 21 #include "accessibility_ability_info.h" 22 #include "accessibility_caption.h" 23 #include "accessibility_event_info.h" 24 #include "i_accessibility_element_operator.h" 25 #include "i_accessibility_enable_ability_lists_observer.h" 26 #include "i_accessible_ability_manager_caption_observer.h" 27 #include "i_accessible_ability_manager_config_observer.h" 28 #include "i_accessible_ability_manager_state_observer.h" 29 #include "iremote_broker.h" 30 31 namespace OHOS { 32 namespace Accessibility { 33 /* 34 * The class define the interface to call ABMS API. 35 */ 36 struct AccessibilityConfigData { 37 bool highContrastText_ = false; 38 bool invertColor_ = false; 39 bool animationOff_ = false; 40 bool audioMono_ = false; 41 bool mouseKey_ = false; 42 bool captionState_ = false; 43 bool screenMagnifier_ = false; 44 bool shortkey_ = false; 45 int32_t mouseAutoClick_ = 0; 46 bool daltonizationState_ = false; 47 uint32_t daltonizationColorFilter_ = 0; 48 uint32_t contentTimeout_ = 0; 49 float brightnessDiscount_ = 0.0; 50 float audioBalance_ = 0.0; 51 std::string shortkeyTarget_ = ""; 52 uint32_t clickResponseTime_ = 0; 53 bool ignoreRepeatClickState_ = false; 54 uint32_t ignoreRepeatClickTime_ = 0; 55 AccessibilityConfig::CaptionProperty captionProperty_ = {}; 56 std::vector<std::string> shortkeyMultiTarget_ = {}; 57 }; 58 59 class IAccessibleAbilityManagerService : public IRemoteBroker { 60 public: 61 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityManagerService"); 62 63 /** 64 * @brief Sends information about an accessibility event. 65 * @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo. 66 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 67 */ 68 virtual RetError SendEvent(const AccessibilityEventInfo &uiEvent, const int32_t flag = 0) = 0; 69 70 /** 71 * @brief Register the state observer of AAMS. 72 * @param callback state observer 73 * @return 0: Register ok; otherwise is refused. 74 */ 75 virtual uint32_t RegisterStateObserver(const sptr<IAccessibleAbilityManagerStateObserver> &callback) = 0; 76 77 virtual uint32_t RegisterCaptionObserver(const sptr<IAccessibleAbilityManagerCaptionObserver> &callback) = 0; 78 79 virtual void RegisterEnableAbilityListsObserver( 80 const sptr<IAccessibilityEnableAbilityListsObserver> &observer) = 0; 81 82 /** 83 * @brief Queries the list of accessibility abilities. 84 * @param accessibilityAbilityTypes Indicates the accessibility type specified by AccessibilityAbilityTypes. 85 * @param stateType Indicates the accessibility ability status. 86 * 1 indicates that the ability is enabled; 87 * 2 indicates that the ability is disabled; 88 * 3 indicates that the ability has been installed. 89 * @param infos accessibility ability infos by specified types. 90 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 91 */ 92 virtual RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType, 93 std::vector<AccessibilityAbilityInfo> &infos) = 0; 94 95 /** 96 * @brief Register the element operator, so the AA can get node info from ACE. 97 * @param windowId Window ID 98 * @param operation The callback object. 99 * @param isApp Whether an application. 100 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 101 */ 102 virtual RetError RegisterElementOperator(const int32_t windowId, 103 const sptr<IAccessibilityElementOperator> &operation, bool isApp = true) = 0; 104 105 /** 106 * @brief Register the element operator, so the AA can get node info from ACE. 107 * @param parameter The Register parameters. 108 * @param operation The callback object. 109 * @param isApp whether an application. 110 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 111 */ 112 virtual RetError RegisterElementOperator(Registration parameter, 113 const sptr<IAccessibilityElementOperator> &operation, bool isApp = false) = 0; 114 115 /** 116 * @brief Deregister the element operator. 117 * @param windowId Window ID 118 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 119 */ 120 virtual RetError DeregisterElementOperator(const int32_t windowId) = 0; 121 122 /** 123 * @brief Deregister the element operator. 124 * @param windowId Window ID 125 * @param treeId Tree ID 126 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 127 */ 128 virtual RetError DeregisterElementOperator(const int32_t windowId, const int32_t treeId) = 0; 129 130 virtual RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) = 0; 131 virtual bool GetEnabledState() = 0; 132 virtual RetError GetCaptionState(bool &state) = 0; 133 virtual bool GetTouchGuideState() = 0; 134 virtual bool GetGestureState() = 0; 135 virtual bool GetKeyEventObserverState() = 0; 136 137 virtual RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) = 0; 138 virtual RetError SetCaptionState(const bool state) = 0; 139 140 virtual RetError EnableAbility(const std::string &name, const uint32_t capabilities) = 0; 141 virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) = 0; 142 virtual RetError DisableAbility(const std::string &name) = 0; 143 virtual int32_t GetActiveWindow() = 0; 144 145 virtual RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) = 0; 146 virtual RetError DisableUITestAbility() = 0; 147 148 virtual RetError SetScreenMagnificationState(const bool state) = 0; 149 virtual RetError SetShortKeyState(const bool state) = 0; 150 virtual RetError SetMouseKeyState(const bool state) = 0; 151 virtual RetError SetMouseAutoClick(const int32_t time) = 0; 152 virtual RetError SetShortkeyTarget(const std::string &name) = 0; 153 virtual RetError SetShortkeyMultiTarget(const std::vector<std::string> &name) = 0; 154 virtual RetError SetHighContrastTextState(const bool state) = 0; 155 virtual RetError SetInvertColorState(const bool state) = 0; 156 virtual RetError SetAnimationOffState(const bool state) = 0; 157 virtual RetError SetAudioMonoState(const bool state) = 0; 158 virtual RetError SetDaltonizationState(const bool state) = 0; 159 virtual RetError SetDaltonizationColorFilter(const uint32_t filter) = 0; 160 virtual RetError SetContentTimeout(const uint32_t time) = 0; 161 virtual RetError SetBrightnessDiscount(const float discount) = 0; 162 virtual RetError SetAudioBalance(const float balance) = 0; 163 virtual RetError SetClickResponseTime(const uint32_t time) = 0; 164 virtual RetError SetIgnoreRepeatClickState(const bool state) = 0; 165 virtual RetError SetIgnoreRepeatClickTime(const uint32_t time) = 0; 166 167 virtual RetError GetScreenMagnificationState(bool &state) = 0; 168 virtual RetError GetShortKeyState(bool &state) = 0; 169 virtual RetError GetMouseKeyState(bool &state) = 0; 170 virtual RetError GetMouseAutoClick(int32_t &time) = 0; 171 virtual RetError GetShortkeyTarget(std::string &name) = 0; 172 virtual RetError GetShortkeyMultiTarget(std::vector<std::string> &name) = 0; 173 virtual RetError GetHighContrastTextState(bool &state) = 0; 174 virtual RetError GetInvertColorState(bool &state) = 0; 175 virtual RetError GetAnimationOffState(bool &state) = 0; 176 virtual RetError GetAudioMonoState(bool &state) = 0; 177 virtual RetError GetDaltonizationState(bool &state) = 0; 178 virtual RetError GetDaltonizationColorFilter(uint32_t &type) = 0; 179 virtual RetError GetContentTimeout(uint32_t &timer) = 0; 180 virtual RetError GetBrightnessDiscount(float &brightness) = 0; 181 virtual RetError GetAudioBalance(float &balance) = 0; 182 virtual RetError GetClickResponseTime(uint32_t& time) = 0; 183 virtual RetError GetIgnoreRepeatClickState(bool& state) = 0; 184 virtual RetError GetIgnoreRepeatClickTime(uint32_t& time) = 0; 185 virtual void GetAllConfigs(AccessibilityConfigData& configData) = 0; 186 virtual void GetRealWindowAndElementId(int32_t& windowId, int64_t& elementId) = 0; 187 virtual void GetSceneBoardInnerWinId(int32_t windowId, int64_t elementId, int32_t& innerWid) = 0; 188 virtual RetError GetFocusedWindowId(int32_t &focusedWindowId) = 0; 189 190 virtual uint32_t RegisterConfigObserver(const sptr<IAccessibleAbilityManagerConfigObserver> &callback) = 0; 191 virtual void RemoveRequestId(int32_t requestId) = 0; 192 193 virtual int64_t GetRootParentId(int32_t windowsId, int32_t treeId) = 0; 194 virtual RetError GetAllTreeId(int32_t windowId, std::vector<int32_t> &treeIds) = 0; 195 }; 196 } // namespace Accessibility 197 } // namespace OHOS 198 #endif // INTERFACE_ACCESSIBILITY_ABILITY_MANAGER_SERVICE_H