Search in sources :

Example 1 with IAccessibilityManager

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

the class UiAutomationConnection method unregisterUiTestAutomationServiceLocked.

private void unregisterUiTestAutomationServiceLocked() {
    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
    try {
        // Calling out with a lock held is fine since if the system
        // process is gone the client calling in will be killed.
        manager.unregisterUiTestAutomationService(mClient);
        mClient = null;
    } catch (RemoteException re) {
        throw new IllegalStateException("Error while unregistering UiTestAutomationService", re);
    }
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) RemoteException(android.os.RemoteException)

Example 2 with IAccessibilityManager

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

the class UiAutomationConnection method registerUiTestAutomationServiceLocked.

private void registerUiTestAutomationServiceLocked(IAccessibilityServiceClient client) {
    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
    info.setCapabilities(AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
    try {
        // Calling out with a lock held is fine since if the system
        // process is gone the client calling in will be killed.
        manager.registerUiTestAutomationService(mToken, client, info);
        mClient = client;
    } catch (RemoteException re) {
        throw new IllegalStateException("Error while registering UiTestAutomationService.", re);
    }
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) RemoteException(android.os.RemoteException)

Example 3 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager 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 4 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager 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 5 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager in project platform_frameworks_base by android.

the class EnableAccessibilityController method enableAccessibility.

public static boolean enableAccessibility(Context context) {
    final IAccessibilityManager accessibilityManager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService("accessibility"));
    final WindowManagerInternal windowManager = LocalServices.getService(WindowManagerInternal.class);
    final UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    ComponentName componentName = getInstalledSpeakingAccessibilityServiceComponent(context);
    if (componentName == null) {
        return false;
    }
    boolean keyguardLocked = windowManager.isKeyguardLocked();
    final boolean hasMoreThanOneUser = userManager.getUsers().size() > 1;
    try {
        if (!keyguardLocked || !hasMoreThanOneUser) {
            final int userId = ActivityManager.getCurrentUser();
            accessibilityManager.enableAccessibilityService(componentName, userId);
        } else if (keyguardLocked) {
            accessibilityManager.temporaryEnableAccessibilityStateUntilKeyguardRemoved(componentName, true);
        }
    } catch (RemoteException e) {
        Log.e(TAG, "cannot enable accessibilty: " + e);
    }
    return true;
}
Also used : WindowManagerInternal(android.view.WindowManagerInternal) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Aggregations

IAccessibilityManager (android.view.accessibility.IAccessibilityManager)28 RemoteException (android.os.RemoteException)20 ComponentName (android.content.ComponentName)8 AccessibilityManager (android.view.accessibility.AccessibilityManager)8 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)7 UserManager (android.os.UserManager)4 MediumTest (android.test.suitebuilder.annotation.MediumTest)4 WindowManagerInternal (android.view.WindowManagerInternal)4 IBinder (android.os.IBinder)3 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)2 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 ArrayList (java.util.ArrayList)1