From 513fcf0d2ad3328830dbf73dc2a55ad1487393c0 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Tue, 1 Feb 2022 17:17:12 +0100 Subject: Android A11Y: execute C++ code on main Qt thread The C++ code, which is called from Java, was executed on Java thread. However Qt has its own main GUI thread, where all GUI elements and their accessibility instances are created. As a result we have threading issues when accessing A11Y objects from Java thread. This patch uses QMetaObject::invokeMethod calls to dispatch all the critical parts of the C++ code to the main thread. It uses BlockingQueuedConnection, so that Java thread can still use these methods synchronously. The proper context is based on the m_accessibilityContext object, which is created as a child of the base accessibility QObject of the application (which is the QGuiApplication instance in most cases). Task-number: QTBUG-95764 Change-Id: Iff4f3f2645657f6aca426fa19ccc86a2cbe4d4d0 Reviewed-by: Assam Boudjelthia Reviewed-by: Jarkko Koivikko (cherry picked from commit e0c61193ea8f6462192d2ef7f1d48d8fa3e38c99) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/android/qandroidplatformaccessibility.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/plugins/platforms/android/qandroidplatformaccessibility.cpp') diff --git a/src/plugins/platforms/android/qandroidplatformaccessibility.cpp b/src/plugins/platforms/android/qandroidplatformaccessibility.cpp index 159d5ca09d..2d4c7294eb 100644 --- a/src/plugins/platforms/android/qandroidplatformaccessibility.cpp +++ b/src/plugins/platforms/android/qandroidplatformaccessibility.cpp @@ -69,4 +69,10 @@ void QAndroidPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent * } } +void QAndroidPlatformAccessibility::setRootObject(QObject *obj) +{ + QPlatformAccessibility::setRootObject(obj); + QtAndroidAccessibility::createAccessibilityContextObject(obj); +} + QT_END_NAMESPACE -- cgit v1.2.3 From f546e3e7c98f1aced03ebf1f467ac1a04c579824 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 10 Feb 2022 11:53:24 +0100 Subject: Android A11Y: handle valueChanged events Before this patch Android A11Y implementation was missing ValueChanged event handling. As a result, no update was given when the element's value was changed. Handling these events allows us to announce value changes on such objects like Slider, SpinBox, etc... This is a universal method of value-change announcement, so it supports all sorts of A11Y gestures. On the Java side a new function was introduced to announce the values, because we need to use the actual element's *value*, not its accessible name or description. Task-number: QTBUG-93396 Change-Id: Ic44abd5f01b9b6f5468962131466edaf6a49d498 Reviewed-by: Assam Boudjelthia Reviewed-by: Rami Potinkara (cherry picked from commit b238f83380dcaa2830999a8f413f4b648db80beb) --- src/plugins/platforms/android/qandroidplatformaccessibility.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/platforms/android/qandroidplatformaccessibility.cpp') diff --git a/src/plugins/platforms/android/qandroidplatformaccessibility.cpp b/src/plugins/platforms/android/qandroidplatformaccessibility.cpp index 2d4c7294eb..73f3a54e65 100644 --- a/src/plugins/platforms/android/qandroidplatformaccessibility.cpp +++ b/src/plugins/platforms/android/qandroidplatformaccessibility.cpp @@ -66,6 +66,8 @@ void QAndroidPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent * QtAndroidAccessibility::notifyObjectHide(event->uniqueId()); } else if (event->type() == QAccessible::Focus) { QtAndroidAccessibility::notifyObjectFocus(event->uniqueId()); + } else if (event->type() == QAccessible::ValueChanged) { + QtAndroidAccessibility::notifyValueChanged(event->uniqueId()); } } -- cgit v1.2.3