Skip to content

Commit 2d8b017

Browse files
committed
Fix bug 5339708 - edge case in ListView focus restoration
Some apps have managed to hit this edge case in monkey runs. In layoutChildren an attempt to findFocus() fails when items are focusable. When ListView attempts to restore focus to this view, bad things happen. Change-Id: Ie8bb1bab847898e342c16fbe3ff1a6153d6f69df
1 parent 6baed6c commit 2d8b017

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/java/android/widget/ListView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,7 @@ protected void layoutChildren() {
16511651
// are focusable
16521652
if (mItemsCanFocus && hasFocus() && !sel.hasFocus()) {
16531653
final boolean focusWasTaken = (sel == focusLayoutRestoreDirectChild &&
1654+
focusLayoutRestoreView != null &&
16541655
focusLayoutRestoreView.requestFocus()) || sel.requestFocus();
16551656
if (!focusWasTaken) {
16561657
// selected item didn't take focus, fine, but still want

0 commit comments

Comments
 (0)