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