1 /*
2 * Copyright (C) 2022-2024 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 int64_t componentId)24 void AccessibilityMemo::SetSource(const int64_t componentId)
25 {
26 HILOG_DEBUG("componentId[%{public}" PRId64 "]", componentId);
27 componentId_ = componentId;
28 elementId_ = componentId;
29 }
30
GetViewId() const31 int64_t AccessibilityMemo::GetViewId() const
32 {
33 HILOG_DEBUG("componentId_[%{public}" PRId64 "]", componentId_);
34 return componentId_;
35 }
36
GetAccessibilityId() const37 int64_t AccessibilityMemo::GetAccessibilityId() const
38 {
39 HILOG_DEBUG("called] elementId_[%{public}" PRId64 "]", 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_[%{private}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_[%{private}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[%{private}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_[%{private}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_[%{private}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 ¬ificationContent)
229 {
230 notificationContent_ = notificationContent;
231 HILOG_DEBUG("notificationContent_[%{public}s]", notificationContent_.c_str());
232 }
233
GetTextAnnouncedForAccessibility() const234 const std::string &AccessibilityEventInfo::GetTextAnnouncedForAccessibility() const
235 {
236 HILOG_DEBUG("textAnnouncedForAccessibility_[%{public}s]", textAnnouncedForAccessibility_.c_str());
237 return textAnnouncedForAccessibility_;
238 }
239
SetTextAnnouncedForAccessibility(const std::string & textAnnouncedForAccessibility)240 void AccessibilityEventInfo::SetTextAnnouncedForAccessibility(const std::string &textAnnouncedForAccessibility)
241 {
242 textAnnouncedForAccessibility_ = textAnnouncedForAccessibility;
243 HILOG_DEBUG("textAnnouncedForAccessibility_[%{public}s]", textAnnouncedForAccessibility_.c_str());
244 }
245
GetInspectorKey() const246 const std::string &AccessibilityEventInfo::GetInspectorKey() const
247 {
248 HILOG_DEBUG("inspectorKey_[%{public}s]", inspectorKey_.c_str());
249 return inspectorKey_;
250 }
251
SetInspectorKey(const std::string & inspectorKey)252 void AccessibilityEventInfo::SetInspectorKey(const std::string &inspectorKey)
253 {
254 inspectorKey_ = inspectorKey;
255 HILOG_DEBUG("inspectorKey_[%{public}s]", inspectorKey_.c_str());
256 }
257
SetTextMovementStep(const TextMoveUnit granularity)258 void AccessibilityEventInfo::SetTextMovementStep(const TextMoveUnit granularity)
259 {
260 textMoveStep_ = granularity;
261 HILOG_DEBUG("textMoveStep_[%{public}d]", textMoveStep_);
262 }
263
GetTextMovementStep() const264 TextMoveUnit AccessibilityEventInfo::GetTextMovementStep() const
265 {
266 HILOG_DEBUG("textMoveStep_[%{public}d]", textMoveStep_);
267 return textMoveStep_;
268 }
269
SetTriggerAction(const ActionType action)270 void AccessibilityEventInfo::SetTriggerAction(const ActionType action)
271 {
272 triggerAction_ = action;
273 HILOG_DEBUG("triggerAction_[%{public}d]", triggerAction_);
274 }
275
GetTriggerAction() const276 ActionType AccessibilityEventInfo::GetTriggerAction() const
277 {
278 HILOG_DEBUG("triggerAction_[%{public}d]", triggerAction_);
279 return triggerAction_;
280 }
281
AccessibilityEventInfo(int32_t windowId,WindowUpdateType windowChangeTypes)282 AccessibilityEventInfo::AccessibilityEventInfo(int32_t windowId, WindowUpdateType windowChangeTypes)
283 : eventType_(TYPE_WINDOW_UPDATE), windowChangeTypes_(windowChangeTypes)
284 {
285 HILOG_DEBUG();
286 SetWindowId(windowId);
287 }
288
AccessibilityEventInfo(EventType eventType)289 AccessibilityEventInfo::AccessibilityEventInfo(EventType eventType) : eventType_(eventType)
290 {
291 HILOG_DEBUG("eventType_[%{public}d]", eventType_);
292 }
293
SetNotificationInfo(const NotificationCategory category)294 void AccessibilityEventInfo::SetNotificationInfo(const NotificationCategory category)
295 {
296 category_ = category;
297 HILOG_DEBUG("category_[%{public}d]", category_);
298 }
299
SetGestureType(const GestureType gestureType)300 void AccessibilityEventInfo::SetGestureType(const GestureType gestureType)
301 {
302 gestureType_ = gestureType;
303 HILOG_DEBUG("gestureType_[%{public}d]", gestureType_);
304 }
305
GetGestureType() const306 GestureType AccessibilityEventInfo::GetGestureType() const
307 {
308 HILOG_DEBUG("gestureType_[%{public}d]", gestureType_);
309 return gestureType_;
310 }
311
GetNotificationInfo() const312 NotificationCategory AccessibilityEventInfo::GetNotificationInfo() const
313 {
314 HILOG_DEBUG("category_[%{public}d]", category_);
315 return category_;
316 }
317
SetPageId(const int32_t pageId)318 void AccessibilityEventInfo::SetPageId(const int32_t pageId)
319 {
320 HILOG_DEBUG("pageId[%{public}d]", pageId);
321 pageId_ = pageId;
322 }
323
GetPageId() const324 int32_t AccessibilityEventInfo::GetPageId() const
325 {
326 HILOG_DEBUG("pageId_[%{public}d]", pageId_);
327 return pageId_;
328 }
329
SetElementInfo(const AccessibilityElementInfo & elementInfo)330 void AccessibilityEventInfo::SetElementInfo(const AccessibilityElementInfo &elementInfo)
331 {
332 HILOG_DEBUG("set elementInfo");
333 elementInfo_ = elementInfo;
334 }
335
GetElementInfo() const336 const AccessibilityElementInfo &AccessibilityEventInfo::GetElementInfo() const
337 {
338 HILOG_DEBUG("get elementInfo");
339 return elementInfo_;
340 }
341
SetRequestFocusElementId(const int32_t requestFocusElementId)342 void AccessibilityEventInfo::SetRequestFocusElementId(const int32_t requestFocusElementId)
343 {
344 HILOG_DEBUG("requestFocusElementId[%{public}d]", requestFocusElementId);
345 requestFocusElementId_ = requestFocusElementId;
346 }
347
GetRequestFocusElementId() const348 int32_t AccessibilityEventInfo::GetRequestFocusElementId() const
349 {
350 HILOG_DEBUG("requestFocusElementId_[%{public}d]", requestFocusElementId_);
351 return requestFocusElementId_;
352 }
353
SetElementMainWindowId(const int32_t windowId)354 void AccessibilityEventInfo::SetElementMainWindowId(const int32_t windowId)
355 {
356 HILOG_DEBUG("mainWindowId[%{public}d]", windowId);
357 elementInfo_.SetMainWindowId(windowId);
358 }
359 } // namespace Accessibility
360 } // namespace OHOS