Search in sources :

Example 16 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Fairphone by Kwamecorp.

the class DragLayer method sendTapOutsideFolderAccessibilityEvent.

private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
        AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
        onInitializeAccessibilityEvent(event);
        event.getText().add(getContext().getString(stringId));
        accessibilityManager.sendAccessibilityEvent(event);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 17 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager 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 18 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerTest method testGetAccessibilityServiceList.

@MediumTest
public void testGetAccessibilityServiceList() throws Exception {
    // create a list of installed accessibility services the mock service returns
    List<AccessibilityServiceInfo> expectedServices = new ArrayList<AccessibilityServiceInfo>();
    AccessibilityServiceInfo accessibilityServiceInfo = new AccessibilityServiceInfo();
    accessibilityServiceInfo.packageNames = new String[] { "foo.bar" };
    expectedServices.add(accessibilityServiceInfo);
    // configure the mock service behavior
    IAccessibilityManager mockServiceInterface = mMockServiceInterface;
    expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
    expect(mockServiceInterface.getInstalledAccessibilityServiceList(UserHandle.USER_OWNER)).andReturn(expectedServices);
    replay(mockServiceInterface);
    // invoke the method under test
    AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
    List<AccessibilityServiceInfo> receivedServices = manager.getInstalledAccessibilityServiceList();
    // check expected result (list equals() compares it contents as well)
    assertEquals("All expected services must be returned", receivedServices, expectedServices);
    // verify the mock service was properly called
    verify(mockServiceInterface);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) ArrayList(java.util.ArrayList) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 19 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerTest method testIsEnabled.

@LargeTest
public void testIsEnabled() throws Exception {
    // configure the mock service behavior
    IAccessibilityManager mockServiceInterface = mMockServiceInterface;
    expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
    replay(mockServiceInterface);
    // invoke the method under test
    AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
    boolean isEnabledServiceEnabled = manager.isEnabled();
    // check expected result
    assertTrue("Must be enabled since the mock service is enabled", isEnabledServiceEnabled);
    // disable accessibility
    manager.getClient().setState(0);
    // wait for the asynchronous IBinder call to complete
    Thread.sleep(TIMEOUT_BINDER_CALL);
    // invoke the method under test
    boolean isEnabledServcieDisabled = manager.isEnabled();
    // check expected result
    assertFalse("Must be disabled since the mock service is disabled", isEnabledServcieDisabled);
    // verify the mock service was properly called
    verify(mockServiceInterface);
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 20 with AccessibilityManager

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

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)119 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)47 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)19 ArrayList (java.util.ArrayList)12 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6 UserInfo (android.content.pm.UserInfo)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 ParcelableString (com.android.internal.util.ParcelableString)6 SuppressLint (android.annotation.SuppressLint)5 ServiceInfo (android.content.pm.ServiceInfo)5 LargeTest (android.test.suitebuilder.annotation.LargeTest)5 Context (android.content.Context)4 AttachInfo (android.view.View.AttachInfo)4 IAccessibilityManagerClient (android.view.accessibility.IAccessibilityManagerClient)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 Paint (android.graphics.Paint)3