Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0dcb9e81 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Save and restore accessibility focus using decor view"

parents f1ab38c8 4cbd3ac7
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -2028,7 +2028,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        }

        // Save the accessibility focused view ID.
        final ViewRootImpl viewRootImpl = mContentParent.getViewRootImpl();
        if (mDecor != null) {
            final ViewRootImpl viewRootImpl = mDecor.getViewRootImpl();
            if (viewRootImpl != null) {
                final View accessFocusHost = viewRootImpl.getAccessibilityFocusedHost();
                if (accessFocusHost != null && accessFocusHost.getId() != View.NO_ID) {
                    outState.putInt(ACCESSIBILITY_FOCUSED_ID_TAG, accessFocusHost.getId());
@@ -2042,6 +2044,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                        outState.putInt(ACCESSIBILITY_FOCUSED_VIRTUAL_ID_TAG, virtualNodeId);
                    }
                }
            }
        }

        // save the panels
        SparseArray<Parcelable> panelStates = new SparseArray<Parcelable>();
@@ -2112,8 +2116,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    }

    private void tryRestoreAccessibilityFocus(int hostViewId, int virtualViewId) {
        if (hostViewId != View.NO_ID) {
            final View needsAccessFocus = mContentParent.findViewById(hostViewId);
        if (hostViewId != View.NO_ID && mDecor != null) {
            final View needsAccessFocus = mDecor.findViewById(hostViewId);
            if (needsAccessFocus != null) {
                if (!tryFocusingVirtualView(needsAccessFocus, virtualViewId)
                        && !needsAccessFocus.requestAccessibilityFocus()) {