Search in sources :

Example 1 with AccessibilityEvent

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;
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 2 with AccessibilityEvent

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;
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 3 with AccessibilityEvent

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;
        }
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 4 with AccessibilityEvent

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);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 5 with AccessibilityEvent

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);
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

AccessibilityEvent (android.view.accessibility.AccessibilityEvent)241 AccessibilityManager (android.view.accessibility.AccessibilityManager)49 LargeTest (android.test.suitebuilder.annotation.LargeTest)40 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)20 ViewParent (android.view.ViewParent)13 TimeoutException (java.util.concurrent.TimeoutException)11 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)10 Notification (android.app.Notification)7 ITransientNotification (android.app.ITransientNotification)6 Context (android.content.Context)6 RemoteException (android.os.RemoteException)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 AccessibilityRecordCompat (android.support.v4.view.accessibility.AccessibilityRecordCompat)6 ViewGroup (android.view.ViewGroup)6 Test (org.junit.Test)6 SuppressLint (android.annotation.SuppressLint)5 AccessibilityEventFilter (android.app.UiAutomation.AccessibilityEventFilter)5 OnAccessibilityEventListener (android.app.UiAutomation.OnAccessibilityEventListener)5 UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)5