• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SYSTEM_ABILITY_CLIENT_H
17 #define ACCESSIBILITY_SYSTEM_ABILITY_CLIENT_H
18 
19 #include <map>
20 #include <vector>
21 #include "accessibility_ability_info.h"
22 #include "accessibility_element_operator.h"
23 #include "accessibility_event_info.h"
24 #include "accessibility_state_event.h"
25 #include "accessibility_window_info.h"
26 
27 namespace OHOS {
28 namespace Accessibility {
29 enum AccessibilityControlType : int32_t {
30     CONTENT_CONTROLS = 0x00000001,
31     CONTENT_ICONS = 0x00000002,
32     CONTENT_TEXT = 0x00000004,
33 };
34 
35 /*
36  * The class register the accessibility service observer to AAMS,and
37  * dispatch the accessibility service status changed. such as Service Enable,
38  * Accessibility Enable. It calls AAMS API to send the event to AA.
39  * It supply sington instance for each process.
40  */
41 class AccessibilitySystemAbilityClient {
42 public:
43     /**
44      * @brief Obtains the AccessibilitySystemAbilityClient instance.
45      * @return AccessibilitySystemAbilityClient instance
46      */
47     static std::shared_ptr<AccessibilitySystemAbilityClient> GetInstance();
48 
49     /**
50      * @brief Deconstruct.
51      */
52     virtual ~AccessibilitySystemAbilityClient() = default;
53 
54     /**
55      * @brief Register the element operator, so the AA can get node info from ACE.
56      * @param windowId Window ID
57      * @param operation The callback object.
58      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
59      */
60     virtual RetError RegisterElementOperator(const int32_t windowId,
61         const std::shared_ptr<AccessibilityElementOperator> &operation) = 0;
62 
63     /**
64      * @brief Deregister the element operator.
65      * @param windowId Window ID
66      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
67      */
68     virtual RetError DeregisterElementOperator(const int32_t windowId) = 0;
69 
70     /**
71      * @brief Checks whether accessibility ability is enabled.
72      * @param isEnabled true: enabled; false: disabled
73      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
74      */
75     virtual RetError IsEnabled(bool &isEnabled)= 0;
76 
77     /**
78      * @brief Checks whether touch exploration ability is enabled.
79      * @param isEnabled true: enabled; false: disabled
80      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
81      */
82     virtual RetError IsTouchExplorationEnabled(bool &isEnabled) = 0;
83 
84     /**
85      * @brief Queries the list of accessibility abilities.
86      * @param accessibilityAbilityTypes Indicates the accessibility type specified by AccessibilityAbilityTypes.
87      * @param stateType Indicates the accessibility ability status.
88      *                  1 indicates that the ability is enabled;
89      *                  2 indicates that the ability is disabled;
90      *                  3 indicates that the ability has been installed.
91      * @param infos accessibility ability infos by specified types.
92      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
93      */
94     virtual RetError GetAbilityList(const uint32_t accessibilityAbilityTypes, const AbilityStateType stateType,
95         std::vector<AccessibilityAbilityInfo> &infos) = 0;
96 
97     /**
98      * @brief Sends an accessibility event.
99      * @param eventType  Identifies the accessibility event specified by AccessibilityEventInfo.
100      * @param componentId Indicates the ID of the component to be associated with the event.
101      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
102      */
103     virtual RetError SendEvent(const EventType eventType, const int32_t componentId) = 0;
104 
105     /**
106      * @brief Sends information about an accessibility event.
107      * @param event Indicates the accessibility event information specified by AccessibilityEventInfo.
108      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
109      */
110     virtual RetError SendEvent(const AccessibilityEventInfo &event) = 0;
111 
112     /**
113      * @brief Subscribes to the specified type of accessibility status change events.
114      * @param observer Indicates the observer for listening to status events, which is specified
115      *              by AccessibilityStateObserver.
116      * @param eventType Indicates the status type, which is specified by AccessibilityStateEventType.
117      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
118      */
119     virtual RetError SubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
120         const uint32_t eventType) = 0;
121 
122     /**
123      * @brief Unsubscribe the specified type of accessibility status change events.
124      * @param observer Indicates the registered accessibility status event observer.
125      * @param eventType Indicates the status type, which is specified by AccessibilityStateEventType.
126      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
127      */
128     virtual RetError UnsubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
129         const uint32_t eventType) = 0;
130 
131     /**
132      * @brief Get enabled abilities.
133      * @param enabledAbilities The infos of enabled abilities.
134      * @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
135      */
136     virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) = 0;
137 };
138 } // namespace Accessibility
139 } // namespace OHOS
140 #endif // ACCESSIBILITY_SYSTEM_ABILITY_CLIENT_H