Bug 699243 - Add method to GeckoAppShell to emit a11y events and bridge it [r=blassey]

This commit is contained in:
Eitan Isaacson 2011-11-04 09:56:24 -04:00
parent df967c87af
commit 7e098f7158
3 changed files with 31 additions and 0 deletions

View File

@ -64,6 +64,7 @@ import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient; import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.provider.Settings; import android.provider.Settings;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityEvent;
import android.util.*; import android.util.*;
import android.net.Uri; import android.net.Uri;
@ -1658,4 +1659,23 @@ public class GeckoAppShell
} }
}); });
} }
public static void emitGeckoAccessibilityEvent (int eventType, String role, String text, String description, boolean enabled, boolean checked, boolean password) {
AccessibilityManager accessibilityManager =
(AccessibilityManager) GeckoApp.mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (!accessibilityManager.isEnabled())
return;
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setClassName(GeckoApp.surfaceView.getClass().getName() + "$" + role);
event.setPackageName(GeckoApp.mAppContext.getPackageName());
event.setEnabled(enabled);
event.setChecked(checked);
event.setPassword(password);
event.setContentDescription(description);
event.getText().add(text);
accessibilityManager.sendAccessibilityEvent(event);
}
} }

View File

@ -1244,6 +1244,15 @@ AndroidBridge::GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInf
mJNIEnv->ReleaseFloatArrayElements(arr, info, 0); mJNIEnv->ReleaseFloatArrayElements(arr, info, 0);
} }
void AndroidBridge::EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsAString& role, const nsAString& text, const nsAString& description, bool enabled, bool checked, bool password) {
AutoLocalJNIFrame jniFrame;
jstring jstrRole = mJNIEnv->NewString(nsPromiseFlatString(role).get(), role.Length());
jstring jstrText = mJNIEnv->NewString(nsPromiseFlatString(text).get(), text.Length());
jstring jstrDescription = mJNIEnv->NewString(nsPromiseFlatString(description).get(), description.Length());
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEmitGeckoAccessibilityEvent, eventType, jstrRole, jstrText, jstrDescription, enabled, checked, password);
}
void * void *
AndroidBridge::LockBitmap(jobject bitmap) AndroidBridge::LockBitmap(jobject bitmap)
{ {

View File

@ -302,6 +302,8 @@ public:
void DisableBatteryNotifications(); void DisableBatteryNotifications();
void GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo); void GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo);
void EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsAString& role, const nsAString& text, const nsAString& description, bool enabled, bool checked, bool password);
protected: protected:
static AndroidBridge *sBridge; static AndroidBridge *sBridge;