10#include "qpa/qplatformaccessibility.h"
11#include <QtGui/private/qaccessiblebridgeutils_p.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>
21#include <QtCore/QObject>
22#include <QtCore/qpointer.h>
23#include <QtCore/qscopeguard.h>
24#include <QtCore/qvarlengtharray.h>
30using namespace Qt::StringLiterals;
86 if (m_accessibilityContext)
87 m_accessibilityContext->deleteLater();
88 m_accessibilityContext =
new QObject(parent);
91 template <
typename Func,
typename Ret>
95 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
96 "Could not run accessibility call in object context, no valid surface.");
100 QtAndroidPrivate::AndroidDeadlockProtector protector(
101 u"QtAndroidAccessibility::runInObjectContext()"_s);
102 if (!protector.acquire()) {
103 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
104 "Could not run accessibility call in object context, accessing "
105 "main thread could lead to deadlock");
109 if (!QtAndroid::blockEventLoopsWhenSuspended()
110 || QGuiApplication::applicationState() != Qt::ApplicationSuspended) {
111 QMetaObject::invokeMethod(context, func, Qt::BlockingQueuedConnection, retVal);
113 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
114 "Could not run accessibility call in object context, event loop suspended.");
128 if (platformIntegration) {
129 platformIntegration->accessibility()->setActive(active);
131 __android_log_print(ANDROID_LOG_DEBUG, m_qtTag,
132 "Android platform integration is not ready, accessibility activation deferred.");
138 QAccessibleInterface *iface =
nullptr;
139 if (objectId == -1) {
140 QWindow *win =
qApp->focusWindow();
142 iface = win->accessibleRoot();
144 iface = QAccessible::accessibleInterface(objectId);
151 QtAndroid::notifyAccessibilityLocationChange(accessibilityObjectId);
158 const auto parentObjectId = parentId_helper(accessibilityObjectId);
159 QtAndroid::notifyObjectHide(accessibilityObjectId, parentObjectId);
164 const auto parentObjectId = parentId_helper(accessibilityObjectId);
165 QtAndroid::notifyObjectShow(parentObjectId);
170 QtAndroid::notifyObjectFocus(accessibilityObjectId);
177 jstring value = jvalueForAccessibleObject(accessibilityObjectId);
178 QtAndroid::notifyValueChanged(accessibilityObjectId, value);
186 QAccessibleInterface *iface = interfaceFromId(accessibilityObjectId);
187 if (iface && iface->isValid()) {
188 const QString value = descriptionForInterface(iface);
189 QtAndroid::notifyDescriptionOrNameChanged(accessibilityObjectId, value);
195 QtAndroid::notifyScrolledEvent(accessiblityObjectId);
200 QtAndroid::notifyAnnouncementEvent(accessibilityObjectId, message);
205 QAccessibleInterface *iface = interfaceFromId(objectId);
206 if (iface && iface->isValid()) {
207 const int childCount = iface->childCount();
208 QVarLengthArray<jint, 8> ifaceIdArray;
209 ifaceIdArray.reserve(childCount);
210 for (
int i = 0; i < childCount; ++i) {
211 QAccessibleInterface *child = iface->child(i);
212 if (child && child->isValid())
213 ifaceIdArray.append(QAccessible::uniqueId(child));
222 if (m_accessibilityContext) {
223 QVarLengthArray<jint, 8> ifaceIdArray;
224 runInObjectContext(m_accessibilityContext, [objectId]() {
225 return childIdListForAccessibleObject_helper(objectId);
227 jintArray jArray = env->NewIntArray(jsize(ifaceIdArray.count()));
228 env->SetIntArrayRegion(jArray, 0, ifaceIdArray.count(), ifaceIdArray.data());
232 return env->NewIntArray(jsize(0));
237 QAccessibleInterface *iface = interfaceFromId(objectId);
238 if (iface && iface->isValid()) {
239 QAccessibleInterface *parent = iface->parent();
240 if (parent && parent->isValid()) {
241 if (parent->role() == QAccessible::Application)
243 return QAccessible::uniqueId(parent);
252 if (m_accessibilityContext) {
253 runInObjectContext(m_accessibilityContext, [objectId]() {
254 return parentId_helper(objectId);
263 QAccessibleInterface *iface = interfaceFromId(objectId);
264 if (iface && iface->isValid()) {
265 rect = QHighDpi::toNativePixels(iface->rect(), iface->window());
268 if (clip && iface && iface->parent() && iface->parent()->isValid()) {
269 const auto parentRect = QHighDpi::toNativePixels(iface->parent()->rect(), iface->parent()->window());
270 rect = rect.intersected(parentRect);
278 if (m_accessibilityContext) {
279 runInObjectContext(m_accessibilityContext, [objectId]() {
280 return screenRect_helper(objectId);
283 jclass rectClass = env->FindClass(
"android/graphics/Rect");
284 jmethodID ctor = env->GetMethodID(rectClass,
"<init>",
"(IIII)V");
285 jobject jrect = env->NewObject(rectClass, ctor, rect.left(), rect.top(), rect.right(), rect.bottom());
291 QAccessibleInterface *root = interfaceFromId(-1);
292 if (root && root->isValid()) {
293 QPoint pos = QHighDpi::fromNativePixels(QPoint(
int(x),
int(y)), root->window());
295 QAccessibleInterface *child = root->childAt(pos.x(), pos.y());
296 QAccessibleInterface *lastChild =
nullptr;
297 while (child && (child != lastChild)) {
299 child = child->childAt(pos.x(), pos.y());
302 return QAccessible::uniqueId(lastChild);
310 if (m_accessibilityContext) {
311 runInObjectContext(m_accessibilityContext, [x, y]() {
312 return hitTest_helper(x, y);
319 const QString& action)
323 QMetaObject::invokeMethod(
qApp, [actionInterface, action]() {
324 actionInterface->doAction(action);
325 }, Qt::QueuedConnection);
330 QAccessibleInterface *iface = interfaceFromId(objectId);
331 if (!iface || !iface->isValid() || !iface->actionInterface())
334 const auto& actionNames = iface->actionInterface()->actionNames();
336 if (actionNames.contains(QAccessibleActionInterface::pressAction())) {
337 invokeActionOnInterfaceInMainThread(iface->actionInterface(),
338 QAccessibleActionInterface::pressAction());
339 }
else if (actionNames.contains(QAccessibleActionInterface::toggleAction())) {
340 invokeActionOnInterfaceInMainThread(iface->actionInterface(),
341 QAccessibleActionInterface::toggleAction());
350 QAccessibleInterface *iface = interfaceFromId(objectId);
351 if (!iface || !iface->isValid() || !iface->actionInterface())
354 const auto& actionNames = iface->actionInterface()->actionNames();
356 if (actionNames.contains(QAccessibleActionInterface::setFocusAction())) {
357 QAccessibleActionInterface *actionInterface = iface->actionInterface();
359 QMetaObject::invokeMethod(
qApp, [actionInterface]() {
360 auto *inputContext = QAndroidInputContext::androidInputContext();
362 inputContext->setAccessibilityFocusInProgress(
true);
363 const auto resetGuard = qScopeGuard([inputContext] {
365 inputContext->setAccessibilityFocusInProgress(
false);
367 actionInterface->doAction(QAccessibleActionInterface::setFocusAction());
368 }, Qt::QueuedConnection);
377 if (m_accessibilityContext) {
378 runInObjectContext(m_accessibilityContext, [objectId]() {
379 return clickAction_helper(objectId);
388 if (m_accessibilityContext) {
389 runInObjectContext(m_accessibilityContext, [objectId]() {
390 return focusAction_helper(objectId);
398 QAccessibleInterface *iface = interfaceFromId(objectId);
399 if (iface && iface->isValid())
400 return QAccessibleBridgeUtils::performEffectiveAction(iface, actionName);
408 const auto& ids = childIdListForAccessibleObject_helper(objectId);
412 const int firstChildId = ids.first();
413 const QRect oldPosition = screenRect_helper(firstChildId,
false);
415 if (m_accessibilityContext) {
416 runInObjectContext(m_accessibilityContext, [objectId]() {
417 return scroll_helper(objectId, QAccessibleActionInterface::increaseAction());
422 return result && oldPosition != screenRect_helper(firstChildId,
false);
429 const auto& ids = childIdListForAccessibleObject_helper(objectId);
433 const int firstChildId = ids.first();
434 const QRect oldPosition = screenRect_helper(firstChildId,
false);
436 if (m_accessibilityContext) {
437 runInObjectContext(m_accessibilityContext, [objectId]() {
438 return scroll_helper(objectId, QAccessibleActionInterface::decreaseAction());
443 return result && oldPosition != screenRect_helper(firstChildId,
false);
448 QAccessibleInterface *iface = interfaceFromId(objectId);
449 if (!iface || !iface->isValid() || !iface->actionInterface())
452 const auto actionNames = iface->actionInterface()->actionNames();
454 if (actionNames.contains(QAccessibleActionInterface::showOnScreenAction())) {
455 invokeActionOnInterfaceInMainThread(iface->actionInterface(), QAccessibleActionInterface::showOnScreenAction());
464 if (m_accessibilityContext) {
465 runInObjectContext(m_accessibilityContext, [objectId]() {
466 return showOnScreen_helper(objectId);
475 if (m_accessibilityContext) {
477 m_accessibilityContext, [objectId]() {
return clickAction_helper(objectId); },
486 if (m_accessibilityContext) {
488 m_accessibilityContext, [objectId]() {
return clickAction_helper(objectId); },
497 QAccessibleValueInterface *valueIface = iface->valueInterface();
499 const QVariant valueVar = valueIface->currentValue();
500 const auto type = valueVar.typeId();
501 if (type == QMetaType::Double || type == QMetaType::Float) {
507 const double val = valueVar.toDouble();
509 bool stepIsValid =
false;
510 const double step = qAbs(valueIface->minimumStepSize().toDouble(&stepIsValid));
511 if (!stepIsValid || qFuzzyIsNull(step)) {
513 valueStr = qFuzzyIsNull(val) ? u"0"_s : QString::number(val,
'f');
515 const int precision = [](
double s) {
517 while (s < 1. && !qFuzzyCompare(s, 1.)) {
524 const int stop = count + 3;
525 const auto fractional = [](
double v) {
527 std::modf(v + 0.5, &whole);
528 return qAbs(v - whole);
531 while (count < stop && !qFuzzyIsNull(s)) {
533 s = fractional(s * 10);
537 valueStr = qFuzzyIsNull(val / step) ? u"0"_s
538 : QString::number(val,
'f', precision);
541 valueStr = valueVar.toString();
549 QAccessibleInterface *iface = interfaceFromId(objectId);
550 const QString value = textFromValue(iface);
552 jstring jstr = env->NewString((jchar*)value.constData(), (jsize)value.size());
553 if (env.checkAndClearExceptions())
554 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
"Failed to create jstring");
560 case QAccessible::Role::Button:
561 case QAccessible::Role::Link:
564 return QStringLiteral(
"android.widget.ToggleButton");
565 return QStringLiteral(
"android.widget.Button");
567 case QAccessible::Role::CheckBox:
570 return QStringLiteral(
"android.widget.CompoundButton");
571 case QAccessible::Role::Switch:
572 return QStringLiteral(
"android.widget.Switch");
573 case QAccessible::Role::Clock:
574 return QStringLiteral(
"android.widget.TextClock");
575 case QAccessible::Role::ComboBox:
576 return QStringLiteral(
"android.widget.Spinner");
577 case QAccessible::Role::Graphic:
579 return QStringLiteral(
"android.widget.ImageView");
580 case QAccessible::Role::Grouping:
581 return QStringLiteral(
"android.view.ViewGroup");
582 case QAccessible::Role::List:
585 return QStringLiteral(
"android.widget.AbsListView");
586 case QAccessible::Role::MenuItem:
587 return QStringLiteral(
"android.view.MenuItem");
588 case QAccessible::Role::PopupMenu:
589 return QStringLiteral(
"android.widget.PopupMenu");
590 case QAccessible::Role::Separator:
591 return QStringLiteral(
"android.widget.Space");
592 case QAccessible::Role::ToolBar:
593 return QStringLiteral(
"android.view.Toolbar");
594 case QAccessible::Role::Heading: [[fallthrough]];
595 case QAccessible::Role::StaticText:
597 return QStringLiteral(
"android.widget.TextView");
598 case QAccessible::Role::EditableText:
599 return QStringLiteral(
"android.widget.EditText");
600 case QAccessible::Role::RadioButton:
601 return QStringLiteral(
"android.widget.RadioButton");
602 case QAccessible::Role::ProgressBar:
603 return QStringLiteral(
"android.widget.ProgressBar");
604 case QAccessible::Role::SpinBox:
605 return QStringLiteral(
"android.widget.NumberPicker");
606 case QAccessible::Role::WebDocument:
607 return QStringLiteral(
"android.webkit.WebView");
608 case QAccessible::Role::Dialog:
609 return QStringLiteral(
"android.app.AlertDialog");
610 case QAccessible::Role::PageTab:
611 return QStringLiteral(
"android.app.ActionBar.Tab");
612 case QAccessible::Role::PageTabList:
613 return QStringLiteral(
"android.widget.TabWidget");
614 case QAccessible::Role::ScrollBar:
615 return QStringLiteral(
"android.widget.Scroller");
616 case QAccessible::Role::Slider:
617 return QStringLiteral(
"com.google.android.material.slider.Slider");
618 case QAccessible::Role::Table:
621 return QStringLiteral(
"android.widget.GridView");
622 case QAccessible::Role::Pane:
624 return QStringLiteral(
"android.view.ViewGroup");
625 case QAccessible::Role::AlertMessage:
626 case QAccessible::Role::Animation:
627 case QAccessible::Role::Application:
628 case QAccessible::Role::Assistant:
629 case QAccessible::Role::BlockQuote:
630 case QAccessible::Role::Border:
631 case QAccessible::Role::ButtonDropGrid:
632 case QAccessible::Role::ButtonDropDown:
633 case QAccessible::Role::ButtonMenu:
634 case QAccessible::Role::Canvas:
635 case QAccessible::Role::Caret:
636 case QAccessible::Role::Cell:
637 case QAccessible::Role::Chart:
638 case QAccessible::Role::Client:
639 case QAccessible::Role::ColorChooser:
640 case QAccessible::Role::Column:
641 case QAccessible::Role::ColumnHeader:
642 case QAccessible::Role::ComplementaryContent:
643 case QAccessible::Role::Cursor:
644 case QAccessible::Role::Desktop:
645 case QAccessible::Role::Dial:
646 case QAccessible::Role::Document:
647 case QAccessible::Role::Equation:
648 case QAccessible::Role::Footer:
649 case QAccessible::Role::Form:
650 case QAccessible::Role::Grip:
651 case QAccessible::Role::HelpBalloon:
652 case QAccessible::Role::HotkeyField:
653 case QAccessible::Role::Indicator:
654 case QAccessible::Role::LayeredPane:
655 case QAccessible::Role::ListItem:
656 case QAccessible::Role::MenuBar:
657 case QAccessible::Role::NoRole:
658 case QAccessible::Role::Note:
659 case QAccessible::Role::Notification:
660 case QAccessible::Role::Paragraph:
661 case QAccessible::Role::PropertyPage:
662 case QAccessible::Role::Row:
663 case QAccessible::Role::RowHeader:
664 case QAccessible::Role::Section:
665 case QAccessible::Role::Sound:
666 case QAccessible::Role::Splitter:
667 case QAccessible::Role::StatusBar:
668 case QAccessible::Role::Terminal:
669 case QAccessible::Role::TitleBar:
670 case QAccessible::Role::ToolTip:
671 case QAccessible::Role::Tree:
672 case QAccessible::Role::TreeItem:
673 case QAccessible::Role::UserRole:
674 case QAccessible::Role::Whitespace:
675 case QAccessible::Role::Window:
679 return QStringLiteral(
"android.view.TextView");
685 if (!state.expandable)
694 if (iface && iface->isValid()) {
695 bool hasValue =
false;
696 desc = iface->text(QAccessible::Name);
697 const QString descStr = iface->text(QAccessible::Description);
698 if (!descStr.isEmpty()) {
700 desc.append(QStringLiteral(
", "));
701 desc.append(descStr);
703 if (desc.isEmpty()) {
704 desc = iface->text(QAccessible::Value);
705 hasValue = !desc.isEmpty();
707 if (!hasValue && iface->valueInterface()) {
708 const QString valueStr = textFromValue(iface);
709 if (!valueStr.isEmpty()) {
711 desc.append(QChar(QChar::Space));
712 desc.append(valueStr);
721 QAccessibleInterface *iface = interfaceFromId(objectId);
722 return descriptionForInterface(iface);
728 if (m_accessibilityContext) {
729 runInObjectContext(m_accessibilityContext, [objectId]() {
730 return descriptionForAccessibleObject_helper(objectId);
733 return env->NewString((jchar*) desc.constData(), (jsize) desc.size());
738 QAccessibleInterface *iface = interfaceFromId(objectId);
739 if (!iface || !iface->isValid())
742 QAccessibleAttributesInterface *attributesIface = iface->attributesInterface();
743 if (!attributesIface || !attributesIface->attributeKeys().contains(QAccessible::Attribute::Locale))
746 return attributesIface->attributeValue(QAccessible::Attribute::Locale).toLocale().bcp47Name();
752 if (m_accessibilityContext) {
753 runInObjectContext(m_accessibilityContext, [objectId]() {
754 return languageTag_helper(objectId);
757 return env->NewString((jchar*)tag.constData(), (jsize)tag.size());
783 QAccessibleInterface *iface = interfaceFromId(objectId);
784 if (iface && iface->isValid()) {
786 info.state = iface->state();
787 info.role = iface->role();
788 info.actions = QAccessibleBridgeUtils::effectiveActionNames(iface);
789 info.description = descriptionForInterface(iface);
790 info.identifier = QAccessibleBridgeUtils::accessibleId(iface);
791 QAccessibleTextInterface *textIface = iface->textInterface();
792 if (textIface && (textIface->selectionCount() > 0)) {
800 if (info.state.editable) {
802 info.text = textIface->text(0, textIface->characterCount());
803 info.hint = iface->text(QAccessible::Name);
805 QAccessibleValueInterface *valueInterface = iface->valueInterface();
806 if (valueInterface) {
808 info.minValue = valueInterface->minimumValue();
809 info.maxValue = valueInterface->maximumValue();
810 info.currentValue = valueInterface->currentValue();
811 info.valueStepSize = valueInterface->minimumStepSize();
820 if (m_accessibilityContext) {
821 runInObjectContext(m_accessibilityContext, [objectId]() {
822 return populateNode_helper(objectId);
826 __android_log_print(ANDROID_LOG_WARN, m_qtTag,
"Accessibility: populateNode for Invalid ID");
830 const QString role = classNameForRole(info.role, info.state);
831 jstring jrole = env->NewString((jchar*)role.constData(), (jsize)role.size());
832 env->CallVoidMethod(node, m_setClassNameMethodID, jrole);
834 const bool hasClickableAction =
835 (info.actions.contains(QAccessibleActionInterface::pressAction())
836 || info.actions.contains(QAccessibleActionInterface::toggleAction()))
837 && !(info.role == QAccessible::StaticText || info.role == QAccessible::Heading);
838 const bool hasIncreaseAction =
839 info.actions.contains(QAccessibleActionInterface::increaseAction());
840 const bool hasDecreaseAction =
841 info.actions.contains(QAccessibleActionInterface::decreaseAction());
842 const bool scrollableRole =
843 info.role == QAccessible::ScrollBar || info.role == QAccessible::List;
846 env->CallVoidMethod(node, m_setTextSelectionMethodID, info
.selectionStart,
850 if (info
.hasValue && m_setRangeInfoMethodID) {
851 int valueType = info.currentValue.typeId();
854 case QMetaType::Float:
855 case QMetaType::Double:
863 float min = info.minValue.toFloat();
864 float max = info.maxValue.toFloat();
865 float current = info.currentValue.toFloat();
866 if (info.role == QAccessible::ProgressBar) {
868 current = 100 * (current - min) / (max - min);
873 QJniObject rangeInfo(
"android/view/accessibility/AccessibilityNodeInfo$RangeInfo",
874 "(IFFF)V", rangeType, min, max, current);
876 if (rangeInfo.isValid()) {
877 env->CallVoidMethod(node, m_setRangeInfoMethodID, rangeInfo.object());
881 env->CallVoidMethod(node, m_setCheckableMethodID, (
bool)info.state.checkable);
882 env->CallVoidMethod(node, m_setCheckedMethodID, (
bool)info.state.checked);
883 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
884 env->CallVoidMethod(node, m_setExpandedStateMethodID,
885 expandedStateFromState(info.state));
887 env->CallVoidMethod(node, m_setEditableMethodID, info.state.editable);
888 env->CallVoidMethod(node, m_setEnabledMethodID, !info.state.disabled);
889 env->CallVoidMethod(node, m_setFocusableMethodID, (
bool)info.state.focusable);
890 env->CallVoidMethod(node, m_setFocusedMethodID, (
bool)info.state.focused);
892 env->CallVoidMethod(node, m_setHeadingMethodID, info.role == QAccessible::Heading);
893 env->CallVoidMethod(node, m_setVisibleToUserMethodID, !info.state.invisible);
894 env->CallVoidMethod(node, m_setScrollableMethodID,
895 hasIncreaseAction || hasDecreaseAction || scrollableRole);
896 env->CallVoidMethod(node, m_setClickableMethodID, hasClickableAction || info.role == QAccessible::Link);
899 if (hasClickableAction)
900 env->CallVoidMethod(node, m_addActionMethodID, (
int)0x00000010);
903 if (hasIncreaseAction)
904 env->CallVoidMethod(node, m_addActionMethodID, (
int)0x00001000);
907 if (hasDecreaseAction)
908 env->CallVoidMethod(node, m_addActionMethodID, (
int)0x00002000);
911 if (info.state.expandable) {
912 if (info.state.expanded) {
915 env->CallVoidMethod(node, m_addActionMethodID,
ACTION_EXPAND);
920 jstring jdesc = env->NewString((jchar*)info.description.constData(),
921 (jsize)info.description.size());
923 env->CallVoidMethod(node, m_setContentDescriptionMethodID, jdesc);
929 if (info.state.editable) {
931 jstring jtext = env->NewString((jchar*)info.text.constData(),
932 (jsize)info.text.size());
933 env->CallVoidMethod(node, m_setTextMethodID, jtext);
934 env->DeleteLocalRef(jtext);
938 env->CallVoidMethod(node, m_setInputTypeMethodID, (jint)0x00000001);
940 jstring jhint = env->NewString((jchar*)info.hint.constData(),
941 (jsize)info.hint.size());
942 env->CallVoidMethod(node, m_setHintTextMethodID, jhint);
943 env->DeleteLocalRef(jhint);
947 QJniObject(node).callMethod<
void>(
"setViewIdResourceName", info.identifier);
963 QAccessibleInterface *iface = interfaceFromId(objectId);
964 if (!iface || !iface->isValid())
967 auto *viewportIface = iface->viewportInterface();
974 info.contentSize = viewportIface->contentSize();
975 info.position = viewportIface->position();
976 info.viewportSize = viewportIface->viewportSize();
984 if (m_accessibilityContext) {
986 m_accessibilityContext,
987 [objectId]() {
return populateScrollEvent_helper(objectId); }, &info);
994 const int itemCount =
std::max(info.contentSize.width(), info.contentSize.height());
995 env->CallVoidMethod(event, m_setItemCountMethodID, itemCount);
996 const int fromIndex =
std::max(info.position.x(), info.position.y()) * itemCount;
997 env->CallVoidMethod(event, m_setFromIndexMethodID, fromIndex);
998 const int toIndex = fromIndex
999 +
std::min(info.viewportSize.width(), info.viewportSize.height() * itemCount);
1000 env->CallVoidMethod(event, m_setToIndexMethodID, toIndex);
1003 env->CallVoidMethod(event, m_setScrollXMethodID,
1004 (
int)(info.position.x() * info.contentSize.width()));
1005 env->CallVoidMethod(event, m_setMaxScrollXMethodID, (
int)info.contentSize.width());
1006 env->CallVoidMethod(event, m_setScrollYMethodID,
1007 (
int)(info.position.y() * info.contentSize.height()));
1008 env->CallVoidMethod(event, m_setMaxScrollYMethodID, (
int)info.contentSize.height());
1017 {
"parentId",
"(I)I", (
void*)
parentId},
1021 {
"hitTest",
"(FF)I", (
void*)
hitTest},
1022 {
"populateNode",
"(ILandroid/view/accessibility/AccessibilityNodeInfo;)Z", (
void*)
populateNode},
1023 {
"populateScrollEvent",
"(ILandroid/view/accessibility/AccessibilityEvent;)Z", (
void*)
populateScrollEvent},
1029 {
"expand",
"(I)Z", (
void *)
expand},
1030 {
"collapse",
"(I)Z", (
void *)
collapse}
1033#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE)
1034 VAR = env->GetMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE);
1036 __android_log_print(ANDROID_LOG_FATAL, QtAndroid::qtTagText(), QtAndroid::methodErrorMsgFmt(), METHOD_NAME, METHOD_SIGNATURE);
1040#define CHECK_AND_INIT_STATIC_FIELD(TYPE, VAR, CLASS, FIELD_NAME)
1041 if (env.findStaticField<TYPE>(CLASS, FIELD_NAME) == nullptr) {
1042 __android_log_print(ANDROID_LOG_FATAL, QtAndroid::qtTagText(),
1043 QtAndroid::staticFieldErrorMsgFmt(), FIELD_NAME);
1046 VAR = QJniObject::getStaticField<TYPE>(CLASS, FIELD_NAME);
1050 if (!env.registerNativeMethods(
"org/qtproject/qt/android/QtNativeAccessibility",
1052 __android_log_print(ANDROID_LOG_FATAL,
"Qt A11y",
"RegisterNatives failed");
1056 jclass nodeInfoClass = env->FindClass(
"android/view/accessibility/AccessibilityNodeInfo");
1061 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
1063 "setExpandedState",
"(I)V");
1066 GET_AND_CHECK_STATIC_METHOD(m_setContentDescriptionMethodID, nodeInfoClass,
"setContentDescription",
"(Ljava/lang/CharSequence;)V");
1075 if (QtAndroidPrivate::androidSdkVersion() >= 28) {
1082 m_setRangeInfoMethodID, nodeInfoClass,
"setRangeInfo",
1083 "(Landroid/view/accessibility/AccessibilityNodeInfo$RangeInfo;)V");
1085 jclass eventClass = env->FindClass(
"android/view/accessibility/AccessibilityEvent");
1094 jclass rangeInfoClass =
1095 env->FindClass(
"android/view/accessibility/AccessibilityNodeInfo$RangeInfo");
1099 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
1101 "RANGE_TYPE_INDETERMINATE");
1106 if (QtAndroidPrivate::androidSdkVersion() >= 36) {
1108 "EXPANDED_STATE_UNDEFINED");
1110 "EXPANDED_STATE_COLLAPSED");
1112 "EXPANDED_STATE_FULL");
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
static int ACTION_COLLAPSE
static jmethodID m_setCheckableMethodID
static int RANGE_TYPE_FLOAT
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 jmethodID m_setFocusableMethodID
static jmethodID m_setFocusedMethodID
static int RANGE_TYPE_INDETERMINATE
static jmethodID m_setClassNameMethodID
static jmethodID m_setInputTypeMethodID
static jmethodID m_setEditableMethodID
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 jmethodID m_setEnabledMethodID
static jboolean expand(JNIEnv *, jobject, jint objectId)
static int RANGE_TYPE_PERCENT
static jstring descriptionForAccessibleObject(JNIEnv *env, jobject, jint objectId)
static bool scroll_helper(int objectId, const QString &actionName)
static QString classNameForRole(QAccessible::Role role, QAccessible::State state)
static jmethodID m_setContentDescriptionMethodID
static bool m_accessibilityActivated
static jmethodID m_setFromIndexMethodID
static QString textFromValue(QAccessibleInterface *iface)
static jmethodID m_setTextMethodID
void createAccessibilityContextObject(QObject *parent)
static jmethodID m_setMaxScrollXMethodID
static QVarLengthArray< int, 8 > childIdListForAccessibleObject_helper(int objectId)
static jmethodID m_setClickableMethodID
static int EXPANDED_STATE_COLLAPSED
static NodeInfo populateNode_helper(int objectId)
static jmethodID m_setScrollYMethodID
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 jmethodID m_setScrollableMethodID
static jint hitTest(JNIEnv *, jobject, jfloat x, jfloat y)
static jmethodID m_setRangeInfoMethodID
static jstring languageTag(JNIEnv *env, jobject, jint objectId)
static jmethodID m_addActionMethodID
static bool focusAction_helper(int objectId)
static int EXPANDED_STATE_UNDEFINED
static jboolean clickAction(JNIEnv *, jobject, jint objectId)
static int RANGE_TYPE_INT
static jmethodID m_setCheckedMethodID
static jmethodID m_setScrollXMethodID
static jstring jvalueForAccessibleObject(int objectId)
static void setActive(JNIEnv *, jobject, jboolean active)
static void invokeActionOnInterfaceInMainThread(QAccessibleActionInterface *actionInterface, const QString &action)
static jmethodID m_setMaxScrollYMethodID
static jmethodID m_setTextSelectionMethodID
bool registerNatives(QJniEnvironment &env)
static int EXPANDED_STATE_FULL
QAccessibleInterface * interfaceFromId(jint objectId)
void notifyValueChanged(uint accessibilityObjectId)
static jboolean populateScrollEvent(JNIEnv *env, jobject, jint objectId, jobject event)
static jmethodID m_setToIndexMethodID
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 jmethodID m_setHeadingMethodID
static jmethodID m_setItemCountMethodID
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 jmethodID m_setHintTextMethodID
static jboolean populateNode(JNIEnv *env, jobject, jint objectId, jobject node)
void notifyScrolledEvent(uint accessiblityObjectId)
QBasicMutex * platformInterfaceMutex()
QAndroidPlatformIntegration * androidPlatformIntegration()