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

Commit e29b24b1 authored by alanv's avatar alanv Committed by The Android Automerger
Browse files

Check for null ViewRootImpl when saving accessibility focus in ListView.

Bug: 7135071
Change-Id: Ide8b6af38b7f1b9bb809e4f8b1c933cb5ddb5e86
parent 28764129
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewRootImpl;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.RemoteViews.RemoteView;
@@ -1590,23 +1591,28 @@ public class ListView extends AbsListView {
            }

            // Remember which child, if any, had accessibility focus.
            final View accessFocusedView = getViewRootImpl().getAccessibilityFocusedHost();
            final ViewRootImpl viewRootImpl = getViewRootImpl();
            if (viewRootImpl != null) {
                final View accessFocusedView = viewRootImpl.getAccessibilityFocusedHost();
                if (accessFocusedView != null) {
                final View accessFocusedChild = findAccessibilityFocusedChild(accessFocusedView);
                    final View accessFocusedChild = findAccessibilityFocusedChild(
                            accessFocusedView);
                    if (accessFocusedChild != null) {
                        if (!dataChanged || isDirectChildHeaderOrFooter(accessFocusedChild)) {
                        // If the views won't be changing, try to maintain focus
                        // on the current view host and (if applicable) its
                        // virtual view.
                            // If the views won't be changing, try to maintain
                            // focus on the current view host and (if
                            // applicable) its virtual view.
                            accessibilityFocusLayoutRestoreView = accessFocusedView;
                        accessibilityFocusLayoutRestoreNode = getViewRootImpl()
                            accessibilityFocusLayoutRestoreNode = viewRootImpl
                                    .getAccessibilityFocusedVirtualView();
                        } else {
                        // Otherwise, try to maintain focus at the same position.
                            // Otherwise, try to maintain focus at the same
                            // position.
                            accessibilityFocusPosition = getPositionForView(accessFocusedChild);
                        }
                    }
                }
            }

            // Clear out old views
            detachAllViewsFromParent();