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
GetResourceId() const210 uint32_t AccessibilityEventInfo::GetResourceId() const
211 {
212 HILOG_DEBUG("GetResourceId [%{public}d]", resourceId_);
213 return resourceId_;
214 }
215
SetResourceId(const uint32_t & resourceId)216 void AccessibilityEventInfo::SetResourceId(const uint32_t &resourceId)
217 {
218 resourceId_ = resourceId;
219 HILOG_DEBUG("SetResourceId [%{public}d]", resourceId_);
220 }
221
GetResourceBundleName() const222 const std::string &AccessibilityEventInfo::GetResourceBundleName() const
223 {
224 HILOG_DEBUG("GetResourceBundleName [%{public}s]", resourceBundleName_.c_str());
225 return resourceBundleName_;
226 }
227
SetResourceBundleName(const std::string & bundleName)228 void AccessibilityEventInfo::SetResourceBundleName(const std::string &bundleName)
229 {
230 resourceBundleName_ = bundleName;
231 HILOG_DEBUG("SetResourceBundleName [%{public}s]", resourceBundleName_.c_str());
232 }
233
GetResourceModuleName() const234 const std::string &AccessibilityEventInfo::GetResourceModuleName() const
235 {
236 HILOG_DEBUG("GetResourceModuleName [%{public}s]", resourceModuleName_.c_str());
237 return resourceModuleName_;
238 }
239
SetResourceModuleName(const std::string & moduleName)240 void AccessibilityEventInfo::SetResourceModuleName(const std::string &moduleName)
241 {
242 resourceModuleName_ = moduleName;
243 HILOG_DEBUG("SetResourceModuleName [%{public}s]", resourceModuleName_.c_str());
244 }
245
GetResourceParams() const246 const std::vector<std::tuple<int32_t, std::string>> &AccessibilityEventInfo::GetResourceParams() const
247 {
248 HILOG_DEBUG("Get ResourceParams");
249 return resourceParams_;
250 }
251
SetResourceParams(const std::vector<std::tuple<int32_t,std::string>> & resourceParams)252 void AccessibilityEventInfo::SetResourceParams(const std::vector<std::tuple<int32_t, std::string>> &resourceParams)
253 {
254 resourceParams_ = resourceParams;
255 HILOG_DEBUG("Set ResourceParams");
256 }
257
GetBundleName() const258 const std::string &AccessibilityEventInfo::GetBundleName() const
259 {
260 HILOG_DEBUG("bundleName_[%{public}s]", bundleName_.c_str());
261 return bundleName_;
262 }
263
SetBundleName(const std::string & bundleName)264 void AccessibilityEventInfo::SetBundleName(const std::string &bundleName)
265 {
266 HILOG_DEBUG("previous bundleName[%{public}s] new bundleName[%{public}s]", bundleName_.c_str(), bundleName.c_str());
267 bundleName_ = bundleName;
268 }
269
GetNotificationContent() const270 const std::string &AccessibilityEventInfo::GetNotificationContent() const
271 {
272 HILOG_DEBUG("notificationContent_[%{public}s]", notificationContent_.c_str());
273 return notificationContent_;
274 }
275
SetNotificationContent(const std::string & notificationContent)276 void AccessibilityEventInfo::SetNotificationContent(const std::string ¬ificationContent)
277 {
278 notificationContent_ = notificationContent;
279 HILOG_DEBUG("notificationContent_[%{public}s]", notificationContent_.c_str());
280 }
281
GetTextAnnouncedForAccessibility() const282 const std::string &AccessibilityEventInfo::GetTextAnnouncedForAccessibility() const
283 {
284 HILOG_DEBUG("textAnnouncedForAccessibility_[%{public}s]", textAnnouncedForAccessibility_.c_str());
285 return textAnnouncedForAccessibility_;
286 }
287
SetTextAnnouncedForAccessibility(const std::string & textAnnouncedForAccessibility)288 void AccessibilityEventInfo::SetTextAnnouncedForAccessibility(const std::string &textAnnouncedForAccessibility)
289 {
290 textAnnouncedForAccessibility_ = textAnnouncedForAccessibility;
291 HILOG_DEBUG("textAnnouncedForAccessibility_[%{public}s]", textAnnouncedForAccessibility_.c_str());
292 }
293
GetInspectorKey() const294 const std::string &AccessibilityEventInfo::GetInspectorKey() const
295 {
296 HILOG_DEBUG("inspectorKey_[%{public}s]", inspectorKey_.c_str());
297 return inspectorKey_;
298 }
299
SetInspectorKey(const std::string & inspectorKey)300 void AccessibilityEventInfo::SetInspectorKey(const std::string &inspectorKey)
301 {
302 inspectorKey_ = inspectorKey;
303 HILOG_DEBUG("inspectorKey_[%{public}s]", inspectorKey_.c_str());
304 }
305
SetTextMovementStep(const TextMoveUnit granularity)306 void AccessibilityEventInfo::SetTextMovementStep(const TextMoveUnit granularity)
307 {
308 textMoveStep_ = granularity;
309 HILOG_DEBUG("textMoveStep_[%{public}d]", textMoveStep_);
310 }
311
GetTextMovementStep() const312 TextMoveUnit AccessibilityEventInfo::GetTextMovementStep() const
313 {
314 HILOG_DEBUG("textMoveStep_[%{public}d]", textMoveStep_);
315 return textMoveStep_;
316 }
317
SetTriggerAction(const ActionType action)318 void AccessibilityEventInfo::SetTriggerAction(const ActionType action)
319 {
320 triggerAction_ = action;
321 HILOG_DEBUG("triggerAction_[%{public}d]", triggerAction_);
322 }
323
GetTriggerAction() const324 ActionType AccessibilityEventInfo::GetTriggerAction() const
325 {
326 HILOG_DEBUG("triggerAction_[%{public}d]", triggerAction_);
327 return triggerAction_;
328 }
329
AccessibilityEventInfo(int32_t windowId,WindowUpdateType windowChangeTypes)330 AccessibilityEventInfo::AccessibilityEventInfo(int32_t windowId, WindowUpdateType windowChangeTypes)
331 : eventType_(TYPE_WINDOW_UPDATE), windowChangeTypes_(windowChangeTypes)
332 {
333 HILOG_DEBUG();
334 SetWindowId(windowId);
335 }
336
AccessibilityEventInfo(EventType eventType)337 AccessibilityEventInfo::AccessibilityEventInfo(EventType eventType) : eventType_(eventType)
338 {
339 HILOG_DEBUG("eventType_[%{public}d]", eventType_);
340 }
341
SetNotificationInfo(const NotificationCategory category)342 void AccessibilityEventInfo::SetNotificationInfo(const NotificationCategory category)
343 {
344 category_ = category;
345 HILOG_DEBUG("category_[%{public}d]", category_);
346 }
347
SetGestureType(const GestureType gestureType)348 void AccessibilityEventInfo::SetGestureType(const GestureType gestureType)
349 {
350 gestureType_ = gestureType;
351 HILOG_DEBUG("gestureType_[%{public}d]", gestureType_);
352 }
353
GetGestureType() const354 GestureType AccessibilityEventInfo::GetGestureType() const
355 {
356 HILOG_DEBUG("gestureType_[%{public}d]", gestureType_);
357 return gestureType_;
358 }
359
GetNotificationInfo() const360 NotificationCategory AccessibilityEventInfo::GetNotificationInfo() const
361 {
362 HILOG_DEBUG("category_[%{public}d]", category_);
363 return category_;
364 }
365
SetPageId(const int32_t pageId)366 void AccessibilityEventInfo::SetPageId(const int32_t pageId)
367 {
368 HILOG_DEBUG("pageId[%{public}d]", pageId);
369 pageId_ = pageId;
370 }
371
GetPageId() const372 int32_t AccessibilityEventInfo::GetPageId() const
373 {
374 HILOG_DEBUG("pageId_[%{public}d]", pageId_);
375 return pageId_;
376 }
377
SetElementInfo(const AccessibilityElementInfo & elementInfo)378 void AccessibilityEventInfo::SetElementInfo(const AccessibilityElementInfo &elementInfo)
379 {
380 HILOG_DEBUG("set elementInfo");
381 elementInfo_ = elementInfo;
382 }
383
GetElementInfo() const384 const AccessibilityElementInfo &AccessibilityEventInfo::GetElementInfo() const
385 {
386 HILOG_DEBUG("get elementInfo");
387 return elementInfo_;
388 }
389
SetRequestFocusElementId(const int32_t requestFocusElementId)390 void AccessibilityEventInfo::SetRequestFocusElementId(const int32_t requestFocusElementId)
391 {
392 HILOG_DEBUG("requestFocusElementId[%{public}d]", requestFocusElementId);
393 requestFocusElementId_ = requestFocusElementId;
394 }
395
GetRequestFocusElementId() const396 int32_t AccessibilityEventInfo::GetRequestFocusElementId() const
397 {
398 HILOG_DEBUG("requestFocusElementId_[%{public}d]", requestFocusElementId_);
399 return requestFocusElementId_;
400 }
401
SetElementMainWindowId(const int32_t windowId)402 void AccessibilityEventInfo::SetElementMainWindowId(const int32_t windowId)
403 {
404 HILOG_DEBUG("mainWindowId[%{public}d]", windowId);
405 elementInfo_.SetMainWindowId(windowId);
406 }
407 } // namespace Accessibility
408 } // namespace OHOS