Search in sources :

Example 1 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.

the class Folder method sendCustomAccessibilityEvent.

private void sendCustomAccessibilityEvent(int type, String text) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(type);
        onInitializeAccessibilityEvent(event);
        event.getText().add(text);
        accessibilityManager.sendAccessibilityEvent(event);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 2 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.

the class Workspace method getPageIndicatorClickListener.

@Override
protected OnClickListener getPageIndicatorClickListener() {
    AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (!am.isTouchExplorationEnabled()) {
        return null;
    }
    OnClickListener listener = new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            enterOverviewMode();
        }
    };
    return listener;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) OnClickListener(android.view.View.OnClickListener) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView)

Example 3 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 4 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 5 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)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)170 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)54 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)49 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 ArrayList (java.util.ArrayList)26 ServiceInfo (android.content.pm.ServiceInfo)20 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 ComponentName (android.content.ComponentName)16 Drawable (android.graphics.drawable.Drawable)10 Bundle (android.os.Bundle)9 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)8 RestrictedPreference (com.android.settingslib.RestrictedPreference)8 SuppressLint (android.annotation.SuppressLint)7 Context (android.content.Context)7 SwitchPreference (android.support.v14.preference.SwitchPreference)7 ListPreference (android.support.v7.preference.ListPreference)7 Preference (android.support.v7.preference.Preference)7 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6