use of android.view.accessibility.AccessibilityEvent in project AndroidTraining by mixi-inc.
the class IcsAdapterView method onRequestSendAccessibilityEvent.
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (super.onRequestSendAccessibilityEvent(child, event)) {
// Add a record for ourselves as well.
AccessibilityEvent record = AccessibilityEvent.obtain();
onInitializeAccessibilityEvent(record);
// Populate with the text of the requesting child.
child.dispatchPopulateAccessibilityEvent(record);
event.appendRecord(record);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ParanoidAndroid.
the class NotificationArea method onRequestSendAccessibilityEvent.
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (super.onRequestSendAccessibilityEvent(child, event)) {
// The event is coming from a descendant like battery but append
// the content of the entire notification area so accessibility
// services can choose how to present the content to the user.
AccessibilityEvent record = AccessibilityEvent.obtain();
onInitializeAccessibilityEvent(record);
dispatchPopulateAccessibilityEvent(record);
event.appendRecord(record);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ParanoidAndroid.
the class TouchExplorer method sendAccessibilityEvent.
/**
* Sends an accessibility event of the given type.
*
* @param type The event type.
*/
private void sendAccessibilityEvent(int type) {
AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(mContext);
if (accessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(type);
accessibilityManager.sendAccessibilityEvent(event);
switch(type) {
case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START:
{
mTouchExplorationInProgress = true;
}
break;
case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END:
{
mTouchExplorationInProgress = false;
}
break;
}
}
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_OneDefault.
@LargeTest
public void testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_OneDefault() 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;
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_OWNER);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(firstService);
assertMockServiceVerifiedWithinTimeout(secondService);
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_OneService_MatchingPackageAndEventType.
@LargeTest
public void testSendAccessibilityEvent_OneService_MatchingPackageAndEventType() throws Exception {
// set the accessibility setting value
ensureAccessibilityEnabled(mContext, true);
// enable the mock accessibility service
ensureOnlyMockServicesEnabled(mContext, true, false);
// configure the mock service
MockAccessibilityService service = MyFirstMockAccessibilityService.sInstance;
service.setServiceInfo(MockAccessibilityService.createDefaultInfo());
// wait for the binder call 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
service.expectEvent(sentEvent);
service.replay();
// send the event
mManagerService.sendAccessibilityEvent(sentEvent, UserHandle.USER_OWNER);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(service);
}
Aggregations