Search in sources :

Example 36 with IAccessibilityInteractionConnectionCallback

use of android.view.accessibility.IAccessibilityInteractionConnectionCallback in project android_frameworks_base by crdroidandroid.

the class AccessibilityInteractionController method findFocusUiThread.

private void findFocusUiThread(Message message) {
    final int flags = message.arg1;
    final int focusType = message.arg2;
    SomeArgs args = (SomeArgs) message.obj;
    final int interactionId = args.argi1;
    final int accessibilityViewId = args.argi2;
    final int virtualDescendantId = args.argi3;
    final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) args.arg1;
    final MagnificationSpec spec = (MagnificationSpec) args.arg2;
    final Region interactiveRegion = (Region) args.arg3;
    args.recycle();
    AccessibilityNodeInfo focused = null;
    try {
        if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
            return;
        }
        mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = flags;
        View root = null;
        if (accessibilityViewId != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
            root = findViewByAccessibilityId(accessibilityViewId);
        } else {
            root = mViewRootImpl.mView;
        }
        if (root != null && isShown(root)) {
            switch(focusType) {
                case AccessibilityNodeInfo.FOCUS_ACCESSIBILITY:
                    {
                        View host = mViewRootImpl.mAccessibilityFocusedHost;
                        // of the root from which to start the search, then the search failed.
                        if (host == null || !ViewRootImpl.isViewDescendantOf(host, root)) {
                            break;
                        }
                        // The focused view not shown, we failed.
                        if (!isShown(host)) {
                            break;
                        }
                        // If the host has a provider ask this provider to search for the
                        // focus instead fetching all provider nodes to do the search here.
                        AccessibilityNodeProvider provider = host.getAccessibilityNodeProvider();
                        if (provider != null) {
                            if (mViewRootImpl.mAccessibilityFocusedVirtualView != null) {
                                focused = AccessibilityNodeInfo.obtain(mViewRootImpl.mAccessibilityFocusedVirtualView);
                            }
                        } else if (virtualDescendantId == AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
                            focused = host.createAccessibilityNodeInfo();
                        }
                    }
                    break;
                case AccessibilityNodeInfo.FOCUS_INPUT:
                    {
                        View target = root.findFocus();
                        if (target == null || !isShown(target)) {
                            break;
                        }
                        AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
                        if (provider != null) {
                            focused = provider.findFocus(focusType);
                        }
                        if (focused == null) {
                            focused = target.createAccessibilityNodeInfo();
                        }
                    }
                    break;
                default:
                    throw new IllegalArgumentException("Unknown focus type: " + focusType);
            }
        }
    } finally {
        try {
            mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
            applyAppScaleAndMagnificationSpecIfNeeded(focused, spec);
            // system process and obtained from a pool when read from parcel.
            if (spec != null && android.os.Process.myPid() != Binder.getCallingPid()) {
                spec.recycle();
            }
            adjustIsVisibleToUserIfNeeded(focused, interactiveRegion);
            callback.setFindAccessibilityNodeInfoResult(focused, interactionId);
        } catch (RemoteException re) {
        /* ignore - the other side will time out */
        }
        // the system process and instantiated  when read from parcel.
        if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) {
            interactiveRegion.recycle();
        }
    }
}
Also used : IAccessibilityInteractionConnectionCallback(android.view.accessibility.IAccessibilityInteractionConnectionCallback) SomeArgs(com.android.internal.os.SomeArgs) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Region(android.graphics.Region) RemoteException(android.os.RemoteException) AccessibilityNodeProvider(android.view.accessibility.AccessibilityNodeProvider) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)36 RemoteException (android.os.RemoteException)36 IAccessibilityInteractionConnectionCallback (android.view.accessibility.IAccessibilityInteractionConnectionCallback)36 SomeArgs (com.android.internal.os.SomeArgs)36 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)30 Region (android.graphics.Region)25 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)18 Bundle (android.os.Bundle)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 LinkedList (java.util.LinkedList)5