summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2013-11-25 17:45:00 -0800
committerSvetoslav <svetoslavganov@google.com>2013-12-13 10:45:03 -0800
commitf8bc964289df5ea53672df401c6d51dd47c02e53 (patch)
treebdccd8918a5bab56ed4a287bf22e5c2dafada537
parenteb3a0fadfee8a0f031cabbdab175c8d1575375dc (diff)
downloadframeworks_base-f8bc964289df5ea53672df401c6d51dd47c02e53.zip
frameworks_base-f8bc964289df5ea53672df401c6d51dd47c02e53.tar.gz
frameworks_base-f8bc964289df5ea53672df401c6d51dd47c02e53.tar.bz2
Fixing some accessibility bugs.
1. Views not important for accessibility should not send events. 2. The base View implementation should not add it self to the list of children for accessibility. 3. Null pointer exception in AccessibilityNodeInfoCache. Change-Id: Ie5b373362269200ead13ffe632679bd42ee40309
-rw-r--r--core/java/android/view/View.java10
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfoCache.java12
2 files changed, 11 insertions, 11 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index a693ed4..0439b50 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5022,7 +5022,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @param text The announcement text.
*/
public void announceForAccessibility(CharSequence text) {
- if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null
+ && isImportantForAccessibility()) {
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_ANNOUNCEMENT);
onInitializeAccessibilityEvent(event);
@@ -5072,7 +5073,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* Note: Called from the default {@link AccessibilityDelegate}.
*/
void sendAccessibilityEventUncheckedInternal(AccessibilityEvent event) {
- if (!isShown()) {
+ if (!isShown() || !isImportantForAccessibility()) {
return;
}
onInitializeAccessibilityEvent(event);
@@ -7372,9 +7373,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @param children The list of children for accessibility.
*/
public void addChildrenForAccessibility(ArrayList<View> children) {
- if (includeForAccessibility()) {
- children.add(this);
- }
+
}
/**
@@ -7388,7 +7387,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @hide
*/
public boolean includeForAccessibility() {
- //noinspection SimplifiableIfStatement
if (mAttachInfo != null) {
return (mAttachInfo.mAccessibilityFetchFlags
& AccessibilityNodeInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java b/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java
index 3f79b47..97db84b 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java
@@ -174,11 +174,13 @@ public class AccessibilityNodeInfoCache {
// subtrees in the cache.
// TODO: Runs in O(n^2), could optimize to O(n + n log n)
final LongArray newChildrenIds = info.getChildNodeIds();
- final int oldChildCount = oldInfo.getChildCount();
- for (int i = 0; i < oldChildCount; i++) {
- final long oldChildId = oldInfo.getChildId(i);
- if (newChildrenIds.indexOf(oldChildId) < 0) {
- clearSubTreeLocked(oldChildId);
+ if (newChildrenIds != null) {
+ final int oldChildCount = oldInfo.getChildCount();
+ for (int i = 0; i < oldChildCount; i++) {
+ final long oldChildId = oldInfo.getChildId(i);
+ if (newChildrenIds.indexOf(oldChildId) < 0) {
+ clearSubTreeLocked(oldChildId);
+ }
}
}