diff options
author | Alan Viverette <alanv@google.com> | 2014-02-24 11:09:18 -0800 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-02-24 11:09:18 -0800 |
commit | 2e6fc8ca5696367a680656f73c1b9b95648eb6fa (patch) | |
tree | e6f456f8f9f14a9c71a8e6db01e67ac6dd9a9789 /core/java | |
parent | 12b97f5d2b15194ed6673c9838b13c8312157709 (diff) | |
download | frameworks_base-2e6fc8ca5696367a680656f73c1b9b95648eb6fa.zip frameworks_base-2e6fc8ca5696367a680656f73c1b9b95648eb6fa.tar.gz frameworks_base-2e6fc8ca5696367a680656f73c1b9b95648eb6fa.tar.bz2 |
Check for null view root before checking for accessibility focus
BUG: 13168971
Change-Id: Ia75d77b18112371f56a624e11f9509f14ec98093
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/widget/GridView.java | 45 | ||||
-rw-r--r-- | core/java/android/widget/ListView.java | 45 |
2 files changed, 48 insertions, 42 deletions
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 4ed48ff..04b18c1 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -1335,27 +1335,30 @@ public class GridView extends AbsListView { } // Attempt to restore accessibility focus, if necessary. - final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); - if (newAccessibilityFocusedView == null) { - if (accessibilityFocusLayoutRestoreView != null - && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { - final AccessibilityNodeProvider provider = - accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); - if (accessibilityFocusLayoutRestoreNode != null && provider != null) { - final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( - accessibilityFocusLayoutRestoreNode.getSourceNodeId()); - provider.performAction(virtualViewId, - AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); - } else { - accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); - } - } else if (accessibilityFocusPosition != INVALID_POSITION) { - // Bound the position within the visible children. - final int position = MathUtils.constrain( - accessibilityFocusPosition - mFirstPosition, 0, getChildCount() - 1); - final View restoreView = getChildAt(position); - if (restoreView != null) { - restoreView.requestAccessibilityFocus(); + if (viewRootImpl != null) { + final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); + if (newAccessibilityFocusedView == null) { + if (accessibilityFocusLayoutRestoreView != null + && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { + final AccessibilityNodeProvider provider = + accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); + if (accessibilityFocusLayoutRestoreNode != null && provider != null) { + final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( + accessibilityFocusLayoutRestoreNode.getSourceNodeId()); + provider.performAction(virtualViewId, + AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); + } else { + accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); + } + } else if (accessibilityFocusPosition != INVALID_POSITION) { + // Bound the position within the visible children. + final int position = MathUtils.constrain( + accessibilityFocusPosition - mFirstPosition, 0, + getChildCount() - 1); + final View restoreView = getChildAt(position); + if (restoreView != null) { + restoreView.requestAccessibilityFocus(); + } } } } diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 63e1358..5de67c8 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -1738,27 +1738,30 @@ public class ListView extends AbsListView { } // Attempt to restore accessibility focus, if necessary. - final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); - if (newAccessibilityFocusedView == null) { - if (accessibilityFocusLayoutRestoreView != null - && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { - final AccessibilityNodeProvider provider = - accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); - if (accessibilityFocusLayoutRestoreNode != null && provider != null) { - final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( - accessibilityFocusLayoutRestoreNode.getSourceNodeId()); - provider.performAction(virtualViewId, - AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); - } else { - accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); - } - } else if (accessibilityFocusPosition != INVALID_POSITION) { - // Bound the position within the visible children. - final int position = MathUtils.constrain( - accessibilityFocusPosition - mFirstPosition, 0, getChildCount() - 1); - final View restoreView = getChildAt(position); - if (restoreView != null) { - restoreView.requestAccessibilityFocus(); + if (viewRootImpl != null) { + final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); + if (newAccessibilityFocusedView == null) { + if (accessibilityFocusLayoutRestoreView != null + && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { + final AccessibilityNodeProvider provider = + accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); + if (accessibilityFocusLayoutRestoreNode != null && provider != null) { + final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( + accessibilityFocusLayoutRestoreNode.getSourceNodeId()); + provider.performAction(virtualViewId, + AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); + } else { + accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); + } + } else if (accessibilityFocusPosition != INVALID_POSITION) { + // Bound the position within the visible children. + final int position = MathUtils.constrain( + accessibilityFocusPosition - mFirstPosition, 0, + getChildCount() - 1); + final View restoreView = getChildAt(position); + if (restoreView != null) { + restoreView.requestAccessibilityFocus(); + } } } } |