diff options
| author | Phil Weaver <pweaver@google.com> | 2016-05-19 10:32:52 -0700 |
|---|---|---|
| committer | Phil Weaver <pweaver@google.com> | 2016-05-19 13:32:24 -0700 |
| commit | adaafb29801b939ab9a5ad348a338ecab4c03098 (patch) | |
| tree | 275a2f8b86581806f5d3b17ebd7ccf5962f318f7 /core/java/android/util/SparseArray.java | |
| parent | 29af3cab293dc7a19ca3b387c5507e521f66d0b7 (diff) | |
Fix a11y crash when window layer isn't unique.
TalkBack is seeing crashes that I can only explain by our assumption
that window layer is unique in all cases. TalkBack reports that it
happens during animation, so I assume that the layer may repeat
transiently.
Reducing our dependence on this assumption by traversing the list of
windows sorted by layer without assuming that the list has the same
length as the list of unsorted windows.
Also documenting the undefined behavior of SparseArray when indexing
beyond its bounds. The undefined behavior itself is intentional for
performance reasons.
Bug: 28679528
Bug: 28815817
Change-Id: I0c9f90b0b458b4cde465f603ba204fe6691e5c2c
Diffstat (limited to 'core/java/android/util/SparseArray.java')
| -rw-r--r-- | core/java/android/util/SparseArray.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java index dc965edd7fad..34e6f04f0404 100644 --- a/core/java/android/util/SparseArray.java +++ b/core/java/android/util/SparseArray.java @@ -160,6 +160,9 @@ public class SparseArray<E> implements Cloneable { /** * Removes the mapping at the specified index. + * + * <p>For indices outside of the range <code>0...size()-1</code>, + * the behavior is undefined.</p> */ public void removeAt(int index) { if (mValues[index] != DELETED) { @@ -173,6 +176,9 @@ public class SparseArray<E> implements Cloneable { * * @param index Index to begin at * @param size Number of mappings to remove + * + * <p>For indices outside of the range <code>0...size()-1</code>, + * the behavior is undefined.</p> */ public void removeAtRange(int index, int size) { final int end = Math.min(mSize, index + size); @@ -262,6 +268,9 @@ public class SparseArray<E> implements Cloneable { * be in ascending order, e.g., <code>keyAt(0)</code> will return the * smallest key and <code>keyAt(size()-1)</code> will return the largest * key.</p> + * + * <p>For indices outside of the range <code>0...size()-1</code>, + * the behavior is undefined.</p> */ public int keyAt(int index) { if (mGarbage) { @@ -281,6 +290,9 @@ public class SparseArray<E> implements Cloneable { * <code>valueAt(0)</code> will return the value associated with the * smallest key and <code>valueAt(size()-1)</code> will return the value * associated with the largest key.</p> + * + * <p>For indices outside of the range <code>0...size()-1</code>, + * the behavior is undefined.</p> */ @SuppressWarnings("unchecked") public E valueAt(int index) { @@ -295,6 +307,8 @@ public class SparseArray<E> implements Cloneable { * Given an index in the range <code>0...size()-1</code>, sets a new * value for the <code>index</code>th key-value mapping that this * SparseArray stores. + * + * <p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined.</p> */ public void setValueAt(int index, E value) { if (mGarbage) { |
