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 uint32_t daltonizationColorFilter_ = 0; 47 uint32_t contentTimeout_ = 0; 48 float brightnessDiscount_ = 0.0; 49 float audioBalance_ = 0.0; 50 std::string shortkeyTarget_ = ""; 51 AccessibilityConfig::CaptionProperty captionProperty_ = {}; 52 }; 53 54 class IAccessibleAbilityManagerService : public IRemoteBroker { 55 public: 56 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityManagerService"); 57 58 /** 59 * @brief Sends information about an accessibility event. 60 * @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo. 61 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 62 */ 63 virtual RetError SendEvent(const AccessibilityEventInfo &uiEvent) = 0; 64 65 /** 66 * @brief Register the state observer of AAMS. 67 * @param callback state observer 68 * @return 0: Register ok; otherwise is refused. 69 */ 70 virtual uint32_t RegisterStateObserver(const sptr<IAccessibleAbilityManagerStateObserver> &callback) = 0; 71 72 virtual uint32_t RegisterCaptionObserver(const sptr<IAccessibleAbilityManagerCaptionObserver> &callback) = 0; 73 74 virtual void RegisterEnableAbilityListsObserver( 75 const sptr<IAccessibilityEnableAbilityListsObserver> &observer) = 0; 76 77 /** 78 * @brief Queries the list of accessibility abilities. 79 * @param accessibilityAbilityTypes Indicates the accessibility type specified by AccessibilityAbilityTypes. 80 * @param stateType Indicates the accessibility ability status. 81 * 1 indicates that the ability is enabled; 82 * 2 indicates that the ability is disabled; 83 * 3 indicates that the ability has been installed. 84 * @param infos accessibility ability infos by specified types. 85 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 86 */ 87 virtual RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType, 88 std::vector<AccessibilityAbilityInfo> &infos) = 0; 89 90 /** 91 * @brief Register the element operator, so the AA can get node info from ACE. 92 * @param windowId Window ID 93 * @param operation The callback object. 94 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 95 */ 96 virtual RetError RegisterElementOperator(const int32_t windowId, 97 const sptr<IAccessibilityElementOperator> &operation) = 0; 98 99 /** 100 * @brief Deregister the element operator. 101 * @param windowId Window ID 102 * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure. 103 */ 104 virtual RetError DeregisterElementOperator(const int32_t windowId) = 0; 105 106 virtual RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) = 0; 107 virtual bool GetEnabledState() = 0; 108 virtual RetError GetCaptionState(bool &state) = 0; 109 virtual bool GetTouchGuideState() = 0; 110 virtual bool GetGestureState() = 0; 111 virtual bool GetKeyEventObserverState() = 0; 112 113 virtual RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) = 0; 114 virtual RetError SetCaptionState(const bool state) = 0; 115 116 virtual RetError EnableAbility(const std::string &name, const uint32_t capabilities) = 0; 117 virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) = 0; 118 virtual RetError DisableAbility(const std::string &name) = 0; 119 virtual int32_t GetActiveWindow() = 0; 120 121 virtual RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) = 0; 122 virtual RetError DisableUITestAbility() = 0; 123 124 virtual RetError SetScreenMagnificationState(const bool state) = 0; 125 virtual RetError SetShortKeyState(const bool state) = 0; 126 virtual RetError SetMouseKeyState(const bool state) = 0; 127 virtual RetError SetMouseAutoClick(const int32_t time) = 0; 128 virtual RetError SetShortkeyTarget(const std::string &name) = 0; 129 virtual RetError SetHighContrastTextState(const bool state) = 0; 130 virtual RetError SetInvertColorState(const bool state) = 0; 131 virtual RetError SetAnimationOffState(const bool state) = 0; 132 virtual RetError SetAudioMonoState(const bool state) = 0; 133 virtual RetError SetDaltonizationColorFilter(const uint32_t filter) = 0; 134 virtual RetError SetContentTimeout(const uint32_t time) = 0; 135 virtual RetError SetBrightnessDiscount(const float discount) = 0; 136 virtual RetError SetAudioBalance(const float balance) = 0; 137 138 virtual RetError GetScreenMagnificationState(bool &state) = 0; 139 virtual RetError GetShortKeyState(bool &state) = 0; 140 virtual RetError GetMouseKeyState(bool &state) = 0; 141 virtual RetError GetMouseAutoClick(int32_t &time) = 0; 142 virtual RetError GetShortkeyTarget(std::string &name) = 0; 143 virtual RetError GetHighContrastTextState(bool &state) = 0; 144 virtual RetError GetInvertColorState(bool &state) = 0; 145 virtual RetError GetAnimationOffState(bool &state) = 0; 146 virtual RetError GetAudioMonoState(bool &state) = 0; 147 virtual RetError GetDaltonizationColorFilter(uint32_t &type) = 0; 148 virtual RetError GetContentTimeout(uint32_t &timer) = 0; 149 virtual RetError GetBrightnessDiscount(float &brightness) = 0; 150 virtual RetError GetAudioBalance(float &balance) = 0; 151 virtual void GetAllConfigs(AccessibilityConfigData& configData) = 0; 152 153 virtual uint32_t RegisterConfigObserver(const sptr<IAccessibleAbilityManagerConfigObserver> &callback) = 0; 154 enum class Message { 155 SEND_EVENT = 0, 156 REGISTER_STATE_CALLBACK, 157 GET_ABILITYLIST, 158 REGISTER_INTERACTION_CONNECTION, 159 DEREGISTER_INTERACTION_CONNECTION, 160 GET_CAPTION_PROPERTY, 161 SET_CAPTION_PROPERTY, 162 SET_CAPTION_STATE, 163 REGISTER_CAPTION_PROPERTY_CALLBACK, 164 GET_ENABLED, 165 GET_CAPTION_STATE, 166 GET_TOUCH_GUIDE_STATE, 167 GET_GESTURE_STATE, 168 GET_KEY_EVENT_OBSERVE_STATE, 169 ENABLE_ABILITIES, 170 GET_ENABLED_OBJECT, 171 DISABLE_ABILITIES, 172 ENABLE_UI_TEST_ABILITY, 173 DISABLE_UI_TEST_ABILITY, 174 GET_ACTIVE_WINDOW, 175 SET_SCREENMAGNIFIER_STATE, 176 SET_SHORTKEY_STATE, 177 SET_MOUSEKEY_STATE, 178 SET_SHORTKEY_TARGET, 179 SET_MOUSEKEY_AUTOCLICK, 180 SET_INVERTCOLOR_STATE, 181 SET_HIGHCONTRASTTEXT_STATE, 182 SET_AUDIOMONO_STATE, 183 SET_ANIMATIONOFF_STATE, 184 SET_DALTONIZATION_COLORFILTER, 185 SET_CONTENT_TIMEOUT, 186 SET_BRIGHTNESS_DISCOUNT, 187 SET_AUDIO_BALANCE, 188 GET_SCREENMAGNIFIER_STATE, 189 GET_SHORTKEY_STATE, 190 GET_MOUSEKEY_STATE, 191 GET_SHORTKEY_TARGET, 192 GET_MOUSEKEY_AUTOCLICK, 193 GET_INVERTCOLOR_STATE, 194 GET_HIGHCONTRASTTEXT_STATE, 195 GET_AUDIOMONO_STATE, 196 GET_ANIMATIONOFF_STATE, 197 GET_DALTONIZATION_COLORFILTER, 198 GET_CONTENT_TIMEOUT, 199 GET_BRIGHTNESS_DISCOUNT, 200 GET_AUDIO_BALANCE, 201 GET_ALL_CONFIGS, 202 REGISTER_ENABLE_ABILITY_LISTS_OBSERVER, 203 REGISTER_CONFIG_CALLBACK, 204 }; 205 }; 206 } // namespace Accessibility 207 } // namespace OHOS 208 #endif // INTERFACE_ACCESSIBILITY_ABILITY_MANAGER_SERVICE_H