Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
androidjniaccessibility.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
10#include "qpa/qplatformaccessibility.h"
11#include <QtGui/private/qaccessiblebridgeutils_p.h>
13#include "qwindow.h"
14#include "qrect.h"
15#include "QtGui/qaccessible.h"
16#include <QtCore/qmath.h>
17#include <QtCore/private/qjnihelpers_p.h>
18#include <QtCore/QJniObject>
19#include <QtGui/private/qhighdpiscaling_p.h>
20
21#include <QtCore/QObject>
22#include <QtCore/qpointer.h>
23#include <QtCore/qscopeguard.h>
24#include <QtCore/qvarlengtharray.h>
25
26#include <atomic>
27
28static const char m_qtTag[] = "Qt A11Y";
29
30QT_BEGIN_NAMESPACE
31
32using namespace Qt::StringLiterals;
33
35{
63
64 static int RANGE_TYPE_INT = 0;
65 static int RANGE_TYPE_FLOAT = 0;
66 static int RANGE_TYPE_PERCENT = 0;
68
71 static int EXPANDED_STATE_FULL = 0;
72
73 static int ACTION_COLLAPSE = 0;
74 static int ACTION_EXPAND = 0;
75
76 static std::atomic<bool> m_accessibilityActivated = false;
77
79
80 // This object is needed to schedule the execution of the code that
81 // deals with accessibility instances to the Qt main thread.
82 // Because of that almost every method here is split into two parts.
83 // The _helper part is executed in the context of m_accessibilityContext
84 // on the main thread. The other part is executed in Java thread.
86
87 // This method is called from the Qt main thread, and normally a
88 // QGuiApplication instance will be used as a parent.
90 {
91 if (m_accessibilityContext)
92 m_accessibilityContext->deleteLater();
93 m_accessibilityContext = new QObject(parent);
94 }
95
96 template <typename Func, typename Ret>
97 void runInObjectContext(QObject *context, Func &&func, Ret *retVal)
98 {
99 if (QGuiApplication::topLevelWindows().isEmpty()) {
100 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
101 "Could not run accessibility call in object context, no top-level windows.");
102 return;
103 }
104
105 QtAndroidPrivate::AndroidDeadlockProtector protector(
106 u"QtAndroidAccessibility::runInObjectContext()"_s);
107 if (!protector.acquire()) {
108 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
109 "Could not run accessibility call in object context, accessing "
110 "main thread could lead to deadlock");
111 return;
112 }
113
114 if (!QtAndroid::blockEventLoopsWhenSuspended()
115 || QGuiApplication::applicationState() != Qt::ApplicationSuspended) {
116 QMetaObject::invokeMethod(context, func, Qt::BlockingQueuedConnection, retVal);
117 } else {
118 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
119 "Could not run accessibility call in object context, event loop suspended.");
120 }
121 }
122
123 bool isActive()
124 {
126 }
127
128 static void setActive(JNIEnv */*env*/, jobject /*thiz*/, jboolean active)
129 {
131
132 if (!m_accessibilityContext) {
133 __android_log_print(ANDROID_LOG_DEBUG, m_qtTag,
134 "Accessibility context is not ready, activation deferred.");
135 return;
136 }
137
138 QMetaObject::invokeMethod(m_accessibilityContext, [active]() {
139 QMutexLocker lock(QtAndroid::platformInterfaceMutex());
140
141 if (!active)
142 m_modalInterfaces.clear();
143
144 auto *platformIntegration = QtAndroid::androidPlatformIntegration();
145 if (!platformIntegration) {
146 __android_log_print(ANDROID_LOG_DEBUG, m_qtTag,
147 "Android platform integration is not ready, accessibility activation deferred.");
148 return;
149 }
150 platformIntegration->accessibility()->setActive(active);
151 }, Qt::QueuedConnection);
152 }
153
154 QAccessibleInterface *interfaceFromId(jint objectId)
155 {
156 QAccessibleInterface *iface = nullptr;
157 if (objectId == -1) {
158 QWindow *win = qApp->focusWindow();
159 if (win)
160 iface = win->accessibleRoot();
161 } else {
162 iface = QAccessible::accessibleInterface(objectId);
163 }
164 return iface;
165 }
166
167 void notifyLocationChange(uint accessibilityObjectId)
168 {
169 QtAndroid::notifyAccessibilityLocationChange(accessibilityObjectId);
170 }
171
172 static int parentId_helper(int objectId); // forward declaration
173
174 void notifyObjectHide(uint accessibilityObjectId)
175 {
176 m_modalInterfaces.removeAll(accessibilityObjectId);
177
178 const auto parentObjectId = parentId_helper(accessibilityObjectId);
179 QtAndroid::notifyObjectHide(accessibilityObjectId, parentObjectId);
180 }
181
182 void notifyObjectShow(uint accessibilityObjectId)
183 {
184 QAccessibleInterface *iface = interfaceFromId(accessibilityObjectId);
185 if (iface && iface->isValid() && iface->state().modal
186 && !m_modalInterfaces.contains(accessibilityObjectId)) {
187 m_modalInterfaces << accessibilityObjectId;
188 }
189
190 const auto parentObjectId = parentId_helper(accessibilityObjectId);
191 QtAndroid::notifyObjectShow(parentObjectId);
192 }
193
194 void notifyObjectFocus(uint accessibilityObjectId)
195 {
196 QtAndroid::notifyObjectFocus(accessibilityObjectId);
197 }
198
199 void notifyObjectDestroyed(uint accessibilityObjectId)
200 {
201 m_modalInterfaces.removeAll(accessibilityObjectId);
202 QtAndroid::notifyObjectDestroyed(accessibilityObjectId,
203 parentId_helper(accessibilityObjectId));
204 }
205
206 void notifyObjectCreated(uint accessibilityObjectId)
207 {
208 QtAndroid::notifyObjectCreated(parentId_helper(accessibilityObjectId));
209 }
210
211 void notifyValueChanged(uint accessibilityObjectId)
212 {
213 QtAndroid::notifyValueChanged(accessibilityObjectId);
214 }
215
216 void notifyDescriptionOrNameChanged(uint accessibilityObjectId)
217 {
218 QtAndroid::notifyDescriptionOrNameChanged(accessibilityObjectId);
219 }
220
221 void notifyScrolledEvent(uint accessiblityObjectId)
222 {
223 QtAndroid::notifyScrolledEvent(accessiblityObjectId);
224 }
225
226 void notifyAnnouncementEvent(uint accessibilityObjectId, const QString &message)
227 {
228 QtAndroid::notifyAnnouncementEvent(accessibilityObjectId, message);
229 }
230
232 {
233 QAccessibleInterface *iface = interfaceFromId(objectId);
234 if (iface && iface->isValid()) {
235 const int childCount = iface->childCount();
236 QVarLengthArray<jint, 8> ifaceIdArray;
237 ifaceIdArray.reserve(childCount);
238 for (int i = 0; i < childCount; ++i) {
239 QAccessibleInterface *child = iface->child(i);
240 if (child && child->isValid())
241 ifaceIdArray.append(QAccessible::uniqueId(child));
242 }
243 return ifaceIdArray;
244 }
245 return {};
246 }
247
248 static jintArray childIdListForAccessibleObject(JNIEnv *env, jobject /*thiz*/, jint objectId)
249 {
250 if (m_accessibilityContext) {
251 QVarLengthArray<jint, 8> ifaceIdArray;
252 runInObjectContext(m_accessibilityContext, [objectId]() {
253 return childIdListForAccessibleObject_helper(objectId);
254 }, &ifaceIdArray);
255 jintArray jArray = env->NewIntArray(jsize(ifaceIdArray.count()));
256 env->SetIntArrayRegion(jArray, 0, ifaceIdArray.count(), ifaceIdArray.data());
257 return jArray;
258 }
259
260 return env->NewIntArray(jsize(0));
261 }
262
263 static int parentId_helper(int objectId)
264 {
265 QAccessibleInterface *iface = interfaceFromId(objectId);
266 if (iface && iface->isValid()) {
267 QAccessibleInterface *parent = iface->parent();
268 if (parent && parent->isValid()) {
269 if (parent->role() == QAccessible::Application)
270 return -1;
271 return QAccessible::uniqueId(parent);
272 }
273 }
274 return -1;
275 }
276
277 static jint parentId(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
278 {
279 jint result = -1;
280 if (m_accessibilityContext) {
281 runInObjectContext(m_accessibilityContext, [objectId]() {
282 return parentId_helper(objectId);
283 }, &result);
284 }
285 return result;
286 }
287
288 static QRect screenRect_helper(int objectId, bool clip = true)
289 {
290 QRect rect;
291 QAccessibleInterface *iface = interfaceFromId(objectId);
292 if (iface && iface->isValid()) {
293 rect = QHighDpi::toNativePixels(iface->rect(), iface->window());
294 }
295 // If the widget is not fully in-bound in its parent then we have to clip the rectangle to draw
296 if (clip && iface && iface->parent() && iface->parent()->isValid()) {
297 const auto parentRect = QHighDpi::toNativePixels(iface->parent()->rect(), iface->parent()->window());
298 rect = rect.intersected(parentRect);
299 }
300 return rect;
301 }
302
303 static jobject screenRect(JNIEnv *env, jobject /*thiz*/, jint objectId)
304 {
305 QRect rect;
306 if (m_accessibilityContext) {
307 runInObjectContext(m_accessibilityContext, [objectId]() {
308 return screenRect_helper(objectId);
309 }, &rect);
310 }
311 jclass rectClass = env->FindClass("android/graphics/Rect");
312 jmethodID ctor = env->GetMethodID(rectClass, "<init>", "(IIII)V");
313 jobject jrect = env->NewObject(rectClass, ctor, rect.left(), rect.top(), rect.right(), rect.bottom());
314 return jrect;
315 }
316
317 static int hitTest_helper(float x, float y)
318 {
319 QAccessibleInterface *root = interfaceFromId(-1);
320 if (root && root->isValid()) {
321 QPoint pos = QHighDpi::fromNativePixels(QPoint(int(x), int(y)), root->window());
322
323 QAccessibleInterface *child = root->childAt(pos.x(), pos.y());
324 QAccessibleInterface *lastChild = nullptr;
325 while (child && (child != lastChild)) {
326 lastChild = child;
327 child = child->childAt(pos.x(), pos.y());
328 }
329 if (lastChild)
330 return QAccessible::uniqueId(lastChild);
331 }
332 return -1;
333 }
334
335 static jint hitTest(JNIEnv */*env*/, jobject /*thiz*/, jfloat x, jfloat y)
336 {
337 jint result = -1;
338 if (m_accessibilityContext) {
339 runInObjectContext(m_accessibilityContext, [x, y]() {
340 return hitTest_helper(x, y);
341 }, &result);
342 }
343 return result;
344 }
345
346 static void invokeActionOnInterfaceInMainThread(QAccessibleActionInterface* actionInterface,
347 const QString& action)
348 {
349 // Queue the action and return back to Java thread, so that we do not
350 // block it for too long
351 QMetaObject::invokeMethod(qApp, [actionInterface, action]() {
352 actionInterface->doAction(action);
353 }, Qt::QueuedConnection);
354 }
355
356 static bool clickAction_helper(int objectId)
357 {
358 QAccessibleInterface *iface = interfaceFromId(objectId);
359 if (!iface || !iface->isValid() || !iface->actionInterface())
360 return false;
361
362 const auto& actionNames = iface->actionInterface()->actionNames();
363
364 if (actionNames.contains(QAccessibleActionInterface::pressAction())) {
365 invokeActionOnInterfaceInMainThread(iface->actionInterface(),
366 QAccessibleActionInterface::pressAction());
367 } else if (actionNames.contains(QAccessibleActionInterface::toggleAction())) {
368 invokeActionOnInterfaceInMainThread(iface->actionInterface(),
369 QAccessibleActionInterface::toggleAction());
370 } else {
371 return false;
372 }
373 return true;
374 }
375
376 static bool focusAction_helper(int objectId)
377 {
378 QAccessibleInterface *iface = interfaceFromId(objectId);
379 if (!iface || !iface->isValid() || !iface->actionInterface())
380 return false;
381
382 const auto& actionNames = iface->actionInterface()->actionNames();
383
384 if (actionNames.contains(QAccessibleActionInterface::setFocusAction())) {
385 QAccessibleActionInterface *actionInterface = iface->actionInterface();
386 // Suppress keyboard activation during accessibility focus navigation.
387 QMetaObject::invokeMethod(qApp, [actionInterface]() {
388 auto *inputContext = QAndroidInputContext::androidInputContext();
389 if (inputContext)
390 inputContext->setAccessibilityFocusInProgress(true);
391 const auto resetGuard = qScopeGuard([inputContext] {
392 if (inputContext)
393 inputContext->setAccessibilityFocusInProgress(false);
394 });
395 actionInterface->doAction(QAccessibleActionInterface::setFocusAction());
396 }, Qt::QueuedConnection);
397 return true;
398 }
399 return false;
400 }
401
402 static jboolean clickAction(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
403 {
404 bool result = false;
405 if (m_accessibilityContext) {
406 runInObjectContext(m_accessibilityContext, [objectId]() {
407 return clickAction_helper(objectId);
408 }, &result);
409 }
410 return result;
411 }
412
413 static jboolean focusAction(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
414 {
415 bool result = false;
416 if (m_accessibilityContext) {
417 runInObjectContext(m_accessibilityContext, [objectId]() {
418 return focusAction_helper(objectId);
419 }, &result);
420 }
421 return result;
422 }
423
424 static bool scroll_helper(int objectId, const QString &actionName)
425 {
426 QAccessibleInterface *iface = interfaceFromId(objectId);
427 if (iface && iface->isValid())
428 return QAccessibleBridgeUtils::performEffectiveAction(iface, actionName);
429 return false;
430 }
431
432 static jboolean scrollForward(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
433 {
434 bool result = false;
435
436 const auto& ids = childIdListForAccessibleObject_helper(objectId);
437 if (ids.isEmpty())
438 return false;
439
440 const int firstChildId = ids.first();
441 const QRect oldPosition = screenRect_helper(firstChildId, false);
442
443 if (m_accessibilityContext) {
444 runInObjectContext(m_accessibilityContext, [objectId]() {
445 return scroll_helper(objectId, QAccessibleActionInterface::increaseAction());
446 }, &result);
447 }
448
449 // Don't check for position change if the call was not successful
450 return result && oldPosition != screenRect_helper(firstChildId, false);
451 }
452
453 static jboolean scrollBackward(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
454 {
455 bool result = false;
456
457 const auto& ids = childIdListForAccessibleObject_helper(objectId);
458 if (ids.isEmpty())
459 return false;
460
461 const int firstChildId = ids.first();
462 const QRect oldPosition = screenRect_helper(firstChildId, false);
463
464 if (m_accessibilityContext) {
465 runInObjectContext(m_accessibilityContext, [objectId]() {
466 return scroll_helper(objectId, QAccessibleActionInterface::decreaseAction());
467 }, &result);
468 }
469
470 // Don't check for position change if the call was not successful
471 return result && oldPosition != screenRect_helper(firstChildId, false);
472 }
473
474 static bool showOnScreen_helper(int objectId)
475 {
476 QAccessibleInterface *iface = interfaceFromId(objectId);
477 if (!iface || !iface->isValid() || !iface->actionInterface())
478 return false;
479
480 const auto actionNames = iface->actionInterface()->actionNames();
481
482 if (actionNames.contains(QAccessibleActionInterface::showOnScreenAction())) {
483 invokeActionOnInterfaceInMainThread(iface->actionInterface(), QAccessibleActionInterface::showOnScreenAction());
484 return true;
485 }
486 return false;
487 }
488
489 static jboolean showOnScreen(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
490 {
491 bool result = false;
492 if (m_accessibilityContext) {
493 runInObjectContext(m_accessibilityContext, [objectId]() {
494 return showOnScreen_helper(objectId);
495 }, &result);
496 }
497 return result;
498 }
499
500 static jboolean expand(JNIEnv * /*env*/, jobject /*thiz*/, jint objectId)
501 {
502 bool result = false;
503 if (m_accessibilityContext) {
504 runInObjectContext(
505 m_accessibilityContext, [objectId]() { return clickAction_helper(objectId); },
506 &result);
507 }
508 return result;
509 }
510
511 static jboolean collapse(JNIEnv * /*env*/, jobject /*thiz*/, jint objectId)
512 {
513 bool result = false;
514 if (m_accessibilityContext) {
515 runInObjectContext(
516 m_accessibilityContext, [objectId]() { return clickAction_helper(objectId); },
517 &result);
518 }
519 return result;
520 }
521
522 static QString textFromValue(QAccessibleInterface *iface)
523 {
524 QString valueStr;
525 QAccessibleValueInterface *valueIface = iface->valueInterface();
526 if (valueIface) {
527 const QVariant valueVar = valueIface->currentValue();
528 const auto type = valueVar.typeId();
529 if (type == QMetaType::Double || type == QMetaType::Float) {
530 // QVariant's toString() formats floating-point values with
531 // FloatingPointShortest, which is not an accessible
532 // representation; nor, in many cases, is it suitable to the UI
533 // element whose value we're looking at. So roll our own
534 // A11Y-friendly conversion to string.
535 const double val = valueVar.toDouble();
536 // Try to use minimumStepSize() to determine precision
537 bool stepIsValid = false;
538 const double step = qAbs(valueIface->minimumStepSize().toDouble(&stepIsValid));
539 if (!stepIsValid || qFuzzyIsNull(step)) {
540 // Ignore step, use default precision
541 valueStr = qFuzzyIsNull(val) ? u"0"_s : QString::number(val, 'f');
542 } else {
543 const int precision = [](double s) {
544 int count = 0;
545 while (s < 1. && !qFuzzyCompare(s, 1.)) {
546 ++count;
547 s *= 10;
548 }
549 // If s is now 1.25, we want to show some more digits,
550 // but don't want to get silly with a step like 1./7;
551 // so only include a few extra digits.
552 const int stop = count + 3;
553 const auto fractional = [](double v) {
554 double whole = 0.0;
555 std::modf(v + 0.5, &whole);
556 return qAbs(v - whole);
557 };
558 s = fractional(s);
559 while (count < stop && !qFuzzyIsNull(s)) {
560 ++count;
561 s = fractional(s * 10);
562 }
563 return count;
564 }(step);
565 valueStr = qFuzzyIsNull(val / step) ? u"0"_s
566 : QString::number(val, 'f', precision);
567 }
568 } else {
569 valueStr = valueVar.toString();
570 }
571 }
572 return valueStr;
573 }
574
575 static QString classNameForRole(QAccessible::Role role, QAccessible::State state,
576 bool isScrollable)
577 {
578 switch (role) {
579 case QAccessible::Role::Button:
580 case QAccessible::Role::Link:
581 {
582 if (state.checkable)
583 return QStringLiteral("android.widget.ToggleButton");
584 return QStringLiteral("android.widget.Button");
585 }
586 case QAccessible::Role::CheckBox:
587 // As of android/accessibility/utils/Role.java::getRole a CheckBox
588 // is NOT android.widget.CheckBox
589 return QStringLiteral("android.widget.CompoundButton");
590 case QAccessible::Role::Switch:
591 return QStringLiteral("android.widget.Switch");
592 case QAccessible::Role::Clock:
593 return QStringLiteral("android.widget.TextClock");
594 case QAccessible::Role::ComboBox:
595 case QAccessible::Role::ButtonDropDown:
596 return QStringLiteral("android.widget.Spinner");
597 case QAccessible::Role::Graphic:
598 // QQuickImage does not provide this role it inherits Client from QQuickItem
599 return QStringLiteral("android.widget.ImageView");
600 case QAccessible::Role::Grouping:
601 return QStringLiteral("android.view.ViewGroup");
602 case QAccessible::Role::List:
603 // As of android/accessibility/utils/Role.java::getRole a List
604 // is NOT android.widget.ListView
605 return QStringLiteral("android.widget.AbsListView");
606 case QAccessible::Role::MenuItem:
607 return QStringLiteral("android.view.MenuItem");
608 case QAccessible::Role::PopupMenu:
609 return QStringLiteral("android.widget.PopupMenu");
610 case QAccessible::Role::Separator:
611 return QStringLiteral("android.widget.Space");
612 case QAccessible::Role::ToolBar:
613 return QStringLiteral("android.view.Toolbar");
614 case QAccessible::Role::Heading: [[fallthrough]];
615 case QAccessible::Role::StaticText:
616 // Heading vs. regular Text is finally determined by AccessibilityNodeInfo.isHeading()
617 return QStringLiteral("android.widget.TextView");
618 case QAccessible::Role::EditableText:
619 return QStringLiteral("android.widget.EditText");
620 case QAccessible::Role::RadioButton:
621 return QStringLiteral("android.widget.RadioButton");
622 case QAccessible::Role::ProgressBar:
623 return QStringLiteral("android.widget.ProgressBar");
624 case QAccessible::Role::SpinBox:
625 return QStringLiteral("android.widget.NumberPicker");
626 case QAccessible::Role::WebDocument:
627 return QStringLiteral("android.webkit.WebView");
628 case QAccessible::Role::Dialog:
629 return QStringLiteral("android.app.AlertDialog");
630 case QAccessible::Role::PageTab:
631 return QStringLiteral("android.app.ActionBar.Tab");
632 case QAccessible::Role::PageTabList:
633 return QStringLiteral("android.widget.TabWidget");
634 case QAccessible::Role::ScrollBar:
635 case QAccessible::Role::Slider:
636 return QStringLiteral("android.widget.SeekBar");
637 case QAccessible::Role::Table:
638 // #TODO Evaluate the usage of AccessibleNodeInfo.setCollectionItemInfo() to provide
639 // infos about colums, rows und items.
640 return QStringLiteral("android.widget.GridView");
641 case QAccessible::Role::Pane:
642 if (isScrollable)
643 return QStringLiteral("android.widget.ScrollView");
644 return QStringLiteral("android.view.ViewGroup");
645 case QAccessible::Role::Client:
646 if (isScrollable)
647 return QStringLiteral("android.widget.ScrollView");
648 [[fallthrough]];
649 case QAccessible::Role::AlertMessage:
650 case QAccessible::Role::Animation:
651 case QAccessible::Role::Application:
652 case QAccessible::Role::Assistant:
653 case QAccessible::Role::BlockQuote:
654 case QAccessible::Role::Border:
655 case QAccessible::Role::ButtonDropGrid:
656 case QAccessible::Role::ButtonMenu:
657 case QAccessible::Role::Canvas:
658 case QAccessible::Role::Caret:
659 case QAccessible::Role::Cell:
660 case QAccessible::Role::Chart:
661 case QAccessible::Role::ColorChooser:
662 case QAccessible::Role::Column:
663 case QAccessible::Role::ColumnHeader:
664 case QAccessible::Role::ComplementaryContent:
665 case QAccessible::Role::Cursor:
666 case QAccessible::Role::Desktop:
667 case QAccessible::Role::Dial:
668 case QAccessible::Role::Document:
669 case QAccessible::Role::Equation:
670 case QAccessible::Role::Footer:
671 case QAccessible::Role::Form:
672 case QAccessible::Role::Grip:
673 case QAccessible::Role::HelpBalloon:
674 case QAccessible::Role::HotkeyField:
675 case QAccessible::Role::Indicator:
676 case QAccessible::Role::LayeredPane:
677 case QAccessible::Role::ListItem:
678 case QAccessible::Role::MenuBar:
679 case QAccessible::Role::NoRole:
680 case QAccessible::Role::Note:
681 case QAccessible::Role::Notification:
682 case QAccessible::Role::Paragraph:
683 case QAccessible::Role::PropertyPage:
684 case QAccessible::Role::Row:
685 case QAccessible::Role::RowHeader:
686 case QAccessible::Role::Section:
687 case QAccessible::Role::Sound:
688 case QAccessible::Role::Splitter:
689 case QAccessible::Role::StatusBar:
690 case QAccessible::Role::Terminal:
691 case QAccessible::Role::TitleBar:
692 case QAccessible::Role::ToolTip:
693 case QAccessible::Role::Tree:
694 case QAccessible::Role::TreeItem:
695 case QAccessible::Role::UserRole:
696 case QAccessible::Role::Whitespace:
697 case QAccessible::Role::Window:
698 // If unsure, every visible or interactive element in Android
699 // inherits android.view.View and by many extends also TextView.
700 // Android itself does a similar thing e.g. in its Settings-App.
701 return QStringLiteral("android.view.TextView");
702 }
703 }
704
705 static int expandedStateFromState(QAccessible::State state)
706 {
707 if (!state.expandable)
709
710 return state.expanded ? EXPANDED_STATE_FULL : EXPANDED_STATE_COLLAPSED;
711 }
712
713 static QString descriptionForInterface(QAccessibleInterface *iface)
714 {
715 QString desc;
716 if (iface && iface->isValid()) {
717 bool hasValue = false;
718 desc = iface->text(QAccessible::Name);
719 const QString descStr = iface->text(QAccessible::Description);
720 if (!descStr.isEmpty()) {
721 if (!desc.isEmpty())
722 desc.append(QStringLiteral(", "));
723 desc.append(descStr);
724 }
725 if (desc.isEmpty()) {
726 desc = iface->text(QAccessible::Value);
727 hasValue = !desc.isEmpty();
728 }
729 if (!hasValue && iface->valueInterface()) {
730 const QString valueStr = textFromValue(iface);
731 if (!valueStr.isEmpty()) {
732 if (!desc.isEmpty())
733 desc.append(QChar(QChar::Space));
734 desc.append(valueStr);
735 }
736 }
737 }
738 return desc;
739 }
740
741 static QString descriptionForAccessibleObject_helper(int objectId)
742 {
743 QAccessibleInterface *iface = interfaceFromId(objectId);
744 return descriptionForInterface(iface);
745 }
746
747 static jstring descriptionForAccessibleObject(JNIEnv *env, jobject /*thiz*/, jint objectId)
748 {
749 QString desc;
750 if (m_accessibilityContext) {
751 runInObjectContext(m_accessibilityContext, [objectId]() {
752 return descriptionForAccessibleObject_helper(objectId);
753 }, &desc);
754 }
755 return env->NewString((jchar*) desc.constData(), (jsize) desc.size());
756 }
757
758 static QString languageTag_helper(int objectId)
759 {
760 QAccessibleInterface *iface = interfaceFromId(objectId);
761 if (!iface || !iface->isValid())
762 return QString();
763
764 QAccessibleAttributesInterface *attributesIface = iface->attributesInterface();
765 if (!attributesIface || !attributesIface->attributeKeys().contains(QAccessible::Attribute::Locale))
766 return QString();
767
768 return attributesIface->attributeValue(QAccessible::Attribute::Locale).toLocale().bcp47Name();
769 }
770
771 static jstring languageTag(JNIEnv *env, jobject /*thiz*/, jint objectId)
772 {
773 QString tag;
774 if (m_accessibilityContext) {
775 runInObjectContext(m_accessibilityContext, [objectId]() {
776 return languageTag_helper(objectId);
777 }, &tag);
778 }
779 return env->NewString((jchar*)tag.constData(), (jsize)tag.size());
780 }
781
782 static bool childOfModalInterface(QAccessibleInterface *modalInterface,
783 QAccessibleInterface *iface)
784 {
785 if (!iface || !modalInterface)
786 return false;
787
788 if (iface == modalInterface)
789 return true;
790
791 return childOfModalInterface(modalInterface, iface->parent());
792 }
793
794 static bool isScrollableNode(QAccessibleInterface *iface, const QStringList &actions)
795 {
796 if (!iface || !iface->isValid())
797 return false;
798 if (iface->role() == QAccessible::ScrollBar || iface->role() == QAccessible::List)
799 return true;
800 return actions.contains(QAccessibleActionInterface::increaseAction())
801 || actions.contains(QAccessibleActionInterface::decreaseAction());
802 }
803
804 struct NodeInfo
805 {
806 bool valid = false;
810 QString description;
811 QString text;
812 QString hint;
813 QString identifier;
814 bool hasTextSelection = false;
817 bool hasValue = false;
818 QVariant minValue = 0;
819 QVariant maxValue = 0;
820 QVariant currentValue = 0;
821 QVariant valueStepSize = 0;
822 bool blockedByModal = false;
823 bool isScrollable = false;
824 bool isCollection = false;
827 };
828
829 static NodeInfo populateNode_helper(int objectId)
830 {
831 NodeInfo info;
832 QAccessibleInterface *iface = interfaceFromId(objectId);
833 if (iface && iface->isValid()) {
834 info.valid = true;
835 info.state = iface->state();
836 info.role = iface->role();
837 info.actions = QAccessibleBridgeUtils::effectiveActionNames(iface);
838 info.description = descriptionForInterface(iface);
839 info.identifier = QAccessibleBridgeUtils::accessibleId(iface);
840 QAccessibleTextInterface *textIface = iface->textInterface();
841 if (textIface && (textIface->selectionCount() > 0)) {
842 info.hasTextSelection = true;
843 textIface->selection(0, &info.selectionStart, &info.selectionEnd);
844 }
845 // For editable nodes, capture the text (exposed via setText(), which
846 // a screen reader reads to track the caret and echo edits) and the
847 // accessible name (exposed via setHintText(), the label channel a
848 // screen reader reads for a text input).
849 if (info.state.editable) {
850 if (textIface)
851 info.text = textIface->text(0, textIface->characterCount());
852 info.hint = iface->text(QAccessible::Name);
853 }
854 QAccessibleValueInterface *valueInterface = iface->valueInterface();
855 if (valueInterface) {
856 info.hasValue = true;
857 info.minValue = valueInterface->minimumValue();
858 info.maxValue = valueInterface->maximumValue();
859 info.currentValue = valueInterface->currentValue();
860 info.valueStepSize = valueInterface->minimumStepSize();
861 }
862 if (!m_modalInterfaces.isEmpty()
863 && !childOfModalInterface(interfaceFromId(m_modalInterfaces.last()), iface)) {
864 info.blockedByModal = true;
865 }
866
867 info.isCollection = iface->role() == QAccessible::List;
868 info.isScrollable = isScrollableNode(iface, info.actions);
869 if (info.isCollection)
870 info.collectionRowCount = iface->childCount();
871 }
872 return info;
873 }
874
875 static jboolean populateNode(JNIEnv *env, jobject /*thiz*/, jint objectId, jobject node)
876 {
877 NodeInfo info;
878 if (m_accessibilityContext) {
879 runInObjectContext(m_accessibilityContext, [objectId]() {
880 return populateNode_helper(objectId);
881 }, &info);
882 }
883 if (!info.valid) {
884 __android_log_print(ANDROID_LOG_WARN, m_qtTag, "Accessibility: populateNode for Invalid ID");
885 return false;
886 }
887
888 const QString role = classNameForRole(info.role, info.state, info.isScrollable);
889 jstring jrole = env->NewString((jchar*)role.constData(), (jsize)role.size());
890 env->CallVoidMethod(node, m_setClassNameMethodID, jrole);
891
892 const bool hasClickableAction =
893 (info.actions.contains(QAccessibleActionInterface::pressAction())
894 || info.actions.contains(QAccessibleActionInterface::toggleAction()))
895 && !(info.role == QAccessible::StaticText || info.role == QAccessible::Heading);
896 const bool hasIncreaseAction =
897 info.actions.contains(QAccessibleActionInterface::increaseAction());
898 const bool hasDecreaseAction =
899 info.actions.contains(QAccessibleActionInterface::decreaseAction());
900
901 if (info.hasTextSelection && m_setTextSelectionMethodID) {
902 env->CallVoidMethod(node, m_setTextSelectionMethodID, info.selectionStart,
903 info.selectionEnd);
904 }
905
906 if (info.hasValue && m_setRangeInfoMethodID) {
907 int valueType = info.currentValue.typeId();
908 jint rangeType = RANGE_TYPE_INDETERMINATE;
909 switch (valueType) {
910 case QMetaType::Float:
911 case QMetaType::Double:
912 rangeType = RANGE_TYPE_FLOAT;
913 break;
914 case QMetaType::Int:
915 rangeType = RANGE_TYPE_INT;
916 break;
917 }
918
919 float min = info.minValue.toFloat();
920 float max = info.maxValue.toFloat();
921 float current = info.currentValue.toFloat();
922 if (info.role == QAccessible::ProgressBar) {
923 rangeType = RANGE_TYPE_PERCENT;
924 current = 100 * (current - min) / (max - min);
925 min = 0.0f;
926 max = 100.0f;
927 }
928
929 QJniObject rangeInfo;
930 if (QtAndroidPrivate::androidSdkVersion() < 30) {
931 rangeInfo = QJniObject::callStaticObjectMethod(
932 "android/view/accessibility/AccessibilityNodeInfo$RangeInfo", "obtain",
933 "(IFFF)Landroid/view/accessibility/AccessibilityNodeInfo$RangeInfo;",
934 rangeType, min, max, current);
935 } else {
936 rangeInfo = QJniObject("android/view/accessibility/AccessibilityNodeInfo$RangeInfo",
937 "(IFFF)V", rangeType, min, max, current);
938 }
939
940 if (rangeInfo.isValid()) {
941 env->CallVoidMethod(node, m_setRangeInfoMethodID, rangeInfo.object());
942 }
943 }
944
945 env->CallVoidMethod(node, m_setCheckableMethodID, (bool)info.state.checkable);
946 env->CallVoidMethod(node, m_setCheckedMethodID, (bool)info.state.checked);
947 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
948 env->CallVoidMethod(node, m_setExpandedStateMethodID,
949 expandedStateFromState(info.state));
950 }
951 env->CallVoidMethod(node, m_setEditableMethodID, info.state.editable);
952 env->CallVoidMethod(node, m_setEnabledMethodID, !info.state.disabled);
953 env->CallVoidMethod(node, m_setFocusableMethodID, (bool)info.state.focusable);
954 env->CallVoidMethod(node, m_setFocusedMethodID, (bool)info.state.focused);
956 env->CallVoidMethod(node, m_setHeadingMethodID, info.role == QAccessible::Heading);
957 env->CallVoidMethod(node, m_setVisibleToUserMethodID,
958 !info.state.invisible && !info.blockedByModal);
959 env->CallVoidMethod(node, m_setScrollableMethodID,
960 info.isCollection || info.isScrollable);
961 env->CallVoidMethod(node, m_setClickableMethodID, hasClickableAction || info.role == QAccessible::Link);
962
963 // Add ACTION_CLICK
964 if (hasClickableAction)
965 env->CallVoidMethod(node, m_addActionMethodID, (int)0x00000010); // ACTION_CLICK defined in AccessibilityNodeInfo
966
967 // Add ACTION_SCROLL_FORWARD
968 if (hasIncreaseAction)
969 env->CallVoidMethod(node, m_addActionMethodID, (int)0x00001000); // ACTION_SCROLL_FORWARD defined in AccessibilityNodeInfo
970
971 // Add ACTION_SCROLL_BACKWARD
972 if (hasDecreaseAction)
973 env->CallVoidMethod(node, m_addActionMethodID, (int)0x00002000); // ACTION_SCROLL_BACKWARD defined in AccessibilityNodeInfo
974
975 // Add ACTION_EXPAND / ACTION_COLLAPSE
976 if (info.state.expandable) {
977 if (info.state.expanded) {
978 env->CallVoidMethod(node, m_addActionMethodID, ACTION_COLLAPSE);
979 } else {
980 env->CallVoidMethod(node, m_addActionMethodID, ACTION_EXPAND);
981 }
982 }
983
984 // try to fill in the text property, this is what the screen reader reads
985 jstring jdesc = env->NewString((jchar*)info.description.constData(),
986 (jsize)info.description.size());
987 //CALL_METHOD(node, "setText", "(Ljava/lang/CharSequence;)V", jdesc)
988 env->CallVoidMethod(node, m_setContentDescriptionMethodID, jdesc);
989
990 // An editable node exposes its content via setText() (read to track the
991 // caret and echo edits), its label via setHintText() (the label channel
992 // for a text input), and an inputType so it is treated as a real text
993 // field. contentDescription is kept above for readers that use it instead.
994 if (info.state.editable) {
995 if (m_setTextMethodID) {
996 jstring jtext = env->NewString((jchar*)info.text.constData(),
997 (jsize)info.text.size());
998 env->CallVoidMethod(node, m_setTextMethodID, jtext);
999 env->DeleteLocalRef(jtext);
1000 }
1001 // 0x1 == android.text.InputType.TYPE_CLASS_TEXT.
1003 env->CallVoidMethod(node, m_setInputTypeMethodID, (jint)0x00000001);
1005 jstring jhint = env->NewString((jchar*)info.hint.constData(),
1006 (jsize)info.hint.size());
1007 env->CallVoidMethod(node, m_setHintTextMethodID, jhint);
1008 env->DeleteLocalRef(jhint);
1009 }
1010 }
1011
1012 if (info.isCollection && m_setCollectionInfoMethodID) {
1013 QJniObject collectionInfo;
1014 if (QtAndroidPrivate::androidSdkVersion() >= 30) {
1015 collectionInfo = QJniObject(
1016 "android/view/accessibility/AccessibilityNodeInfo$CollectionInfo", "(IIZ)V",
1018 } else {
1019 collectionInfo = QJniObject::callStaticObjectMethod(
1020 "android/view/accessibility/AccessibilityNodeInfo$CollectionInfo", "obtain",
1021 "(IIZ)Landroid/view/accessibility/AccessibilityNodeInfo$CollectionInfo;",
1022 info.collectionRowCount, info.collectionColumnCount, false);
1023 }
1024 if (collectionInfo.isValid())
1025 env->CallVoidMethod(node, m_setCollectionInfoMethodID, collectionInfo.object());
1026 }
1027
1028 QJniObject(node).callMethod<void>("setViewIdResourceName", info.identifier);
1029
1030 return true;
1031 }
1032
1041
1043 {
1044 QAccessibleInterface *iface = interfaceFromId(objectId);
1045 if (!iface || !iface->isValid())
1046 return { };
1047
1048 auto *viewportIface = iface->viewportInterface();
1049 if (!viewportIface)
1050 return { };
1051
1052 ScrollEventInfo info;
1053 info.isValid = true;
1054 info.isIndexed = viewportIface->isIndexed();
1055 info.contentSize = viewportIface->contentSize();
1056 info.position = viewportIface->position();
1057 info.viewportSize = viewportIface->viewportSize();
1058
1059 return info;
1060 }
1061
1062 static jboolean populateScrollEvent(JNIEnv *env, jobject /*thiz*/, jint objectId, jobject event)
1063 {
1064 ScrollEventInfo info;
1065 if (m_accessibilityContext) {
1066 runInObjectContext(
1067 m_accessibilityContext,
1068 [objectId]() { return populateScrollEvent_helper(objectId); }, &info);
1069 }
1070
1071 if (!info.isValid)
1072 return false;
1073
1074 if (info.isIndexed) {
1075 const int itemCount = std::max(info.contentSize.width(), info.contentSize.height());
1076 env->CallVoidMethod(event, m_setItemCountMethodID, itemCount);
1077 const int fromIndex = std::max(info.position.x(), info.position.y()) * itemCount;
1078 env->CallVoidMethod(event, m_setFromIndexMethodID, fromIndex);
1079 const int toIndex = fromIndex
1080 + std::min(info.viewportSize.width(), info.viewportSize.height() * itemCount);
1081 env->CallVoidMethod(event, m_setToIndexMethodID, toIndex);
1082
1083 } else {
1084 env->CallVoidMethod(event, m_setScrollXMethodID,
1085 (int)(info.position.x() * info.contentSize.width()));
1086 env->CallVoidMethod(event, m_setMaxScrollXMethodID, (int)info.contentSize.width());
1087 env->CallVoidMethod(event, m_setScrollYMethodID,
1088 (int)(info.position.y() * info.contentSize.height()));
1089 env->CallVoidMethod(event, m_setMaxScrollYMethodID, (int)info.contentSize.height());
1090 }
1091
1092 return true;
1093 }
1094
1095 static const JNINativeMethod methods[] = {
1096 {"setActive","(Z)V",(void*)setActive},
1097 {"childIdListForAccessibleObject", "(I)[I", (jintArray)childIdListForAccessibleObject},
1098 {"parentId", "(I)I", (void*)parentId},
1099 {"descriptionForAccessibleObject", "(I)Ljava/lang/String;", (jstring)descriptionForAccessibleObject},
1100 {"languageTag", "(I)Ljava/lang/String;", (jstring)languageTag},
1101 {"screenRect", "(I)Landroid/graphics/Rect;", (jobject)screenRect},
1102 {"hitTest", "(FF)I", (void*)hitTest},
1103 {"populateNode", "(ILandroid/view/accessibility/AccessibilityNodeInfo;)Z", (void*)populateNode},
1104 {"populateScrollEvent", "(ILandroid/view/accessibility/AccessibilityEvent;)Z", (void*)populateScrollEvent},
1105 {"clickAction", "(I)Z", (void*)clickAction},
1106 {"focusAction", "(I)Z", (void*)focusAction},
1107 {"scrollForward", "(I)Z", (void*)scrollForward},
1108 {"scrollBackward", "(I)Z", (void*)scrollBackward},
1109 {"showOnScreen", "(I)Z", (void *)showOnScreen},
1110 {"expand", "(I)Z", (void *)expand},
1111 {"collapse", "(I)Z", (void *)collapse}
1112 };
1113
1114#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE)
1115 VAR = env->GetMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE);
1116 if (!VAR) {
1117 __android_log_print(ANDROID_LOG_FATAL, QtAndroid::qtTagText(), QtAndroid::methodErrorMsgFmt(), METHOD_NAME, METHOD_SIGNATURE);
1118 return false;
1119 }
1120
1121#define CHECK_AND_INIT_STATIC_FIELD(TYPE, VAR, CLASS, FIELD_NAME)
1122 if (env.findStaticField<TYPE>(CLASS, FIELD_NAME) == nullptr) {
1123 __android_log_print(ANDROID_LOG_FATAL, QtAndroid::qtTagText(),
1124 QtAndroid::staticFieldErrorMsgFmt(), FIELD_NAME);
1125 return false;
1126 }
1127 VAR = QJniObject::getStaticField<TYPE>(CLASS, FIELD_NAME);
1128
1129 bool registerNatives(QJniEnvironment &env)
1130 {
1131 if (!env.registerNativeMethods("org/qtproject/qt/android/QtNativeAccessibility",
1132 methods, sizeof(methods) / sizeof(methods[0]))) {
1133 __android_log_print(ANDROID_LOG_FATAL,"Qt A11y", "RegisterNatives failed");
1134 return false;
1135 }
1136
1137 jclass nodeInfoClass = env->FindClass("android/view/accessibility/AccessibilityNodeInfo");
1138 GET_AND_CHECK_STATIC_METHOD(m_setClassNameMethodID, nodeInfoClass, "setClassName", "(Ljava/lang/CharSequence;)V");
1139 GET_AND_CHECK_STATIC_METHOD(m_addActionMethodID, nodeInfoClass, "addAction", "(I)V");
1140 GET_AND_CHECK_STATIC_METHOD(m_setCheckableMethodID, nodeInfoClass, "setCheckable", "(Z)V");
1141 GET_AND_CHECK_STATIC_METHOD(m_setCheckedMethodID, nodeInfoClass, "setChecked", "(Z)V");
1142 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
1143 GET_AND_CHECK_STATIC_METHOD(m_setExpandedStateMethodID, nodeInfoClass,
1144 "setExpandedState", "(I)V");
1145 }
1146 GET_AND_CHECK_STATIC_METHOD(m_setClickableMethodID, nodeInfoClass, "setClickable", "(Z)V");
1147 GET_AND_CHECK_STATIC_METHOD(m_setContentDescriptionMethodID, nodeInfoClass, "setContentDescription", "(Ljava/lang/CharSequence;)V");
1148 GET_AND_CHECK_STATIC_METHOD(m_setTextMethodID, nodeInfoClass, "setText", "(Ljava/lang/CharSequence;)V");
1149 GET_AND_CHECK_STATIC_METHOD(m_setInputTypeMethodID, nodeInfoClass, "setInputType", "(I)V");
1150 // setHintText is API 26+, below Qt's API-28 floor, so no SDK guard needed.
1151 GET_AND_CHECK_STATIC_METHOD(m_setHintTextMethodID, nodeInfoClass, "setHintText", "(Ljava/lang/CharSequence;)V");
1152 GET_AND_CHECK_STATIC_METHOD(m_setEditableMethodID, nodeInfoClass, "setEditable", "(Z)V");
1153 GET_AND_CHECK_STATIC_METHOD(m_setEnabledMethodID, nodeInfoClass, "setEnabled", "(Z)V");
1154 GET_AND_CHECK_STATIC_METHOD(m_setFocusableMethodID, nodeInfoClass, "setFocusable", "(Z)V");
1155 GET_AND_CHECK_STATIC_METHOD(m_setFocusedMethodID, nodeInfoClass, "setFocused", "(Z)V");
1156 if (QtAndroidPrivate::androidSdkVersion() >= 28) {
1157 GET_AND_CHECK_STATIC_METHOD(m_setHeadingMethodID, nodeInfoClass, "setHeading", "(Z)V");
1158 }
1159 GET_AND_CHECK_STATIC_METHOD(m_setScrollableMethodID, nodeInfoClass, "setScrollable", "(Z)V");
1160 GET_AND_CHECK_STATIC_METHOD(m_setVisibleToUserMethodID, nodeInfoClass, "setVisibleToUser", "(Z)V");
1161 GET_AND_CHECK_STATIC_METHOD(m_setTextSelectionMethodID, nodeInfoClass, "setTextSelection", "(II)V");
1163 m_setRangeInfoMethodID, nodeInfoClass, "setRangeInfo",
1164 "(Landroid/view/accessibility/AccessibilityNodeInfo$RangeInfo;)V");
1166 m_setCollectionInfoMethodID, nodeInfoClass, "setCollectionInfo",
1167 "(Landroid/view/accessibility/AccessibilityNodeInfo$CollectionInfo;)V");
1168
1169 jclass eventClass = env->FindClass("android/view/accessibility/AccessibilityEvent");
1170 GET_AND_CHECK_STATIC_METHOD(m_setMaxScrollXMethodID, eventClass, "setMaxScrollX", "(I)V");
1171 GET_AND_CHECK_STATIC_METHOD(m_setScrollXMethodID, eventClass, "setScrollX", "(I)V");
1172 GET_AND_CHECK_STATIC_METHOD(m_setMaxScrollYMethodID, eventClass, "setMaxScrollY", "(I)V");
1173 GET_AND_CHECK_STATIC_METHOD(m_setScrollYMethodID, eventClass, "setScrollY", "(I)V");
1174 GET_AND_CHECK_STATIC_METHOD(m_setItemCountMethodID, eventClass, "setItemCount", "(I)V");
1175 GET_AND_CHECK_STATIC_METHOD(m_setFromIndexMethodID, eventClass, "setFromIndex", "(I)V");
1176 GET_AND_CHECK_STATIC_METHOD(m_setToIndexMethodID, eventClass, "setToIndex", "(I)V");
1177
1178 jclass rangeInfoClass =
1179 env->FindClass("android/view/accessibility/AccessibilityNodeInfo$RangeInfo");
1180 CHECK_AND_INIT_STATIC_FIELD(int, RANGE_TYPE_INT, rangeInfoClass, "RANGE_TYPE_INT");
1181 CHECK_AND_INIT_STATIC_FIELD(int, RANGE_TYPE_FLOAT, rangeInfoClass, "RANGE_TYPE_FLOAT");
1182 CHECK_AND_INIT_STATIC_FIELD(int, RANGE_TYPE_PERCENT, rangeInfoClass, "RANGE_TYPE_PERCENT");
1183 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
1185 "RANGE_TYPE_INDETERMINATE");
1186 } else {
1188 }
1189
1190 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
1192 "EXPANDED_STATE_UNDEFINED");
1194 "EXPANDED_STATE_COLLAPSED");
1196 "EXPANDED_STATE_FULL");
1197 }
1198
1199 CHECK_AND_INIT_STATIC_FIELD(int, ACTION_COLLAPSE, nodeInfoClass, "ACTION_COLLAPSE");
1200 CHECK_AND_INIT_STATIC_FIELD(int, ACTION_EXPAND, nodeInfoClass, "ACTION_EXPAND");
1201
1202 return true;
1203 }
1204}
1205
1206QT_END_NAMESPACE
static const char m_qtTag[]
#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE)
#define CHECK_AND_INIT_STATIC_FIELD(TYPE, VAR, CLASS, FIELD_NAME)
\inmodule QtCore\reentrant
Definition qpoint.h:30
static jboolean showOnScreen(JNIEnv *, jobject, jint objectId)
void notifyDescriptionOrNameChanged(uint accessibilityObjectId)
void notifyObjectShow(uint accessibilityObjectId)
static bool clickAction_helper(int objectId)
static const JNINativeMethod methods[]
void notifyLocationChange(uint accessibilityObjectId)
void runInObjectContext(QObject *context, Func &&func, Ret *retVal)
static std::atomic< bool > m_accessibilityActivated
static jmethodID m_setCollectionInfoMethodID
static jboolean scrollForward(JNIEnv *, jobject, jint objectId)
static ScrollEventInfo populateScrollEvent_helper(int objectId)
void notifyObjectFocus(uint accessibilityObjectId)
static jboolean scrollBackward(JNIEnv *, jobject, jint objectId)
static QString descriptionForInterface(QAccessibleInterface *iface)
static bool isScrollableNode(QAccessibleInterface *iface, const QStringList &actions)
static bool showOnScreen_helper(int objectId)
static int hitTest_helper(float x, float y)
static jboolean expand(JNIEnv *, jobject, jint objectId)
static jstring descriptionForAccessibleObject(JNIEnv *env, jobject, jint objectId)
void notifyObjectDestroyed(uint accessibilityObjectId)
static bool scroll_helper(int objectId, const QString &actionName)
static jmethodID m_setContentDescriptionMethodID
static QString textFromValue(QAccessibleInterface *iface)
void createAccessibilityContextObject(QObject *parent)
static QVarLengthArray< int, 8 > childIdListForAccessibleObject_helper(int objectId)
void notifyObjectCreated(uint accessibilityObjectId)
static NodeInfo populateNode_helper(int objectId)
void notifyObjectHide(uint accessibilityObjectId)
static jboolean focusAction(JNIEnv *, jobject, jint objectId)
static jmethodID m_setExpandedStateMethodID
static QList< QAccessible::Id > m_modalInterfaces
static QString languageTag_helper(int objectId)
static jmethodID m_setVisibleToUserMethodID
static jint hitTest(JNIEnv *, jobject, jfloat x, jfloat y)
static jstring languageTag(JNIEnv *env, jobject, jint objectId)
static bool focusAction_helper(int objectId)
static jboolean clickAction(JNIEnv *, jobject, jint objectId)
static bool childOfModalInterface(QAccessibleInterface *modalInterface, QAccessibleInterface *iface)
static void setActive(JNIEnv *, jobject, jboolean active)
static void invokeActionOnInterfaceInMainThread(QAccessibleActionInterface *actionInterface, const QString &action)
static jmethodID m_setTextSelectionMethodID
bool registerNatives(QJniEnvironment &env)
QAccessibleInterface * interfaceFromId(jint objectId)
void notifyValueChanged(uint accessibilityObjectId)
static jboolean populateScrollEvent(JNIEnv *env, jobject, jint objectId, jobject event)
static int expandedStateFromState(QAccessible::State state)
void notifyAnnouncementEvent(uint accessibilityObjectId, const QString &message)
static int parentId_helper(int objectId)
static QRect screenRect_helper(int objectId, bool clip=true)
static QString classNameForRole(QAccessible::Role role, QAccessible::State state, bool isScrollable)
static QString descriptionForAccessibleObject_helper(int objectId)
static jint parentId(JNIEnv *, jobject, jint objectId)
static jboolean collapse(JNIEnv *, jobject, jint objectId)
static jobject screenRect(JNIEnv *env, jobject, jint objectId)
static jintArray childIdListForAccessibleObject(JNIEnv *env, jobject, jint objectId)
static jboolean populateNode(JNIEnv *env, jobject, jint objectId, jobject node)
void notifyScrolledEvent(uint accessiblityObjectId)
#define qApp