• 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_STATE_EVENT_H
17 #define ACCESSIBILITY_STATE_EVENT_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace Accessibility {
23 enum AccessibilityStateEventType : int {
24     EVENT_ACCESSIBILITY_STATE_CHANGED = 0x00000001,
25     EVENT_TOUCH_GUIDE_STATE_CHANGED = 0x00000002,
26     EVENT_CAPTION_STATE_CHANGED = 0x00000004,
27     EVENT_KEVEVENT_STATE_CHANGED = 0x00000008,
28     EVENT_GESTURE_STATE_CHANGED = 0x00000010,
29 };
30 
31 /*
32 * This class is used for ASAC as the listener of AAMS.
33 */
34 class AccessibilityStateEvent {
35 public:
36     AccessibilityStateEvent();
37 
38     /**
39      * @brief Get the type of the state event.
40      * @return EVENT_ACCESSIBILITY_STATE_CHANGED/EVENT_TOUCH_GUIDE_STATE_CHANGED
41      * @since 3
42      * @sysCap Accessibility
43      */
44     AccessibilityStateEventType GetEventType() const;
45 
46     /**
47      * @brief Get the state of the ability.
48      * @return  0:enabled;  otherwise is disabled;
49      * @since 3
50      * @sysCap Accessibility
51      */
52     int GetEventResult() const;
53 
54     /**
55      * @brief Get the description of the ability.
56      * @return The description of the ability
57      * @since 3
58      * @sysCap Accessibility
59      */
60     std::string GetEventMsg() const;
61 
62     /**
63      * @brief Set the type of the state event.
64      * @param eventType EVENT_ACCESSIBILITY_STATE_CHANGED/EVENT_TOUCH_GUIDE_STATE_CHANGED
65      * @since 3
66      * @sysCap Accessibility
67      */
68     void SetEventType(const AccessibilityStateEventType eventType);
69 
70     /**
71      * @brief Get the state of the ability.
72      * @param enabled  0:enabled;  otherwise is disabled;
73      * @since 3
74      * @sysCap Accessibility
75      */
76     void SetEventResult(const int enabled);
77 
78     /**
79      * @brief Set the description of the ability.
80      * @param description The description of the ability
81      * @since 3
82      * @sysCap Accessibility
83      */
84     void SetEventMsg(std::string &description);
85 private:
86     AccessibilityStateEventType eventType_ = EVENT_ACCESSIBILITY_STATE_CHANGED;
87     int enabled_ = 0;
88     std::string  describeEvent_ = "";
89 };
90 
91 class AccessibilityStateObserver {
92 public:
93     /**
94      * @brief Destruct
95      * @param
96      * @return
97      * @since 3
98      * @sysCap Accessibility
99      */
100     virtual ~AccessibilityStateObserver() = default;
101 
102     /**
103      * @brief Receives notifications on accessibility status changes.
104      * @param stateEvent Indicates the status change event.
105      * @return
106      * @since 3
107      * @sysCap Accessibility
108      */
109     virtual void OnStateChanged(const bool state) = 0;
110 };
111 } // namespace Accessibility
112 } // namespace OHOS
113 #endif