Search in sources :

Example 36 with AccessibilityManager

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

the class AccessibilityManagerTest method createManager.

private AccessibilityManager createManager(boolean enabled) throws Exception {
    if (enabled) {
        when(mMockService.addClient(any(IAccessibilityManagerClient.class), anyInt())).thenReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
    } else {
        when(mMockService.addClient(any(IAccessibilityManagerClient.class), anyInt())).thenReturn(0);
    }
    AccessibilityManager manager = new AccessibilityManager(mContext, mMockService, UserHandle.USER_CURRENT);
    verify(mMockService).addClient(any(IAccessibilityManagerClient.class), anyInt());
    return manager;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) IAccessibilityManagerClient(android.view.accessibility.IAccessibilityManagerClient)

Example 37 with AccessibilityManager

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

the class AccessibilityManagerTest method testIsEnabled.

@LargeTest
public void testIsEnabled() throws Exception {
    // invoke the method under test
    AccessibilityManager manager = createManager(true);
    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);
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 38 with AccessibilityManager

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

the class AccessibilityManagerTest method testSendAccessibilityEvent_AccessibilityEnabled.

@MediumTest
public void testSendAccessibilityEvent_AccessibilityEnabled() throws Exception {
    AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
    when(mMockService.sendAccessibilityEvent(eq(sentEvent), anyInt())).thenReturn(true).thenReturn(false);
    AccessibilityManager manager = createManager(true);
    manager.sendAccessibilityEvent(sentEvent);
    assertSame("The event should be recycled.", sentEvent, AccessibilityEvent.obtain());
    manager.sendAccessibilityEvent(sentEvent);
    assertNotSame("The event should not be recycled.", sentEvent, AccessibilityEvent.obtain());
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 39 with AccessibilityManager

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

the class AccessibilityManagerTest method testInterrupt.

@MediumTest
public void testInterrupt() throws Exception {
    AccessibilityManager manager = createManager(true);
    manager.interrupt();
    verify(mMockService).interrupt(UserHandle.USER_CURRENT);
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 40 with AccessibilityManager

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

the class NotificationManagerService method sendAccessibilityEvent.

void sendAccessibilityEvent(Notification notification, CharSequence packageName) {
    AccessibilityManager manager = AccessibilityManager.getInstance(getContext());
    if (!manager.isEnabled()) {
        return;
    }
    AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
    event.setPackageName(packageName);
    event.setClassName(Notification.class.getName());
    event.setParcelableData(notification);
    CharSequence tickerText = notification.tickerText;
    if (!TextUtils.isEmpty(tickerText)) {
        event.getText().add(tickerText);
    }
    try {
        manager.sendAccessibilityEvent(event);
    } catch (IllegalStateException e) {
        Slog.e(TAG, "sendAccessibilityEvent failed.", e);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) ITransientNotification(android.app.ITransientNotification) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

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