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);
}
use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_OneService_NotifivationAfterTimeout.
@LargeTest
public void testSendAccessibilityEvent_OneService_NotifivationAfterTimeout() 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;
AccessibilityServiceInfo info = MockAccessibilityService.createDefaultInfo();
info.notificationTimeout = TIMEOUT_TEST_NOTIFICATION_TIMEOUT;
service.setServiceInfo(info);
// wait for the binder call to #setService to complete
Thread.sleep(TIMEOUT_BINDER_CALL);
// create and populate the first event to be sent
AccessibilityEvent firstEvent = AccessibilityEvent.obtain();
fullyPopulateDefaultAccessibilityEvent(firstEvent);
// create and populate the second event to be sent
AccessibilityEvent secondEvent = AccessibilityEvent.obtain();
fullyPopulateDefaultAccessibilityEvent(secondEvent);
// set expectations
service.expectEvent(secondEvent);
service.replay();
// send the events
mManagerService.sendAccessibilityEvent(firstEvent, UserHandle.USER_OWNER);
mManagerService.sendAccessibilityEvent(secondEvent, UserHandle.USER_OWNER);
// wait for #sendAccessibilityEvent to reach the backing service
Thread.sleep(TIMEOUT_BINDER_CALL);
try {
service.verify();
fail("No events must be dispatched before the expiration of the notification timeout.");
} catch (IllegalStateException ise) {
/* expected */
}
// wait for the configured notification timeout to expire
Thread.sleep(TIMEOUT_TEST_NOTIFICATION_TIMEOUT);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(service);
}
Aggregations