Skip to content

Commit a2b986e

Browse files
committed
Bug 5151927 - Monkeys should not play with detached lists.
Don't process ListView key events while detached from a window. Change-Id: Ibf85e081887d47834a467f9fd2cb6a1e39b4857e
1 parent 2873917 commit a2b986e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

core/java/android/widget/AbsListView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
635635
/**
636636
* Track if we are currently attached to a window.
637637
*/
638-
private boolean mIsAttached;
638+
boolean mIsAttached;
639639

640640
/**
641641
* Track the item count from the last time we handled a data change.

core/java/android/widget/ListView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
20742074
}
20752075

20762076
private boolean commonKey(int keyCode, int count, KeyEvent event) {
2077-
if (mAdapter == null) {
2077+
if (mAdapter == null || !mIsAttached) {
20782078
return false;
20792079
}
20802080

0 commit comments

Comments
 (0)