use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by crdroidandroid.
the class VolumeDialog method dismissH.
protected void dismissH(int reason) {
if (mMotion.isAnimating()) {
return;
}
mHandler.removeMessages(H.DISMISS);
mHandler.removeMessages(H.SHOW);
if (!mShowing)
return;
mShowing = false;
mMotion.startDismiss(new Runnable() {
@Override
public void run() {
updateExpandedH(false, /* expanding */
true);
}
});
if (mAccessibilityMgr.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
event.setPackageName(mContext.getPackageName());
event.setClassName(CustomDialog.class.getSuperclass().getName());
event.getText().add(mContext.getString(R.string.volume_dialog_accessibility_dismissed_message));
mAccessibilityMgr.sendAccessibilityEvent(event);
}
Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason);
mController.notifyVisible(false);
synchronized (mSafetyWarningLock) {
if (mSafetyWarning != null) {
if (D.BUG)
Log.d(TAG, "SafetyWarning dismissed");
mSafetyWarning.dismiss();
}
}
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by crdroidandroid.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_OneDefault.
@LargeTest
public void testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_OneDefault() throws Exception {
// enable the mock accessibility services
ensureOnlyMockServicesEnabled(mContext, true, true);
// set the accessibility setting value
ensureAccessibilityEnabled(mContext, 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;
secondService.setServiceInfo(MySecondMockAccessibilityService.createDefaultInfo());
// 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.replay();
// set expectations for the second mock service
secondService.expectEvent(sentEvent);
secondService.replay();
// send the event
mManagerService.sendAccessibilityEvent(sentEvent, UserHandle.USER_CURRENT);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(firstService);
assertMockServiceVerifiedWithinTimeout(secondService);
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by crdroidandroid.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType.
@LargeTest
public void testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType() throws Exception {
// enable the mock accessibility services
ensureOnlyMockServicesEnabled(mContext, true, true);
// set the accessibility setting value
ensureAccessibilityEnabled(mContext, true);
// configure the first mock service
MockAccessibilityService firstService = MyFirstMockAccessibilityService.sInstance;
firstService.setServiceInfo(MockAccessibilityService.createDefaultInfo());
// configure the second mock service
MockAccessibilityService secondService = MySecondMockAccessibilityService.sInstance;
secondService.setServiceInfo(MockAccessibilityService.createDefaultInfo());
// 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_CURRENT);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(firstService);
assertMockServiceVerifiedWithinTimeout(secondService);
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by AOSPA.
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 android_frameworks_base by AOSPA.
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);
}
}
Aggregations