use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_TwoDefault.
@LargeTest
public void testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_TwoDefault() throws Exception {
// set the accessibility setting value
ensureAccessibilityEnabled(mContext, true);
// enable the mock accessibility services
ensureOnlyMockServicesEnabled(mContext, true, true);
// configure the first mock service
MockAccessibilityService firstService = MyFirstMockAccessibilityService.sInstance;
AccessibilityServiceInfo firstInfo = MyFirstMockAccessibilityService.createDefaultInfo();
firstInfo.flags = AccessibilityServiceInfo.DEFAULT;
firstService.setServiceInfo(firstInfo);
// configure the second mock service
MockAccessibilityService secondService = MySecondMockAccessibilityService.sInstance;
AccessibilityServiceInfo secondInfo = MyFirstMockAccessibilityService.createDefaultInfo();
secondInfo.flags = AccessibilityServiceInfo.DEFAULT;
secondService.setServiceInfo(firstInfo);
// wait for the binder calls to #setService to complete
Thread.sleep(TIMEOUT_BINDER_CALL);
// create and populate an event to be sent
AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
fullyPopulateDefaultAccessibilityEvent(sentEvent);
// set expectations for the first mock service
firstService.expectEvent(sentEvent);
firstService.replay();
// set expectations for the second mock service
secondService.replay();
// send the event
mManagerService.sendAccessibilityEvent(sentEvent, UserHandle.USER_OWNER);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(firstService);
assertMockServiceVerifiedWithinTimeout(secondService);
}
use of android.view.accessibility.AccessibilityEvent in project HoloEverywhere by Prototik.
the class SwitchScreenPreference method sendAccessibilityEvent.
@SuppressLint("NewApi")
void sendAccessibilityEvent(View view) {
try {
AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (mSendClickAccessibilityEvent && accessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain();
event.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED);
if (VERSION.SDK_INT >= 14) {
view.onInitializeAccessibilityEvent(event);
}
view.dispatchPopulateAccessibilityEvent(event);
accessibilityManager.sendAccessibilityEvent(event);
}
} catch (Exception e) {
}
mSendClickAccessibilityEvent = false;
}
use of android.view.accessibility.AccessibilityEvent in project HoloEverywhere by Prototik.
the class AdapterView method onRequestSendAccessibilityEvent.
@SuppressLint("NewApi")
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (super.onRequestSendAccessibilityEvent(child, event)) {
AccessibilityEvent record = AccessibilityEvent.obtain();
onInitializeAccessibilityEvent(record);
child.dispatchPopulateAccessibilityEvent(record);
event.appendRecord(record);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityEvent in project HoloEverywhere by Prototik.
the class TouchExplorationHelper method getEventForItem.
private AccessibilityEvent getEventForItem(T item, int eventType) {
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
final int virtualDescendantId = getIdForItem(item);
// Ensure the client has good defaults.
event.setEnabled(true);
// Allow the client to populate the event.
populateEventForItem(item, event);
if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) {
throw new RuntimeException("You must add text or a content description in populateEventForItem()");
}
// Don't allow the client to override these properties.
event.setClassName(item.getClass().getName());
event.setPackageName(mParentView.getContext().getPackageName());
record.setSource(mParentView, virtualDescendantId);
return event;
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ParanoidAndroid.
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.getInt(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 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);
}
}
Aggregations