summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-05-17 10:17:48 +0200
committerIvan Solovev <ivan.solovev@qt.io>2022-05-17 15:50:24 +0200
commitd550a99505c61d6d72049e7e4c92c1edb4b90d7d (patch)
treee485675356a3a3093e870b4bf1a32dbd05f71758
parent1af04d67bdf5cb973e46f84cbab28a7a89bab543 (diff)
Android A11Y: handle LocationChanged event only for focused element
LocationChanged event unconditionally triggered invalidateVirtualViewId call. That call results in TYPE_WINDOW_CONTENT_CHANGED Android event, which causes a lot of background processing. That is not correct, because LocationChanged event is generated by every accessible element, not only the one that has A11Y focus. This patch checks event->uniqueId(), and processes only events that come from the focused accessible element. Done-with: Mike Achtelik <mike.achtelik@gmail.com> Task-number: QTBUG-102594 Change-Id: I6b941733c9d215fed5ee5a7aeeb5be234add9ebe Reviewed-by: Mike Achtelik <mike.achtelik@gmail.com> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit 0613146d210e494bf98e0e4de97e03fc5021736e) Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java4
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java4
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java5
-rw-r--r--src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java4
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.cpp4
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.h2
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp6
-rw-r--r--src/plugins/platforms/android/androidjnimain.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformaccessibility.cpp2
9 files changed, 18 insertions, 15 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index 9f7c040c17..184956d8ef 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -894,11 +894,11 @@ public class QtActivityDelegate
m_splashScreen.startAnimation(fadeOut);
}
- public void notifyAccessibilityLocationChange()
+ public void notifyAccessibilityLocationChange(int viewId)
{
if (m_accessibilityDelegate == null)
return;
- m_accessibilityDelegate.notifyLocationChange();
+ m_accessibilityDelegate.notifyLocationChange(viewId);
}
public void notifyObjectHide(int viewId, int parentId)
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index c0d6c900ae..e019797cf6 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -948,13 +948,13 @@ public class QtNative
return m_activityDelegate.isKeyboardVisible() && !m_isKeyboardHiding;
}
- private static void notifyAccessibilityLocationChange()
+ private static void notifyAccessibilityLocationChange(final int viewId)
{
runAction(new Runnable() {
@Override
public void run() {
if (m_activityDelegate != null) {
- m_activityDelegate.notifyAccessibilityLocationChange();
+ m_activityDelegate.notifyAccessibilityLocationChange(viewId);
}
}
});
diff --git a/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java
index 90e38231fc..3b910e288d 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java
@@ -193,9 +193,10 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
return true;
}
- public void notifyLocationChange()
+ public void notifyLocationChange(int viewId)
{
- invalidateVirtualViewId(m_focusedVirtualViewId);
+ if (m_focusedVirtualViewId == viewId)
+ invalidateVirtualViewId(m_focusedVirtualViewId);
}
public void notifyObjectHide(int viewId, int parentId)
diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
index 5b3e330282..dd94d6267a 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
@@ -1122,9 +1122,9 @@ public class QtActivity extends Activity
QtNative.activityDelegate().setFullScreen(enterFullScreen);
}
- public void notifyAccessibilityLocationChange()
+ public void notifyAccessibilityLocationChange(int viewId)
{
- QtNative.activityDelegate().notifyAccessibilityLocationChange();
+ QtNative.activityDelegate().notifyAccessibilityLocationChange(viewId);
}
public void notifyObjectHide(int viewId, int parentId)
diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
index 649cea84c0..07906650ee 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
@@ -134,9 +134,9 @@ namespace QtAndroidAccessibility
return iface;
}
- void notifyLocationChange()
+ void notifyLocationChange(uint accessibilityObjectId)
{
- QtAndroid::notifyAccessibilityLocationChange();
+ QtAndroid::notifyAccessibilityLocationChange(accessibilityObjectId);
}
static int parentId_helper(int objectId); // forward declaration
diff --git a/src/plugins/platforms/android/androidjniaccessibility.h b/src/plugins/platforms/android/androidjniaccessibility.h
index 484786c649..c9469df178 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.h
+++ b/src/plugins/platforms/android/androidjniaccessibility.h
@@ -51,7 +51,7 @@ namespace QtAndroidAccessibility
void initialize();
bool isActive();
bool registerNatives(JNIEnv *env);
- void notifyLocationChange();
+ void notifyLocationChange(uint accessibilityObjectId);
void notifyObjectHide(uint accessibilityObjectId);
void notifyObjectFocus(uint accessibilityObjectId);
void notifyValueChanged(uint accessibilityObjectId);
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 207f94bb58..4717b88ae3 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -225,9 +225,11 @@ namespace QtAndroid
m_statusBarShowing = false;
}
- void notifyAccessibilityLocationChange()
+ void notifyAccessibilityLocationChange(uint accessibilityObjectId)
{
- QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "notifyAccessibilityLocationChange");
+ QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass,
+ "notifyAccessibilityLocationChange",
+ "(I)V", accessibilityObjectId);
}
void notifyObjectHide(uint accessibilityObjectId, uint parentObjectId)
diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h
index 2fbb6633ab..f2204631aa 100644
--- a/src/plugins/platforms/android/androidjnimain.h
+++ b/src/plugins/platforms/android/androidjnimain.h
@@ -95,7 +95,7 @@ namespace QtAndroid
jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env);
jobject createBitmapDrawable(jobject bitmap, JNIEnv *env = 0);
- void notifyAccessibilityLocationChange();
+ void notifyAccessibilityLocationChange(uint accessibilityObjectId);
void notifyObjectHide(uint accessibilityObjectId, uint parentObjectId);
void notifyObjectFocus(uint accessibilityObjectId);
void notifyValueChanged(uint accessibilityObjectId, jstring value);
diff --git a/src/plugins/platforms/android/qandroidplatformaccessibility.cpp b/src/plugins/platforms/android/qandroidplatformaccessibility.cpp
index 73f3a54e65..951ad83b9e 100644
--- a/src/plugins/platforms/android/qandroidplatformaccessibility.cpp
+++ b/src/plugins/platforms/android/qandroidplatformaccessibility.cpp
@@ -61,7 +61,7 @@ void QAndroidPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *
// so that the element can be moved on the screen if it's focused.
if (event->type() == QAccessible::LocationChanged) {
- QtAndroidAccessibility::notifyLocationChange();
+ QtAndroidAccessibility::notifyLocationChange(event->uniqueId());
} else if (event->type() == QAccessible::ObjectHide) {
QtAndroidAccessibility::notifyObjectHide(event->uniqueId());
} else if (event->type() == QAccessible::Focus) {