• 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 #include "accessibility_event_info.h"
17 
18 #include <cinttypes>
19 
20 #include "hilog_wrapper.h"
21 
22 namespace OHOS {
23 namespace Accessibility {
SetSource(const int32_t componentId)24 void AccessibilityMemo::SetSource(const int32_t componentId)
25 {
26     HILOG_DEBUG("componentId[%{public}d]", componentId);
27     componentId_ = componentId;
28     elementId_ = componentId;
29 }
30 
GetViewId() const31 int32_t AccessibilityMemo::GetViewId() const
32 {
33     HILOG_DEBUG("componentId_[%{public}d]", componentId_);
34     return componentId_;
35 }
36 
GetAccessibilityId() const37 int32_t AccessibilityMemo::GetAccessibilityId() const
38 {
39     HILOG_DEBUG("called] elementId_[%{public}d]", elementId_);
40     return elementId_;
41 }
42 
SetWindowId(const int32_t windowId)43 void AccessibilityMemo::SetWindowId(const int32_t windowId)
44 {
45     HILOG_DEBUG("windowId[%{public}d]", windowId);
46     windowId_ = windowId;
47 }
48 
GetWindowId() const49 int32_t AccessibilityMemo::GetWindowId() const
50 {
51     HILOG_DEBUG("windowId_[%{public}d]", windowId_);
52     return windowId_;
53 }
54 
GetCurrentIndex() const55 int32_t AccessibilityMemo::GetCurrentIndex() const
56 {
57     HILOG_DEBUG("currentIndex_[%{public}d]", currentIndex_);
58     return currentIndex_;
59 }
60 
SetCurrentIndex(const int32_t index)61 void AccessibilityMemo::SetCurrentIndex(const int32_t index)
62 {
63     currentIndex_ = index;
64     HILOG_DEBUG("currentIndex_[%{public}d]", currentIndex_);
65 }
66 
GetBeginIndex() const67 int32_t AccessibilityMemo::GetBeginIndex() const
68 {
69     HILOG_DEBUG("beginIndex_[%{public}d]", beginIndex_);
70     return beginIndex_;
71 }
72 
SetBeginIndex(const int32_t index)73 void AccessibilityMemo::SetBeginIndex(const int32_t index)
74 {
75     beginIndex_ = index;
76     HILOG_DEBUG("beginIndex_[%{public}d]", beginIndex_);
77 }
78 
GetEndIndex() const79 int32_t AccessibilityMemo::GetEndIndex() const
80 {
81     HILOG_DEBUG("endIndex_[%{public}d]", endIndex_);
82     return endIndex_;
83 }
84 
SetEndIndex(const int32_t index)85 void AccessibilityMemo::SetEndIndex(const int32_t index)
86 {
87     endIndex_ = index;
88     HILOG_DEBUG("endIndex_[%{public}d]", endIndex_);
89 }
90 
GetComponentType() const91 const std::string &AccessibilityMemo::GetComponentType() const
92 {
93     HILOG_DEBUG("componentType_[%{public}s]", componentType_.c_str());
94     return componentType_;
95 }
96 
SetComponentType(const std::string & className)97 void AccessibilityMemo::SetComponentType(const std::string &className)
98 {
99     componentType_ = className;
100     HILOG_DEBUG("componentType_[%{public}s]", componentType_.c_str());
101 }
102 
GetBeforeText() const103 const std::string &AccessibilityMemo::GetBeforeText() const
104 {
105     HILOG_DEBUG("beforeText_[%{public}s]", beforeText_.c_str());
106     return beforeText_;
107 }
108 
SetBeforeText(const std::string & beforeText)109 void AccessibilityMemo::SetBeforeText(const std::string &beforeText)
110 {
111     beforeText_ = beforeText;
112     HILOG_DEBUG("beforeText_[%{public}s]", beforeText_.c_str());
113 }
114 
AddContent(const std::string & content)115 void AccessibilityMemo::AddContent(const std::string &content)
116 {
117     contents_.push_back(content);
118     HILOG_DEBUG("content[%{public}s]", content.c_str());
119 }
120 
GetContentList() const121 const std::vector<std::string> &AccessibilityMemo::GetContentList() const
122 {
123     return contents_;
124 }
125 
GetLatestContent() const126 const std::string &AccessibilityMemo::GetLatestContent() const
127 {
128     HILOG_DEBUG("latestContent_[%{public}s]", latestContent_.c_str());
129     return latestContent_;
130 }
131 
SetLatestContent(const std::string & content)132 void AccessibilityMemo::SetLatestContent(const std::string &content)
133 {
134     latestContent_ = content;
135     HILOG_DEBUG("latestContent_[%{public}s]", latestContent_.c_str());
136 }
137 
GetDescription() const138 const std::string &AccessibilityMemo::GetDescription() const
139 {
140     HILOG_DEBUG("description_[%{public}s]", description_.c_str());
141     return description_;
142 }
143 
SetDescription(const std::string & contentDescription)144 void AccessibilityMemo::SetDescription(const std::string &contentDescription)
145 {
146     description_ = contentDescription;
147     HILOG_DEBUG("description_[%{public}s]", description_.c_str());
148 }
149 
SetItemCounts(const int32_t itemCounts)150 void AccessibilityMemo::SetItemCounts(const int32_t itemCounts)
151 {
152     itemCounts_ = itemCounts;
153     HILOG_DEBUG("itemCounts_[%{public}d]", itemCounts_);
154 }
155 
GetItemCounts() const156 int32_t AccessibilityMemo::GetItemCounts() const
157 {
158     HILOG_DEBUG("itemCounts_[%{public}d]", itemCounts_);
159     return itemCounts_;
160 }
161 
GetEventType() const162 EventType AccessibilityEventInfo::GetEventType() const
163 {
164     HILOG_DEBUG("eventType_[%{public}d]", eventType_);
165     return eventType_;
166 }
167 
GetWindowContentChangeTypes() const168 WindowsContentChangeTypes AccessibilityEventInfo::GetWindowContentChangeTypes() const
169 {
170     HILOG_DEBUG("windowType_[%{public}d]", windowContentChangeTypes_);
171     return windowContentChangeTypes_;
172 }
173 
SetWindowContentChangeTypes(const WindowsContentChangeTypes changeTypes)174 void AccessibilityEventInfo::SetWindowContentChangeTypes(const WindowsContentChangeTypes changeTypes)
175 {
176     windowContentChangeTypes_ = changeTypes;
177     HILOG_DEBUG("windowType_[%{public}d]", windowContentChangeTypes_);
178 }
179 
GetWindowChangeTypes() const180 WindowUpdateType AccessibilityEventInfo::GetWindowChangeTypes() const
181 {
182     HILOG_DEBUG("windowType_[%{public}d]", windowChangeTypes_);
183     return windowChangeTypes_;
184 }
185 
SetWindowChangeTypes(const WindowUpdateType changeTypes)186 void AccessibilityEventInfo::SetWindowChangeTypes(const WindowUpdateType changeTypes)
187 {
188     windowChangeTypes_ = changeTypes;
189     HILOG_DEBUG("windowType_[%{public}d]", windowChangeTypes_);
190 }
191 
SetEventType(const EventType eventType)192 void AccessibilityEventInfo::SetEventType(const EventType eventType)
193 {
194     eventType_ = EventType(eventType);
195     HILOG_DEBUG("eventType_[%{public}d]", eventType_);
196 }
197 
GetTimeStamp() const198 int64_t AccessibilityEventInfo::GetTimeStamp() const
199 {
200     HILOG_DEBUG("timeStamp:%{public}" PRId64 "", timeStamp_);
201     return timeStamp_;
202 }
203 
SetTimeStamp(int64_t timeStamp)204 void AccessibilityEventInfo::SetTimeStamp(int64_t timeStamp)
205 {
206     timeStamp_ = timeStamp;
207     HILOG_DEBUG("timeStamp:%{public}" PRId64 "", timeStamp_);
208 }
209 
GetBundleName() const210 const std::string &AccessibilityEventInfo::GetBundleName() const
211 {
212     HILOG_DEBUG("bundleName_[%{public}s]", bundleName_.c_str());
213     return bundleName_;
214 }
215 
SetBundleName(const std::string & bundleName)216 void AccessibilityEventInfo::SetBundleName(const std::string &bundleName)
217 {
218     HILOG_DEBUG("previous bundleName[%{public}s] new bundleName[%{public}s]", bundleName_.c_str(), bundleName.c_str());
219     bundleName_ = bundleName;
220 }
221 
GetNotificationContent() const222 const std::string &AccessibilityEventInfo::GetNotificationContent() const
223 {
224     HILOG_DEBUG("notificationContent_[%{public}s]", notificationContent_.c_str());
225     return notificationContent_;
226 }
227 
SetNotificationContent(const std::string & notificationContent)228 void AccessibilityEventInfo::SetNotificationContent(const std::string &notificationContent)
229 {
230     notificationContent_ = notificationContent;
231     HILOG_DEBUG("notificationContent_[%{public}s]", notificationContent_.c_str());
232 }
233 
SetTextMovementStep(const TextMoveUnit granularity)234 void AccessibilityEventInfo::SetTextMovementStep(const TextMoveUnit granularity)
235 {
236     textMoveStep_ = granularity;
237     HILOG_DEBUG("textMoveStep_[%{public}d]", textMoveStep_);
238 }
239 
GetTextMovementStep() const240 TextMoveUnit AccessibilityEventInfo::GetTextMovementStep() const
241 {
242     HILOG_DEBUG("textMoveStep_[%{public}d]", textMoveStep_);
243     return textMoveStep_;
244 }
245 
SetTriggerAction(const ActionType action)246 void AccessibilityEventInfo::SetTriggerAction(const ActionType action)
247 {
248     triggerAction_ = action;
249     HILOG_DEBUG("triggerAction_[%{public}d]", triggerAction_);
250 }
251 
GetTriggerAction() const252 ActionType AccessibilityEventInfo::GetTriggerAction() const
253 {
254     HILOG_DEBUG("triggerAction_[%{public}d]", triggerAction_);
255     return triggerAction_;
256 }
257 
AccessibilityEventInfo(int32_t windowId,WindowUpdateType windowChangeTypes)258 AccessibilityEventInfo::AccessibilityEventInfo(int32_t windowId, WindowUpdateType windowChangeTypes)
259     : eventType_(TYPE_WINDOW_UPDATE), windowChangeTypes_(windowChangeTypes)
260 {
261     HILOG_DEBUG();
262     SetWindowId(windowId);
263 }
264 
AccessibilityEventInfo(EventType eventType)265 AccessibilityEventInfo::AccessibilityEventInfo(EventType eventType) : eventType_(eventType)
266 {
267     HILOG_DEBUG("eventType_[%{public}d]", eventType_);
268 }
269 
SetNotificationInfo(const NotificationCategory category)270 void AccessibilityEventInfo::SetNotificationInfo(const NotificationCategory category)
271 {
272     category_ = category;
273     HILOG_DEBUG("category_[%{public}d]", category_);
274 }
275 
SetGestureType(const GestureType gestureType)276 void AccessibilityEventInfo::SetGestureType(const GestureType gestureType)
277 {
278     gestureType_ = gestureType;
279     HILOG_DEBUG("gestureType_[%{public}d]", gestureType_);
280 }
281 
GetGestureType() const282 GestureType AccessibilityEventInfo::GetGestureType() const
283 {
284     HILOG_DEBUG("gestureType_[%{public}d]", gestureType_);
285     return gestureType_;
286 }
287 
GetNotificationInfo() const288 NotificationCategory AccessibilityEventInfo::GetNotificationInfo() const
289 {
290     HILOG_DEBUG("category_[%{public}d]", category_);
291     return category_;
292 }
293 
SetPageId(const int32_t pageId)294 void AccessibilityEventInfo::SetPageId(const int32_t pageId)
295 {
296     HILOG_DEBUG("pageId[%{public}d]", pageId);
297     pageId_ = pageId;
298 }
299 
GetPageId() const300 int32_t AccessibilityEventInfo::GetPageId() const
301 {
302     HILOG_DEBUG("pageId_[%{public}d]", pageId_);
303     return pageId_;
304 }
305 } // namespace Accessibility
306 } // namespace OHOS