diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 59b0eef990e..ae783cc6f32 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -1871,7 +1871,7 @@ public class GeckoAppShell return false; } - public static void emitGeckoAccessibilityEvent (int eventType, String role, String text, String description, boolean enabled, boolean checked, boolean password) { + public static void emitGeckoAccessibilityEvent (int eventType, String[] textList, String description, boolean enabled, boolean checked, boolean password) { AccessibilityManager accessibilityManager = (AccessibilityManager) GeckoApp.mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE); @@ -1882,13 +1882,14 @@ public class GeckoAppShell LayerView layerView = layerController.getView(); AccessibilityEvent event = AccessibilityEvent.obtain(eventType); - event.setClassName(layerView.getClass().getName() + "$" + role); + event.setClassName(layerView.getClass().getName()); event.setPackageName(GeckoApp.mAppContext.getPackageName()); event.setEnabled(enabled); event.setChecked(checked); event.setPassword(password); event.setContentDescription(description); - event.getText().add(text); + for (String text: textList) + event.getText().add(text); accessibilityManager.sendAccessibilityEvent(event); } diff --git a/widget/android/AndroidBridge.cpp b/widget/android/AndroidBridge.cpp index 85860800f5c..b17deb1b8f8 100644 --- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -178,6 +178,7 @@ AndroidBridge::Init(JNIEnv *jEnv, jGetCurrentNetworkInformation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getCurrentNetworkInformation", "()[D"); jEnableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableNetworkNotifications", "()V"); jDisableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableNetworkNotifications", "()V"); + jEmitGeckoAccessibilityEvent = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "emitGeckoAccessibilityEvent", "(I[Ljava/lang/String;Ljava/lang/String;ZZZ)V"); jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext")); jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10")); @@ -186,6 +187,8 @@ AndroidBridge::Init(JNIEnv *jEnv, jEGLConfigImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLConfigImpl")); jEGLDisplayImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLDisplayImpl")); + jStringClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("java/lang/String")); + InitAndroidJavaWrappers(jEnv); // jEnv should NOT be cached here by anything -- the jEnv here @@ -1487,17 +1490,17 @@ AndroidBridge::MarkURIVisited(const nsAString& aURI) env->CallStaticVoidMethod(mGeckoAppShellClass, jMarkUriVisited, jstrURI); } -void AndroidBridge::EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsAString& role, const nsAString& text, const nsAString& description, bool enabled, bool checked, bool password) { - - JNIEnv *env = GetJNIEnv(); - if (!env) - return; - - AutoLocalJNIFrame jniFrame(env); - jstring jstrRole = env->NewString(nsPromiseFlatString(role).get(), role.Length()); - jstring jstrText = env->NewString(nsPromiseFlatString(text).get(), text.Length()); - jstring jstrDescription = env->NewString(nsPromiseFlatString(description).get(), description.Length()); - env->CallStaticVoidMethod(mGeckoAppShellClass, jEmitGeckoAccessibilityEvent, eventType, jstrRole, jstrText, jstrDescription, enabled, checked, password); +void AndroidBridge::EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsTArray& text, const nsAString& description, bool enabled, bool checked, bool password) { + AutoLocalJNIFrame jniFrame; + jobjectArray jarrayText = mJNIEnv->NewObjectArray(text.Length(), + jStringClass, 0); + for (PRUint32 i = 0; i < text.Length() ; i++) { + jstring jstrText = mJNIEnv->NewString(nsPromiseFlatString(text[i]).get(), + text[i].Length()); + mJNIEnv->SetObjectArrayElement(jarrayText, i, jstrText); + } + jstring jstrDescription = mJNIEnv->NewString(nsPromiseFlatString(description).get(), description.Length()); + mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEmitGeckoAccessibilityEvent, eventType, jarrayText, jstrDescription, enabled, checked, password); } PRUint16 @@ -1584,8 +1587,8 @@ AndroidBridge::CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aR jobjectArray numbers = (jobjectArray)env->NewObjectArray(aFilter.numbers().Length(), - env->FindClass("java/lang/String"), - env->NewStringUTF("")); + jStringClass, + env->NewStringUTF("")); for (PRUint32 i = 0; i < aFilter.numbers().Length(); ++i) { env->SetObjectArrayElement(numbers, i, diff --git a/widget/android/AndroidBridge.h b/widget/android/AndroidBridge.h index 84e2de05561..c9ee11a0f8e 100644 --- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -357,7 +357,7 @@ public: nsCOMPtr GetDrawMetadataProvider(); - void EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsAString& role, const nsAString& text, const nsAString& description, bool enabled, bool checked, bool password); + void EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsTArray& text, const nsAString& description, bool enabled, bool checked, bool password); void CheckURIVisited(const nsAString& uri); void MarkURIVisited(const nsAString& uri); @@ -498,6 +498,9 @@ protected: jclass jEGLContextClass; jclass jEGL10Class; + // some convinient types to have around + jclass jStringClass; + // calls we've dlopened from libjnigraphics.so int (* AndroidBitmap_getInfo)(JNIEnv *env, jobject bitmap, void *info); int (* AndroidBitmap_lockPixels)(JNIEnv *env, jobject bitmap, void **buffer);