use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class EventsCommand method run.
@Override
public void run(String[] args) {
UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
automationWrapper.connect();
automationWrapper.getUiAutomation().setOnAccessibilityEventListener(new OnAccessibilityEventListener() {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
System.out.println(String.format("%s %s", formatter.format(new Date()), event.toString()));
}
});
// for user to press Ctrl+C
synchronized (mQuitLock) {
try {
mQuitLock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
automationWrapper.disconnect();
}
use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class KeyboardView method sendAccessibilityEventForUnicodeCharacter.
private void sendAccessibilityEventForUnicodeCharacter(int eventType, int code) {
if (mAccessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
onInitializeAccessibilityEvent(event);
String text = null;
// This is very efficient since the properties are cached.
final boolean speakPassword = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0, UserHandle.USER_CURRENT_OR_SELF) != 0;
// used to avoid leaking passwords.
if (speakPassword || mAudioManager.isBluetoothA2dpOn() || mAudioManager.isWiredHeadsetOn()) {
switch(code) {
case Keyboard.KEYCODE_ALT:
text = mContext.getString(R.string.keyboardview_keycode_alt);
break;
case Keyboard.KEYCODE_CANCEL:
text = mContext.getString(R.string.keyboardview_keycode_cancel);
break;
case Keyboard.KEYCODE_DELETE:
text = mContext.getString(R.string.keyboardview_keycode_delete);
break;
case Keyboard.KEYCODE_DONE:
text = mContext.getString(R.string.keyboardview_keycode_done);
break;
case Keyboard.KEYCODE_MODE_CHANGE:
text = mContext.getString(R.string.keyboardview_keycode_mode_change);
break;
case Keyboard.KEYCODE_SHIFT:
text = mContext.getString(R.string.keyboardview_keycode_shift);
break;
case '\n':
text = mContext.getString(R.string.keyboardview_keycode_enter);
break;
default:
text = String.valueOf((char) code);
}
} else if (!mHeadsetRequiredToHearPasswordsAnnounced) {
// hover enter and hover exit event, so set the flag after the exit.
if (eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
mHeadsetRequiredToHearPasswordsAnnounced = true;
}
text = mContext.getString(R.string.keyboard_headset_required_to_hear_password);
} else {
text = mContext.getString(R.string.keyboard_password_character_no_headset);
}
event.getText().add(text);
mAccessibilityManager.sendAccessibilityEvent(event);
}
}
use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class PasswordTextView method sendAccessibilityEventTypeViewTextChanged.
void sendAccessibilityEventTypeViewTextChanged(String beforeText, int fromIndex, int removedCount, int addedCount) {
if (AccessibilityManager.getInstance(mContext).isEnabled() && (isFocused() || isSelected() && isShown())) {
if (!shouldSpeakPasswordsForAccessibility()) {
beforeText = null;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
event.setFromIndex(fromIndex);
event.setRemovedCount(removedCount);
event.setAddedCount(addedCount);
event.setBeforeText(beforeText);
event.setPassword(true);
sendAccessibilityEventUnchecked(event);
}
}
use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class PhoneStatusBarView method onRequestSendAccessibilityEventInternal.
@Override
public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
if (super.onRequestSendAccessibilityEventInternal(child, event)) {
// The status bar is very small so augment the view that the user is touching
// with the content of the status bar a whole. This way an accessibility service
// may announce the current item as well as the entire content if appropriate.
AccessibilityEvent record = AccessibilityEvent.obtain();
onInitializeAccessibilityEvent(record);
dispatchPopulateAccessibilityEvent(record);
event.appendRecord(record);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class MockAccessibilityService method onAccessibilityEvent.
@Override
public void onAccessibilityEvent(AccessibilityEvent receivedEvent) {
if (!mReplaying) {
return;
}
if (mExpectedEvents.isEmpty()) {
throw new IllegalStateException("Unexpected event: " + receivedEvent);
}
AccessibilityEvent expectedEvent = mExpectedEvents.poll();
assertEqualsAccessiblityEvent(expectedEvent, receivedEvent);
}
Aggregations