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_element_info.h"
17 #include "parcel_util.h"
18 #include "hilog_wrapper.h"
19 #include "accessibility_operator.h"
20
21 namespace OHOS {
22 namespace Accessibility {
23 // text move step
24 const std::string MOVE_UNIT_CHARACTER = "char";
25 const std::string MOVE_UNIT_WORD = "word";
26 const std::string MOVE_UNIT_LINE = "line";
27 const std::string MOVE_UNIT_PAGE = "page";
28 const std::string MOVE_UNIT_PARAGRAPH = "paragraph";
29
30 // Operation Arguments Type
31 const std::string ACTION_ARGU_INVALID = "invalid";
32 const std::string ACTION_ARGU_SELECT_TEXT_START = "selectTextBegin";
33 const std::string ACTION_ARGU_SELECT_TEXT_END = "selectTextEnd";
34 const std::string ACTION_ARGU_HTML_ELEMENT = "htmlItem";
35 const std::string ACTION_ARGU_SET_TEXT = "setText";
36 const std::string ACTION_ARGU_MOVE_UNIT = "textMoveUnit";
37
38 // HtmlItemType
39 const std::string HTML_ITEM_INVALID = "invalid";
40 const std::string HTML_ITEM_LINK = "link";
41 const std::string HTML_ITEM_CONTROL = "control";
42 const std::string HTML_ITEM_GRAPHIC = "graphic";
43 const std::string HTML_ITEM_LIST_ITEM = "listItem";
44 const std::string HTML_ITEM_LIST = "list";
45 const std::string HTML_ITEM_TABLE = "table";
46 const std::string HTML_ITEM_COMBOX = "combox";
47 const std::string HTML_ITEM_HEADING = "heading";
48 const std::string HTML_ITEM_BUTTON = "button";
49 const std::string HTML_ITEM_CHECKBOX = "checkBox";
50 const std::string HTML_ITEM_LANDMARK = "landmark";
51 const std::string HTML_ITEM_TEXT_FIELD = "textField";
52 const std::string HTML_ITEM_FOCUSABLE = "focusable";
53 const std::string HTML_ITEM_H1 = "h1";
54 const std::string HTML_ITEM_H2 = "h2";
55 const std::string HTML_ITEM_H3 = "h3";
56 const std::string HTML_ITEM_H4 = "h4";
57 const std::string HTML_ITEM_H5 = "h5";
58 const std::string HTML_ITEM_H6 = "h6";
59 const std::string HTML_ITEM_UNKOWN = "unknown";
60
61 /* AccessibilityElementInfo Parcel struct */
ReadFromParcel(Parcel & parcel)62 bool AccessibilityElementInfo::ReadFromParcel(Parcel &parcel)
63 {
64 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
65 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, elementId_);
66 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, parentId_);
67 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
68 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType_);
69 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, text_);
70 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, hintText_);
71 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityText_);
72 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityDescription_);
73 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, contentDescription_);
74 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, resourceName_);
75 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32Vector, parcel, &childNodeIds_);
76 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childCount_);
77 int32_t operationsSize = 0;
78 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, operationsSize);
79 for (int i = 0; i < operationsSize; i++) {
80 sptr<AccessibleAction> accessibleOperation = parcel.ReadStrongParcelable<AccessibleAction>();
81 if (!accessibleOperation) {
82 HILOG_ERROR("ReadStrongParcelable<accessibleOperation> failed");
83 return false;
84 }
85 operations_.emplace_back(*accessibleOperation);
86 }
87 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, textLengthLimit_);
88 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, channelId_);
89 sptr<Rect> rect = parcel.ReadStrongParcelable<Rect>();
90 if (!rect) {
91 return false;
92 }
93 bounds_ = *rect;
94 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityGroup_);
95 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checkable_);
96 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checked_);
97 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focusable_);
98 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
99 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, visible_);
100 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
101 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
102 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clickable_);
103 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, longClickable_);
104 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, enable_);
105 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPassword_);
106 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, scrollable_);
107 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, editable_);
108 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, popupSupported_);
109 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, multiLine_);
110 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, deletable_);
111 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, hint_);
112 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isEssential_);
113 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex_);
114 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex_);
115 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex_);
116 sptr<RangeInfo> rangeInfo = parcel.ReadStrongParcelable<RangeInfo>();
117 if (!rangeInfo) {
118 return false;
119 }
120 rangeInfo_ = *rangeInfo;
121 sptr<GridInfo> grid = parcel.ReadStrongParcelable<GridInfo>();
122 if (!grid) {
123 return false;
124 }
125 grid_ = *grid;
126 sptr<GridItemInfo> gridItem = parcel.ReadStrongParcelable<GridItemInfo>();
127 if (!gridItem) {
128 return false;
129 }
130 gridItem_ = *gridItem;
131 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, liveRegion_);
132 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, contentInvalid_);
133 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, error_);
134 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, labeled_);
135 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginSelected_);
136 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endSelected_);
137 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, inputType_);
138 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, validElement_);
139
140 return true;
141 }
142
Marshalling(Parcel & parcel) const143 bool AccessibilityElementInfo::Marshalling(Parcel &parcel) const
144 {
145 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
146 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, elementId_);
147 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, parentId_);
148 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
149 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType_);
150 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, text_);
151 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, hintText_);
152 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityText_);
153 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityDescription_);
154 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, contentDescription_);
155 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, resourceName_);
156 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32Vector, parcel, childNodeIds_);
157 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childCount_);
158 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, operations_.size());
159 for (auto &operations : operations_) {
160 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &operations);
161 }
162 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, textLengthLimit_);
163 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, channelId_);
164 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &bounds_);
165 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityGroup_);
166 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checkable_);
167 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checked_);
168 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focusable_);
169 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
170 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, visible_);
171 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
172 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
173 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clickable_);
174 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, longClickable_);
175 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, enable_);
176 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPassword_);
177 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, scrollable_);
178 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, editable_);
179 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, popupSupported_);
180 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, multiLine_);
181 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, deletable_);
182 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, hint_);
183 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isEssential_);
184 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex_);
185 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex_);
186 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex_);
187 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &rangeInfo_);
188 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &grid_);
189 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &gridItem_);
190 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, liveRegion_);
191 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, contentInvalid_);
192 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, error_);
193 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, labeled_);
194 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginSelected_);
195 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endSelected_);
196 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, inputType_);
197 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, validElement_);
198 return true;
199 };
200
Unmarshalling(Parcel & parcel)201 sptr<AccessibilityElementInfo> AccessibilityElementInfo::Unmarshalling(Parcel& parcel)
202 {
203 sptr<AccessibilityElementInfo> accessibilityInfo = new AccessibilityElementInfo();
204 if (!accessibilityInfo->ReadFromParcel(parcel)) {
205 HILOG_ERROR("read from parcel failed");
206 return nullptr;
207 }
208 return accessibilityInfo;
209 }
210
SetComponentId(const int componentId)211 void AccessibilityElementInfo::SetComponentId(const int componentId)
212 {
213 elementId_ = componentId;
214 HILOG_DEBUG("elementId_[%{public}d]", elementId_);
215 }
216
GetFocus(const int focus,AccessibilityElementInfo & elementInfo)217 bool AccessibilityElementInfo::GetFocus(const int focus, AccessibilityElementInfo &elementInfo)
218 {
219 HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d],\
220 elementId_[%{public}d], focus[%{public}d]", channelId_, windowId_, elementId_, focus);
221 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
222 bool result = false;
223 if (instance != nullptr) {
224 result = instance->FindFocusedElementInfo(channelId_, windowId_, elementId_, focus, elementInfo);
225 } else {
226 HILOG_ERROR("Can't get AccessibilityOperator instance");
227 }
228 return result;
229 }
230
GetNext(const FocusMoveDirection direction,AccessibilityElementInfo & elementInfo)231 bool AccessibilityElementInfo::GetNext(const FocusMoveDirection direction, AccessibilityElementInfo &elementInfo)
232 {
233 HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d],\
234 elementId_[%{public}d], direction[%{public}d]", channelId_, windowId_, elementId_, direction);
235 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
236 bool result = false;
237 if (instance != nullptr) {
238 result = instance->FocusMoveSearch(channelId_, windowId_, elementId_, direction, elementInfo);
239 } else {
240 HILOG_ERROR("Can't get AccessibilityOperator instance");
241 }
242 return result;
243 }
244
GetChildId(const int index) const245 int AccessibilityElementInfo::GetChildId(const int index) const
246 {
247 HILOG_DEBUG("index[%{public}d]", index);
248 if (index >= childCount_ || index < 0) {
249 HILOG_ERROR("index[%{public}d] is invalid", index);
250 return 0;
251 }
252 return childNodeIds_[index];
253 }
GetChildCount() const254 int AccessibilityElementInfo::GetChildCount() const
255 {
256 HILOG_DEBUG("childCount_[%{public}d]", childCount_);
257 return childCount_;
258 }
259
GetChild(const int index,AccessibilityElementInfo & elementInfo)260 bool AccessibilityElementInfo::GetChild(const int index, AccessibilityElementInfo &elementInfo)
261 {
262 HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d],\
263 elementId_[%{public}d], index[%{public}d]", channelId_, windowId_, elementId_, index);
264 if (index >= childCount_ || index < 0) {
265 HILOG_ERROR("index[%{public}d] is invalid", index);
266 return false;
267 }
268 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
269 bool result = false;
270 std::vector<AccessibilityElementInfo> elementInfos {};
271 if (instance != nullptr) {
272 result = instance->SearchElementInfosByAccessibilityId(channelId_,
273 windowId_, GetChildId(index), 0, elementInfos);
274 if (elementInfos.empty()) {
275 result = false;
276 } else {
277 elementInfo = elementInfos.front();
278 }
279 } else {
280 HILOG_ERROR("Can't get AccessibilityOperator instance");
281 }
282 return result;
283 }
284
GetChildIds() const285 std::vector<int> AccessibilityElementInfo::GetChildIds() const
286 {
287 HILOG_DEBUG("childCount_[%{public}d]", childCount_);
288 return childNodeIds_;
289 }
AddChild(const int childId)290 void AccessibilityElementInfo::AddChild(const int childId)
291 {
292 HILOG_DEBUG("childId[%{public}d]", childId);
293 for (int i = 0; i < childCount_; i++) {
294 if (childNodeIds_[i] == childId) {
295 HILOG_ERROR("childId[%{public}d] is exited", childId);
296 return;
297 }
298 }
299 childCount_++;
300 childNodeIds_.push_back(childId);
301 HILOG_DEBUG("childId[%{public}d] end", childId);
302 }
303
RemoveChild(const int childId)304 bool AccessibilityElementInfo::RemoveChild(const int childId)
305 {
306 HILOG_DEBUG("childId[%{public}d]", childId);
307 for (auto iter = childNodeIds_.begin(); iter != childNodeIds_.end(); iter++) {
308 if (*iter == childId) {
309 iter = childNodeIds_.erase(iter);
310 childCount_--;
311 return true;
312 }
313 }
314 HILOG_ERROR("Not find childId[%{public}d]", childId);
315 return false;
316 }
317
GetActionList() const318 std::vector<AccessibleAction> AccessibilityElementInfo::GetActionList() const
319 {
320 HILOG_DEBUG("start");
321 return operations_;
322 }
323
AddAction(AccessibleAction & action)324 void AccessibilityElementInfo::AddAction(AccessibleAction &action)
325 {
326 HILOG_DEBUG("start");
327 operations_.push_back(action);
328 HILOG_DEBUG("actionType[%{public}d] end", action.GetActionType());
329 }
330
DeleteAction(AccessibleAction & action)331 void AccessibilityElementInfo::DeleteAction(AccessibleAction &action)
332 {
333 HILOG_DEBUG("start");
334 for (auto iter = operations_.begin(); iter != operations_.end(); iter++) {
335 HILOG_DEBUG("actionType[%{public}d]", action.GetActionType());
336 if (iter->GetActionType() == action.GetActionType()) {
337 iter = operations_.erase(iter);
338 return;
339 }
340 }
341 HILOG_ERROR("Not find actionType[%{public}d]", action.GetActionType());
342 }
343
DeleteAction(ActionType & actionType)344 bool AccessibilityElementInfo::DeleteAction(ActionType &actionType)
345 {
346 HILOG_DEBUG("start");
347 for (auto iter = operations_.begin(); iter != operations_.end(); iter++) {
348 HILOG_DEBUG("actionType[%{public}d]", actionType);
349 if (iter->GetActionType() == actionType) {
350 iter = operations_.erase(iter);
351 return true;
352 }
353 }
354 HILOG_ERROR("Not find actionType[%{public}d]", actionType);
355 return false;
356 }
357
DeleteAllActions()358 void AccessibilityElementInfo::DeleteAllActions()
359 {
360 HILOG_DEBUG("start");
361 operations_.clear();
362 }
363
SetTextLengthLimit(const int max)364 void AccessibilityElementInfo::SetTextLengthLimit(const int max)
365 {
366 textLengthLimit_ = max;
367 HILOG_DEBUG("textLengthLimit_[%{public}d]", textLengthLimit_);
368 }
369
GetTextLengthLimit() const370 int AccessibilityElementInfo::GetTextLengthLimit() const
371 {
372 HILOG_DEBUG("textLengthLimit_[%{public}d]", textLengthLimit_);
373 return textLengthLimit_;
374 }
375
ExecuteAction(const ActionType & action,const std::map<std::string,std::string> & actionArguments)376 bool AccessibilityElementInfo::ExecuteAction(const ActionType &action,
377 const std::map<std::string, std::string> &actionArguments)
378 {
379 HILOG_INFO("called] channelId_[%{public}d], windowId_[%{public}d], elementId_[%{public}d]",
380 channelId_, windowId_, elementId_);
381 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
382 if (instance != nullptr) {
383 return instance->ExecuteAction(channelId_, windowId_, elementId_, action,
384 const_cast<std::map<std::string, std::string> &>(actionArguments));
385 } else {
386 HILOG_INFO("Can't get AccessibilityOperator instance");
387 return false;
388 }
389 }
390
GetByContent(const std::string & text,std::vector<AccessibilityElementInfo> & elementInfos)391 bool AccessibilityElementInfo::GetByContent(const std::string &text,
392 std::vector<AccessibilityElementInfo> &elementInfos)
393 {
394 HILOG_INFO("called channelId_[%{public}d], windowId_[%{public}d],\
395 elementId_[%{public}d], text[%{public}s]", channelId_, windowId_, elementId_, text.c_str());
396 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
397 bool result = false;
398 if (instance != nullptr) {
399 result = instance->SearchElementInfosByText(channelId_, windowId_, elementId_, text, elementInfos);
400 } else {
401 HILOG_INFO("Can't get AccessibilityOperator instance");
402 }
403 return result;
404 }
405
GetElementInfosById(const int elementId,int mode,std::vector<AccessibilityElementInfo> & elementInfos)406 bool AccessibilityElementInfo::GetElementInfosById(const int elementId, int mode,
407 std::vector<AccessibilityElementInfo> &elementInfos)
408 {
409 HILOG_DEBUG("start");
410 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
411 bool result = false;
412 if (instance != nullptr) {
413 result = instance->SearchElementInfosByAccessibilityId(channelId_,
414 windowId_, elementId, mode, elementInfos);
415 } else {
416 HILOG_INFO("Can't get AccessibilityOperator instance");
417 }
418
419 return result;
420 }
421
GetWindowId() const422 int AccessibilityElementInfo::GetWindowId() const
423 {
424 HILOG_DEBUG("windowId_[%{public}d]", windowId_);
425 return windowId_;
426 }
427
SetWindowId(const int windowId)428 void AccessibilityElementInfo::SetWindowId(const int windowId)
429 {
430 windowId_ = windowId;
431 HILOG_DEBUG("windowId_[%{public}d]", windowId_);
432 }
433
GetParent(AccessibilityElementInfo & elementInfo)434 bool AccessibilityElementInfo::GetParent(AccessibilityElementInfo &elementInfo)
435 {
436 HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d], parentId_[%{public}d]",
437 channelId_, windowId_, parentId_);
438 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
439 std::vector<AccessibilityElementInfo> elementInfos {};
440 bool result = false;
441 if (instance != nullptr) {
442 result = instance->SearchElementInfosByAccessibilityId(channelId_,
443 windowId_, parentId_, 0, elementInfos);
444 if (elementInfos.empty()) {
445 result = false;
446 } else {
447 elementInfo = elementInfos.front();
448 }
449 } else {
450 HILOG_INFO("Can't get AccessibilityOperator instance");
451 }
452 return result;
453 }
454
GetParentNodeId() const455 int AccessibilityElementInfo::GetParentNodeId() const
456 {
457 HILOG_DEBUG("parentId_[%{public}d]", parentId_);
458 return parentId_;
459 }
460
SetParent(const int parentId)461 void AccessibilityElementInfo::SetParent(const int parentId)
462 {
463 parentId_ = parentId;
464 HILOG_DEBUG("parentId_[%{public}d]", parentId_);
465 }
GetRectInScreen() const466 Rect AccessibilityElementInfo::GetRectInScreen() const
467 {
468 HILOG_DEBUG("start");
469 return bounds_;
470 }
471
SetRectInScreen(Rect & bounds)472 void AccessibilityElementInfo::SetRectInScreen(Rect &bounds)
473 {
474 HILOG_DEBUG("start");
475 bounds_.SetLeftTopScreenPostion(bounds.GetLeftTopXScreenPostion(), bounds.GetLeftTopYScreenPostion());
476 bounds_.SetRightBottomScreenPostion(bounds.GetRightBottomXScreenPostion(), bounds.GetRightBottomYScreenPostion());
477 }
478
IsCheckable() const479 bool AccessibilityElementInfo::IsCheckable() const
480 {
481 HILOG_DEBUG("checkable_[%{public}d]", checkable_);
482 return checkable_;
483 }
484
SetCheckable(const bool checkable)485 void AccessibilityElementInfo::SetCheckable(const bool checkable)
486 {
487 checkable_ = checkable;
488 HILOG_DEBUG("checkable_[%{public}d]", checkable_);
489 }
490
IsChecked() const491 bool AccessibilityElementInfo::IsChecked() const
492 {
493 HILOG_DEBUG("checked_[%{public}d]", checked_);
494 return checked_;
495 }
496
SetChecked(const bool checked)497 void AccessibilityElementInfo::SetChecked(const bool checked)
498 {
499 checked_ = checked;
500 HILOG_DEBUG("checked_[%{public}d]", checked_);
501 }
502
IsFocusable() const503 bool AccessibilityElementInfo::IsFocusable() const
504 {
505 HILOG_DEBUG("focusable_[%{public}d]", focusable_);
506 return focusable_;
507 }
508
SetFocusable(const bool focusable)509 void AccessibilityElementInfo::SetFocusable(const bool focusable)
510 {
511 focusable_ = focusable;
512 HILOG_DEBUG("focusable_[%{public}d]", focusable_);
513 }
514
IsFocused() const515 bool AccessibilityElementInfo::IsFocused() const
516 {
517 HILOG_DEBUG("focused_[%{public}d]", focused_);
518 return focused_;
519 }
520
SetFocused(const bool focused)521 void AccessibilityElementInfo::SetFocused(const bool focused)
522 {
523 focused_ = focused;
524 HILOG_DEBUG("focused_[%{public}d]", focused_);
525 }
526
IsVisible() const527 bool AccessibilityElementInfo::IsVisible() const
528 {
529 HILOG_DEBUG("visible_[%{public}d]", visible_);
530 return visible_;
531 }
532
SetVisible(const bool visible)533 void AccessibilityElementInfo::SetVisible(const bool visible)
534 {
535 visible_ = visible;
536 HILOG_DEBUG("visible_[%{public}d]", visible_);
537 }
538
HasAccessibilityFocus() const539 bool AccessibilityElementInfo::HasAccessibilityFocus() const
540 {
541 HILOG_DEBUG("accessibilityFocused_[%{public}d]", accessibilityFocused_);
542 return accessibilityFocused_;
543 }
544
SetAccessibilityFocus(const bool focused)545 void AccessibilityElementInfo::SetAccessibilityFocus(const bool focused)
546 {
547 accessibilityFocused_ = focused;
548 HILOG_DEBUG("accessibilityFocused_[%{public}d]", accessibilityFocused_);
549 }
550
IsSelected() const551 bool AccessibilityElementInfo::IsSelected() const
552 {
553 HILOG_DEBUG("selected_[%{public}d]", selected_);
554 return selected_;
555 }
556
SetSelected(const bool selected)557 void AccessibilityElementInfo::SetSelected(const bool selected)
558 {
559 selected_ = selected;
560 HILOG_DEBUG("selected_[%{public}d]", selected_);
561 }
562
IsClickable() const563 bool AccessibilityElementInfo::IsClickable() const
564 {
565 HILOG_DEBUG("clickable_[%{public}d]", clickable_);
566 return clickable_;
567 }
568
SetClickable(const bool clickable)569 void AccessibilityElementInfo::SetClickable(const bool clickable)
570 {
571 clickable_ = clickable;
572 HILOG_DEBUG("clickable_[%{public}d]", clickable_);
573 }
574
IsLongClickable() const575 bool AccessibilityElementInfo::IsLongClickable() const
576 {
577 HILOG_DEBUG("longClickable_[%{public}d]", longClickable_);
578 return longClickable_;
579 }
580
SetLongClickable(const bool longClickable)581 void AccessibilityElementInfo::SetLongClickable(const bool longClickable)
582 {
583 longClickable_ = longClickable;
584 HILOG_DEBUG("longClickable_[%{public}d]", longClickable_);
585 }
586
IsEnabled() const587 bool AccessibilityElementInfo::IsEnabled() const
588 {
589 HILOG_DEBUG("enable_[%{public}d]", enable_);
590 return enable_;
591 }
592
SetEnabled(const bool enabled)593 void AccessibilityElementInfo::SetEnabled(const bool enabled)
594 {
595 enable_ = enabled;
596 HILOG_DEBUG("enable_[%{public}d]", enable_);
597 }
598
IsPassword() const599 bool AccessibilityElementInfo::IsPassword() const
600 {
601 HILOG_DEBUG();
602 return isPassword_;
603 }
604
SetPassword(const bool type)605 void AccessibilityElementInfo::SetPassword(const bool type)
606 {
607 HILOG_DEBUG("type[%{public}d]", type);
608 isPassword_ = type;
609 }
610
IsScrollable() const611 bool AccessibilityElementInfo::IsScrollable() const
612 {
613 HILOG_DEBUG("scrollable_[%{public}d]", scrollable_);
614 return scrollable_;
615 }
616
SetScrollable(const bool scrollable)617 void AccessibilityElementInfo::SetScrollable(const bool scrollable)
618 {
619 scrollable_ = scrollable;
620 HILOG_DEBUG("scrollable_[%{public}d]", scrollable_);
621 }
622
GetCurrentIndex() const623 int AccessibilityElementInfo::GetCurrentIndex() const
624 {
625 HILOG_DEBUG("currentIndex_[%{public}d]", currentIndex_);
626 return currentIndex_;
627 }
628
SetCurrentIndex(const int index)629 void AccessibilityElementInfo::SetCurrentIndex(const int index)
630 {
631 currentIndex_ = index;
632 HILOG_DEBUG("currentIndex_[%{public}d]", currentIndex_);
633 }
634
GetBeginIndex() const635 int AccessibilityElementInfo::GetBeginIndex() const
636 {
637 HILOG_DEBUG("beginIndex_[%{public}d]", beginIndex_);
638 return beginIndex_;
639 }
640
SetBeginIndex(const int index)641 void AccessibilityElementInfo::SetBeginIndex(const int index)
642 {
643 beginIndex_ = index;
644 HILOG_DEBUG("beginIndex_[%{public}d]", beginIndex_);
645 }
646
GetEndIndex() const647 int AccessibilityElementInfo::GetEndIndex() const
648 {
649 HILOG_DEBUG("endIndex_[%{public}d]", endIndex_);
650 return endIndex_;
651 }
652
SetEndIndex(const int index)653 void AccessibilityElementInfo::SetEndIndex(const int index)
654 {
655 endIndex_ = index;
656 HILOG_DEBUG("endIndex_[%{public}d]", endIndex_);
657 }
658
GetInputType() const659 int AccessibilityElementInfo::GetInputType() const
660 {
661 HILOG_DEBUG("inputType_[%{public}d]", inputType_);
662 return inputType_;
663 }
664
SetInputType(const int inputType)665 void AccessibilityElementInfo::SetInputType(const int inputType)
666 {
667 inputType_ = inputType;
668 HILOG_DEBUG("inputType_[%{public}d]", inputType_);
669 }
670
SetValidElement(const bool valid)671 void AccessibilityElementInfo::SetValidElement(const bool valid)
672 {
673 HILOG_DEBUG("validElevalidment_[%{public}d]", valid);
674 validElement_ = valid;
675 }
676
SetInspectorKey(const std::string key)677 void AccessibilityElementInfo::SetInspectorKey(const std::string key)
678 {
679 HILOG_DEBUG("inspector key [%{public}s]", key.c_str());
680 inspectorKey_ = key;
681 }
682
GetInspectorKey() const683 std::string AccessibilityElementInfo::GetInspectorKey() const
684 {
685 HILOG_DEBUG("inspector key [%{public}s]", inspectorKey_.c_str());
686 return inspectorKey_;
687 }
688
IsValidElement() const689 bool AccessibilityElementInfo::IsValidElement() const
690 {
691 HILOG_DEBUG("validElement_[%{public}d]", validElement_);
692 return validElement_;
693 }
694
IsEditable() const695 bool AccessibilityElementInfo::IsEditable() const
696 {
697 HILOG_DEBUG("editable_[%{public}d]", editable_);
698 return editable_;
699 }
700
SetEditable(const bool editable)701 void AccessibilityElementInfo::SetEditable(const bool editable)
702 {
703 editable_ = editable;
704 HILOG_DEBUG("editable_[%{public}d]", editable_);
705 }
706
IsPluraLineSupported() const707 bool AccessibilityElementInfo::IsPluraLineSupported() const
708 {
709 HILOG_DEBUG("multiLine_[%{public}d]", multiLine_);
710 return multiLine_;
711 }
712
SetPluraLineSupported(const bool multiLine)713 void AccessibilityElementInfo::SetPluraLineSupported(const bool multiLine)
714 {
715 multiLine_ = multiLine;
716 HILOG_DEBUG("multiLine_[%{public}d]", multiLine_);
717 }
718
IsPopupSupported() const719 bool AccessibilityElementInfo::IsPopupSupported() const
720 {
721 HILOG_DEBUG("popupSupported_[%{public}d]", popupSupported_);
722 return popupSupported_;
723 }
724
SetPopupSupported(const bool supportPopup)725 void AccessibilityElementInfo::SetPopupSupported(const bool supportPopup)
726 {
727 popupSupported_ = supportPopup;
728 HILOG_DEBUG("popupSupported_[%{public}d]", popupSupported_);
729 }
730
IsDeletable() const731 bool AccessibilityElementInfo::IsDeletable() const
732 {
733 HILOG_DEBUG("deletable_[%{public}d]", deletable_);
734 return deletable_;
735 }
736
SetDeletable(const bool deletable)737 void AccessibilityElementInfo::SetDeletable(const bool deletable)
738 {
739 deletable_ = deletable;
740 HILOG_DEBUG("deletable_[%{public}d]", deletable_);
741 }
742
IsEssential() const743 bool AccessibilityElementInfo::IsEssential() const
744 {
745 HILOG_DEBUG("isEssential_[%{public}d]", isEssential_);
746 return isEssential_;
747 }
748
SetEssential(const bool essential)749 void AccessibilityElementInfo::SetEssential(const bool essential)
750 {
751 isEssential_ = essential;
752 HILOG_DEBUG("isEssential_[%{public}d]", isEssential_);
753 }
754
IsGivingHint() const755 bool AccessibilityElementInfo::IsGivingHint() const
756 {
757 HILOG_DEBUG("hint_[%{public}d]", hint_);
758 return hint_;
759 }
SetHinting(const bool hinting)760 void AccessibilityElementInfo::SetHinting(const bool hinting)
761 {
762 hint_ = hinting;
763 HILOG_DEBUG("hint_[%{public}d]", hint_);
764 }
765
GetBundleName() const766 std::string AccessibilityElementInfo::GetBundleName() const
767 {
768 HILOG_DEBUG("bundleName_[%{public}s]", bundleName_.c_str());
769 return bundleName_;
770 }
771
SetBundleName(const std::string & bundleName)772 void AccessibilityElementInfo::SetBundleName(const std::string &bundleName)
773 {
774 bundleName_ = bundleName;
775 HILOG_DEBUG("bundleName_[%{public}s]", bundleName_.c_str());
776 }
777
GetComponentType() const778 std::string AccessibilityElementInfo::GetComponentType() const
779 {
780 HILOG_DEBUG("componentType_[%{public}s]", componentType_.c_str());
781 return componentType_;
782 }
783
SetComponentType(const std::string & className)784 void AccessibilityElementInfo::SetComponentType(const std::string &className)
785 {
786 componentType_ = className;
787 HILOG_DEBUG("componentType_[%{public}s]", componentType_.c_str());
788 }
789
GetContent() const790 std::string AccessibilityElementInfo::GetContent() const
791 {
792 HILOG_DEBUG("text_[%{public}s]", text_.c_str());
793 return text_;
794 }
795
SetContent(const std::string & text)796 void AccessibilityElementInfo::SetContent(const std::string &text)
797 {
798 text_ = text;
799 HILOG_DEBUG("text_[%{public}s]", text_.c_str());
800 }
801
GetAccessibilityContent() const802 std::string AccessibilityElementInfo::GetAccessibilityContent() const
803 {
804 HILOG_DEBUG("accessibilityText_[%{public}s]", accessibilityText_.c_str());
805 return accessibilityText_;
806 }
807
SetAccessibilityContent(const std::string & text)808 void AccessibilityElementInfo::SetAccessibilityContent(const std::string &text)
809 {
810 accessibilityText_ = text;
811 HILOG_DEBUG("accessibilityText_[%{public}s]", accessibilityText_.c_str());
812 }
813
SetSelectedBegin(const int start)814 void AccessibilityElementInfo::SetSelectedBegin(const int start)
815 {
816 beginSelected_ = start;
817 HILOG_DEBUG("beginSelected_[%{public}d]", beginSelected_);
818 }
819
GetSelectedBegin() const820 int AccessibilityElementInfo::GetSelectedBegin() const
821 {
822 HILOG_DEBUG("beginSelected_[%{public}d]", beginSelected_);
823 return beginSelected_;
824 }
825
SetSelectedEnd(const int end)826 void AccessibilityElementInfo::SetSelectedEnd(const int end)
827 {
828 endSelected_ = end;
829 HILOG_DEBUG("endSelected_[%{public}d]", endSelected_);
830 }
831
GetSelectedEnd() const832 int AccessibilityElementInfo::GetSelectedEnd() const
833 {
834 HILOG_DEBUG("endSelected_[%{public}d]", endSelected_);
835 return endSelected_;
836 }
837
GetAccessibilityDescription() const838 std::string AccessibilityElementInfo::GetAccessibilityDescription() const
839 {
840 HILOG_DEBUG("endSelected_[%{public}s]", accessibilityDescription_.c_str());
841 return accessibilityDescription_;
842 }
843
SetAccessibilityDescription(const std::string & text)844 void AccessibilityElementInfo::SetAccessibilityDescription(const std::string &text)
845 {
846 accessibilityDescription_ = text;
847 HILOG_DEBUG("endSelected_[%{public}s]", accessibilityDescription_.c_str());
848 }
849
GetAccessibilityGroup() const850 bool AccessibilityElementInfo::GetAccessibilityGroup() const
851 {
852 HILOG_DEBUG("accessibilityGroup_[%{public}d]", accessibilityGroup_);
853 return accessibilityGroup_;
854 }
855
SetAccessibilityGroup(const bool group)856 void AccessibilityElementInfo::SetAccessibilityGroup(const bool group)
857 {
858 accessibilityGroup_ = group;
859 HILOG_DEBUG("accessibilityGroup_[%{public}d]", accessibilityGroup_);
860 }
861
GetHint() const862 std::string AccessibilityElementInfo::GetHint() const
863 {
864 HILOG_DEBUG("hintText_[%{public}s]", hintText_.c_str());
865 return hintText_;
866 }
867
SetHint(const std::string & hintText)868 void AccessibilityElementInfo::SetHint(const std::string &hintText)
869 {
870 hintText_ = hintText;
871 HILOG_DEBUG("hintText_[%{public}s]", hintText_.c_str());
872 }
873
GetDescriptionInfo() const874 std::string AccessibilityElementInfo::GetDescriptionInfo() const
875 {
876 HILOG_DEBUG("contentDescription_[%{public}s]", contentDescription_.c_str());
877 return contentDescription_;
878 }
879
SetDescriptionInfo(const std::string contentDescription)880 void AccessibilityElementInfo::SetDescriptionInfo(const std::string contentDescription)
881 {
882 contentDescription_ = contentDescription;
883 HILOG_DEBUG("contentDescription_[%{public}s]", contentDescription_.c_str());
884 }
885
SetComponentResourceId(const std::string & viewIdResName)886 void AccessibilityElementInfo::SetComponentResourceId(const std::string &viewIdResName)
887 {
888 resourceName_ = viewIdResName;
889 HILOG_DEBUG("resourceName_[%{public}s]", resourceName_.c_str());
890 }
891
GetComponentResourceId() const892 std::string AccessibilityElementInfo::GetComponentResourceId() const
893 {
894 HILOG_DEBUG("resourceName_[%{public}s]", resourceName_.c_str());
895 return resourceName_;
896 }
897
SetLiveRegion(const int liveRegion)898 void AccessibilityElementInfo::SetLiveRegion(const int liveRegion)
899 {
900 liveRegion_ = liveRegion;
901 HILOG_DEBUG("liveRegion_[%{public}d]", liveRegion_);
902 }
903
GetLiveRegion() const904 int AccessibilityElementInfo::GetLiveRegion() const
905 {
906 HILOG_DEBUG("liveRegion_[%{public}d]", liveRegion_);
907 return liveRegion_;
908 }
909
SetContentInvalid(const bool contentInvalid)910 void AccessibilityElementInfo::SetContentInvalid(const bool contentInvalid)
911 {
912 contentInvalid_ = contentInvalid;
913 HILOG_DEBUG("contentInvalid_[%{public}d]", contentInvalid_);
914 }
915
GetContentInvalid() const916 bool AccessibilityElementInfo::GetContentInvalid() const
917 {
918 HILOG_DEBUG("contentInvalid_[%{public}d]", contentInvalid_);
919 return contentInvalid_;
920 }
921
SetError(const std::string & error)922 void AccessibilityElementInfo::SetError(const std::string &error)
923 {
924 error_ = error;
925 HILOG_DEBUG("error_[%{public}s]", error_.c_str());
926 }
927
GetError() const928 std::string AccessibilityElementInfo::GetError() const
929 {
930 HILOG_DEBUG("error_[%{public}s]", error_.c_str());
931 return error_;
932 }
933
SetLabeled(const int componentId)934 void AccessibilityElementInfo::SetLabeled(const int componentId)
935 {
936 labeled_ = componentId;
937 HILOG_DEBUG("labeled_[%{public}d]", labeled_);
938 }
939
GetLabeled(AccessibilityElementInfo & elementInfo) const940 bool AccessibilityElementInfo::GetLabeled(AccessibilityElementInfo &elementInfo) const
941 {
942 HILOG_DEBUG("labeled_[%{public}d]", labeled_);
943 AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
944
945 std::vector<AccessibilityElementInfo> elementInfos {};
946 bool result = false;
947 if (instance != nullptr) {
948 result = instance->SearchElementInfosByAccessibilityId(channelId_,
949 windowId_, labeled_, 0, elementInfos);
950 if (elementInfos.empty()) {
951 result = false;
952 } else {
953 elementInfo = elementInfos.front();
954 }
955 } else {
956 HILOG_INFO("Can't get AccessibilityOperator instance");
957 }
958 return result;
959 }
960
GetLabeledAccessibilityId() const961 int AccessibilityElementInfo::GetLabeledAccessibilityId() const
962 {
963 HILOG_DEBUG("labeled_[%{public}d]", labeled_);
964 return labeled_;
965 }
966
GetChannelId() const967 int AccessibilityElementInfo::GetChannelId() const
968 {
969 HILOG_DEBUG("channelId_[%{public}d]", channelId_);
970 return channelId_;
971 }
972
SetChannelId(const int channelId)973 void AccessibilityElementInfo::SetChannelId(const int channelId)
974 {
975 channelId_ = channelId;
976 HILOG_DEBUG("channelId_[%{public}d]", channelId_);
977 }
978
SetAccessibilityId(const int componentId)979 void AccessibilityElementInfo::SetAccessibilityId(const int componentId)
980 {
981 elementId_ = componentId;
982 HILOG_DEBUG("elementId_[%{public}d]", elementId_);
983 }
984
GetAccessibilityId() const985 int AccessibilityElementInfo::GetAccessibilityId() const
986 {
987 HILOG_DEBUG("elementId_[%{public}d]", elementId_);
988 return elementId_;
989 }
990
GetRange() const991 RangeInfo AccessibilityElementInfo::GetRange() const
992 {
993 HILOG_DEBUG("start");
994 return rangeInfo_;
995 }
996
SetRange(RangeInfo & rangeInfo)997 void AccessibilityElementInfo::SetRange(RangeInfo &rangeInfo)
998 {
999 HILOG_DEBUG("start");
1000 rangeInfo_.SetMax(rangeInfo.GetMax());
1001 rangeInfo_.SetMin(rangeInfo.GetMin());
1002 rangeInfo_.SetCurrent(rangeInfo.GetCurrent());
1003 }
1004
GetGrid() const1005 GridInfo AccessibilityElementInfo::GetGrid() const
1006 {
1007 HILOG_DEBUG("start");
1008 return grid_;
1009 }
1010
SetGrid(const GridInfo & grid)1011 void AccessibilityElementInfo::SetGrid(const GridInfo &grid)
1012 {
1013 HILOG_DEBUG("start");
1014 grid_ = grid;
1015 }
1016
GetGridItem() const1017 GridItemInfo AccessibilityElementInfo::GetGridItem() const
1018 {
1019 HILOG_DEBUG("start");
1020 return gridItem_;
1021 }
1022
SetGridItem(const GridItemInfo & gridItem)1023 void AccessibilityElementInfo::SetGridItem(const GridItemInfo &gridItem)
1024 {
1025 HILOG_DEBUG("start");
1026 gridItem_ = gridItem;
1027 }
1028
AccessibilityElementInfo()1029 AccessibilityElementInfo::AccessibilityElementInfo()
1030 {
1031 HILOG_DEBUG("start");
1032 }
1033
ReadFromParcel(Parcel & parcel)1034 bool AccessibleAction::ReadFromParcel(Parcel &parcel)
1035 {
1036 HILOG_DEBUG("start");
1037 int type = ActionType::ACCESSIBILITY_ACTION_INVALID;
1038 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, type);
1039 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
1040 actionType_ = ActionType(type);
1041 return true;
1042 }
1043
Marshalling(Parcel & parcel) const1044 bool AccessibleAction::Marshalling(Parcel &parcel) const
1045 {
1046 HILOG_DEBUG("start");
1047 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, int32_t(actionType_));
1048 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
1049
1050 return true;
1051 };
1052
Unmarshalling(Parcel & parcel)1053 sptr<AccessibleAction> AccessibleAction::Unmarshalling(Parcel& parcel)
1054 {
1055 HILOG_DEBUG("start");
1056 sptr<AccessibleAction> accessibleOperation = new AccessibleAction();
1057 if (!accessibleOperation->ReadFromParcel(parcel)) {
1058 HILOG_ERROR("read from parcel failed");
1059 delete accessibleOperation;
1060 accessibleOperation = nullptr;
1061 }
1062 return accessibleOperation;
1063 }
1064
AccessibleAction(ActionType actionType,std::string description)1065 AccessibleAction::AccessibleAction(ActionType actionType, std::string description)
1066 {
1067 HILOG_DEBUG("start");
1068 actionType_ = actionType;
1069 description_ = description;
1070 }
1071
GetActionType() const1072 ActionType AccessibleAction::GetActionType() const
1073 {
1074 HILOG_DEBUG("actionType_[%{public}d]", actionType_);
1075 return actionType_;
1076 }
1077
GetDescriptionInfo() const1078 std::string AccessibleAction::GetDescriptionInfo() const
1079 {
1080 HILOG_DEBUG("description_[%{public}s]", description_.c_str());
1081 return description_;
1082 }
1083
ReadFromParcel(Parcel & parcel)1084 bool RangeInfo::ReadFromParcel(Parcel &parcel)
1085 {
1086 HILOG_DEBUG("start");
1087 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, min_);
1088 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, max_);
1089 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, current_);
1090
1091 return true;
1092 }
1093
Marshalling(Parcel & parcel) const1094 bool RangeInfo::Marshalling(Parcel &parcel) const
1095 {
1096 HILOG_DEBUG("start");
1097 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, min_);
1098 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, max_);
1099 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, current_);
1100
1101 return true;
1102 }
1103
Unmarshalling(Parcel & parcel)1104 sptr<RangeInfo> RangeInfo::Unmarshalling(Parcel& parcel)
1105 {
1106 HILOG_DEBUG("start");
1107 sptr<RangeInfo> rangeInfo = new RangeInfo();
1108 if (!rangeInfo->ReadFromParcel(parcel)) {
1109 HILOG_ERROR("read from parcel failed");
1110 delete rangeInfo;
1111 rangeInfo = nullptr;
1112 }
1113 return rangeInfo;
1114 }
1115
RangeInfo(int min,int max,int current)1116 RangeInfo::RangeInfo(int min, int max, int current)
1117 {
1118 HILOG_DEBUG("start");
1119 min_ = min;
1120 max_ = max;
1121 current_ = current;
1122 HILOG_DEBUG("min_[%{public}d]", min_);
1123 HILOG_DEBUG("max_[%{public}d]", max_);
1124 HILOG_DEBUG("current_[%{public}d]", current_);
1125 }
1126
GetMin() const1127 int RangeInfo::GetMin() const
1128 {
1129 HILOG_DEBUG("min_[%{public}d]", min_);
1130 return min_;
1131 }
1132
GetMax() const1133 int RangeInfo::GetMax() const
1134 {
1135 HILOG_DEBUG("max_[%{public}d]", max_);
1136 return max_;
1137 }
1138
GetCurrent() const1139 int RangeInfo::GetCurrent() const
1140 {
1141 HILOG_DEBUG("current_[%{public}d]", current_);
1142 return current_;
1143 }
1144
SetMin(int min)1145 void RangeInfo::SetMin(int min)
1146 {
1147 min_ = min;
1148 HILOG_DEBUG("min_[%{public}d]", min_);
1149 }
1150
SetMax(int max)1151 void RangeInfo::SetMax(int max)
1152 {
1153 max_ = max;
1154 HILOG_DEBUG("max_[%{public}d]", max_);
1155 }
1156
SetCurrent(int current)1157 void RangeInfo::SetCurrent(int current)
1158 {
1159 current_ = current;
1160 HILOG_DEBUG("current_[%{public}d]", current_);
1161 }
1162
ReadFromParcel(Parcel & parcel)1163 bool GridInfo::ReadFromParcel(Parcel &parcel)
1164 {
1165 HILOG_DEBUG("start");
1166 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowCount_);
1167 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnCount_);
1168 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, selectionMode_);
1169
1170 return true;
1171 }
1172
Marshalling(Parcel & parcel) const1173 bool GridInfo::Marshalling(Parcel &parcel) const
1174 {
1175 HILOG_DEBUG("start");
1176 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowCount_);
1177 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnCount_);
1178 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, selectionMode_);
1179
1180 return true;
1181 };
1182
Unmarshalling(Parcel & parcel)1183 sptr<GridInfo> GridInfo::Unmarshalling(Parcel& parcel)
1184 {
1185 HILOG_DEBUG("start");
1186 sptr<GridInfo> grid = new GridInfo();
1187 if (!grid->ReadFromParcel(parcel)) {
1188 HILOG_ERROR("read from parcel failed");
1189 delete grid;
1190 grid = nullptr;
1191 }
1192 return grid;
1193 }
1194
GridInfo(int rowCount,int columnCount,int mode)1195 GridInfo::GridInfo(int rowCount, int columnCount, int mode)
1196 {
1197 HILOG_DEBUG("start");
1198 rowCount_ = rowCount;
1199 columnCount_ = columnCount;
1200 selectionMode_ = mode;
1201
1202 HILOG_DEBUG("rowCount_[%{public}d]", rowCount_);
1203 HILOG_DEBUG("columnCount_[%{public}d]", columnCount_);
1204 HILOG_DEBUG("selectionMode_[%{public}d]", selectionMode_);
1205 }
1206
SetGrid(int rowCount,int columnCount,int mode)1207 void GridInfo::SetGrid(int rowCount, int columnCount, int mode)
1208 {
1209 HILOG_DEBUG("start");
1210 rowCount_ = rowCount;
1211 columnCount_ = columnCount;
1212 selectionMode_ = mode;
1213
1214 HILOG_DEBUG("rowCount_[%{public}d]", rowCount_);
1215 HILOG_DEBUG("columnCount_[%{public}d]", columnCount_);
1216 HILOG_DEBUG("selectionMode_[%{public}d]", selectionMode_);
1217 }
1218
SetGrid(GridInfo other)1219 void GridInfo::SetGrid(GridInfo other)
1220 {
1221 HILOG_DEBUG("start");
1222 rowCount_ = other.rowCount_;
1223 columnCount_ = other.columnCount_;
1224 selectionMode_ = other.selectionMode_;
1225
1226 HILOG_DEBUG("rowCount_[%{public}d]", rowCount_);
1227 HILOG_DEBUG("columnCount_[%{public}d]", columnCount_);
1228 HILOG_DEBUG("selectionMode_[%{public}d]", selectionMode_);
1229 }
1230
GetRowCount() const1231 int GridInfo::GetRowCount() const
1232 {
1233 HILOG_DEBUG("start");
1234 HILOG_DEBUG("rowCount_[%{public}d]", rowCount_);
1235 return rowCount_;
1236 }
1237
GetColumnCount() const1238 int GridInfo::GetColumnCount() const
1239 {
1240 HILOG_DEBUG("columnCount_[%{public}d]", columnCount_);
1241 return columnCount_;
1242 }
1243
GetSelectionMode() const1244 int GridInfo::GetSelectionMode() const
1245 {
1246 HILOG_DEBUG("selectionMode_[%{public}d]", selectionMode_);
1247 return selectionMode_;
1248 }
1249
ReadFromParcel(Parcel & parcel)1250 bool GridItemInfo::ReadFromParcel(Parcel &parcel)
1251 {
1252 HILOG_DEBUG("start");
1253 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, heading_);
1254 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnIndex_);
1255 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowIndex_);
1256 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnSpan_);
1257 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowSpan_);
1258 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
1259
1260 return true;
1261 }
1262
Marshalling(Parcel & parcel) const1263 bool GridItemInfo::Marshalling(Parcel &parcel) const
1264 {
1265 HILOG_DEBUG("start");
1266 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, heading_);
1267 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnIndex_);
1268 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowIndex_);
1269 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnSpan_);
1270 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowSpan_);
1271 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
1272
1273 return true;
1274 };
1275
Unmarshalling(Parcel & parcel)1276 sptr<GridItemInfo> GridItemInfo::Unmarshalling(Parcel& parcel)
1277 {
1278 HILOG_DEBUG("start");
1279 sptr<GridItemInfo> gridItem = new GridItemInfo();
1280 if (!gridItem->ReadFromParcel(parcel)) {
1281 HILOG_ERROR("read from parcel failed");
1282 delete gridItem;
1283 gridItem = nullptr;
1284 }
1285 return gridItem;
1286 }
1287
GridItemInfo(int rowIndex,int rowSpan,int columnIndex,int columnSpan,bool heading,bool selected)1288 GridItemInfo::GridItemInfo(int rowIndex, int rowSpan, int columnIndex, int columnSpan, bool heading, bool selected)
1289 {
1290 HILOG_DEBUG("start");
1291 rowIndex_ = rowIndex;
1292 rowSpan_ = rowSpan;
1293 columnIndex_ = columnIndex;
1294 columnSpan_ = columnSpan;
1295 heading_ = heading;
1296 selected_ = selected;
1297
1298 HILOG_DEBUG("rowIndex_[%{public}d]", rowIndex_);
1299 HILOG_DEBUG("rowSpan_[%{public}d]", rowSpan_);
1300 HILOG_DEBUG("columnIndex_[%{public}d]", columnIndex_);
1301 HILOG_DEBUG("columnSpan_[%{public}d]", columnSpan_);
1302 HILOG_DEBUG("heading_[%{public}d]", heading_);
1303 HILOG_DEBUG("selected_[%{public}d]", selected_);
1304 }
1305
SetGridItemInfo(GridItemInfo other)1306 void GridItemInfo::SetGridItemInfo(GridItemInfo other)
1307 {
1308 HILOG_DEBUG("start");
1309 rowIndex_ = other.rowIndex_;
1310 rowSpan_ = other.rowSpan_;
1311 columnIndex_ = other.columnIndex_;
1312 columnSpan_ = other.columnSpan_;
1313 heading_ = other.heading_;
1314 selected_ = other.selected_;
1315
1316 HILOG_DEBUG("rowIndex_[%{public}d]", rowIndex_);
1317 HILOG_DEBUG("rowSpan_[%{public}d]", rowSpan_);
1318 HILOG_DEBUG("columnIndex_[%{public}d]", columnIndex_);
1319 HILOG_DEBUG("columnSpan_[%{public}d]", columnSpan_);
1320 HILOG_DEBUG("heading_[%{public}d]", heading_);
1321 HILOG_DEBUG("selected_[%{public}d]", selected_);
1322 }
1323
SetGridItemInfo(int rowIndex,int rowSpan,int columnIndex,int columnSpan,bool heading,bool selected)1324 void GridItemInfo::SetGridItemInfo(int rowIndex, int rowSpan, int columnIndex,
1325 int columnSpan, bool heading, bool selected)
1326 {
1327 HILOG_DEBUG("start");
1328 rowIndex_ = rowIndex;
1329 rowSpan_ = rowSpan;
1330 columnIndex_ = columnIndex;
1331 columnSpan_ = columnSpan;
1332 heading_ = heading;
1333 selected_ = selected;
1334
1335 HILOG_DEBUG("rowIndex_[%{public}d]", rowIndex_);
1336 HILOG_DEBUG("rowSpan_[%{public}d]", rowSpan_);
1337 HILOG_DEBUG("columnIndex_[%{public}d]", columnIndex_);
1338 HILOG_DEBUG("columnSpan_[%{public}d]", columnSpan_);
1339 HILOG_DEBUG("heading_[%{public}d]", heading_);
1340 HILOG_DEBUG("selected_[%{public}d]", selected_);
1341 }
1342
GetColumnIndex() const1343 int GridItemInfo::GetColumnIndex() const
1344 {
1345 HILOG_DEBUG("columnIndex_[%{public}d]", columnIndex_);
1346 return columnIndex_;
1347 }
1348
GetRowIndex() const1349 int GridItemInfo::GetRowIndex() const
1350 {
1351 HILOG_DEBUG("rowIndex_[%{public}d]", rowIndex_);
1352 return rowIndex_;
1353 }
1354
GetColumnSpan() const1355 int GridItemInfo::GetColumnSpan() const
1356 {
1357 HILOG_DEBUG("columnSpan_[%{public}d]", columnSpan_);
1358 return columnSpan_;
1359 }
1360
GetRowSpan() const1361 int GridItemInfo::GetRowSpan() const
1362 {
1363 HILOG_DEBUG("rowSpan_[%{public}d]", rowSpan_);
1364 return rowSpan_;
1365 }
1366
IsHeading() const1367 bool GridItemInfo::IsHeading() const
1368 {
1369 HILOG_DEBUG("heading_[%{public}d]", heading_);
1370 return heading_;
1371 }
1372
IsSelected() const1373 bool GridItemInfo::IsSelected() const
1374 {
1375 HILOG_DEBUG("selected_[%{public}d]", selected_);
1376 return selected_;
1377 }
1378
ReadFromParcel(Parcel & parcel)1379 bool Rect::ReadFromParcel(Parcel &parcel)
1380 {
1381 HILOG_DEBUG("start");
1382 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopX_);
1383 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopY_);
1384 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomX_);
1385 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomY_);
1386 return true;
1387 }
1388
Marshalling(Parcel & parcel) const1389 bool Rect::Marshalling(Parcel &parcel) const
1390 {
1391 HILOG_DEBUG("start");
1392 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopX_);
1393 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopY_);
1394 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomX_);
1395 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomY_);
1396 return true;
1397 };
1398
Unmarshalling(Parcel & parcel)1399 sptr<Rect> Rect::Unmarshalling(Parcel& parcel)
1400 {
1401 HILOG_DEBUG("start");
1402 sptr<Rect> rect = new Rect();
1403 if (!rect->ReadFromParcel(parcel)) {
1404 HILOG_ERROR("read from parcel failed");
1405 return nullptr;
1406 }
1407 return rect;
1408 }
1409 } // namespace Accessibility
1410 } // namespace OHOS