summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Qasid Ahmad Sadiq <qasid@google.com> 2019-02-27 18:26:34 -0800
committer Qasid Ahmad Sadiq <qasid@google.com> 2019-02-27 18:26:34 -0800
commit1aa9da4250326da33e9666aa685ef747ff6ee40a (patch)
tree206b3f1b305ecbba140096e1b77634c5f7970910
parent763ca762a1ac42b0dcf07c62d68b681af4fd9399 (diff)
Make mIdsToViews thread safe.
View calls like "attachedToWindow" and "detachedToWindow" can be called off of the main thread, on "android.anim" this happens in the system process for application splash screens. Let's wrap it with a synchronized block. Fix: 124110476 Test: The crash is a race condition, so the best I can do is make sure it generally doesn't crash anything by trying out both normal and virtual hierarchies in Talkback. Change-Id: I19f972a97b5ac80917f8dd77ac79bf7e3d5e826c
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeIdManager.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityNodeIdManager.java b/core/java/android/view/accessibility/AccessibilityNodeIdManager.java
index 1ac704774e7f..0f5e950582dd 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeIdManager.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeIdManager.java
@@ -45,7 +45,9 @@ public final class AccessibilityNodeIdManager {
* @param id The accessibilityViewId of the view.
*/
public void registerViewWithId(View view, int id) {
- mIdsToViews.append(id, view);
+ synchronized (mIdsToViews) {
+ mIdsToViews.append(id, view);
+ }
}
/**
@@ -53,7 +55,9 @@ public final class AccessibilityNodeIdManager {
* @param id The id returned from registerView when the view as first associated.
*/
public void unregisterViewWithId(int id) {
- mIdsToViews.remove(id);
+ synchronized (mIdsToViews) {
+ mIdsToViews.remove(id);
+ }
}
/**
@@ -62,7 +66,10 @@ public final class AccessibilityNodeIdManager {
* @return The view.
*/
public View findView(int id) {
- final View view = mIdsToViews.get(id);
+ View view = null;
+ synchronized (mIdsToViews) {
+ view = mIdsToViews.get(id);
+ }
return view != null && view.includeForAccessibility() ? view : null;
}
}