Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77f18a96 authored by Qasid Sadiq's avatar Qasid Sadiq Committed by Android (Google) Code Review
Browse files

Merge "Make mIdsToViews thread safe."

parents a485f9a4 1aa9da42
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -45,16 +45,20 @@ public final class AccessibilityNodeIdManager {
     * @param id The accessibilityViewId of the view.
     */
    public void registerViewWithId(View view, int id) {
        synchronized (mIdsToViews) {
            mIdsToViews.append(id, view);
        }
    }

    /**
     * Unregister view, accessibility won't keep track of this view after this call.
     * @param id The id returned from registerView when the view as first associated.
     */
    public void unregisterViewWithId(int id) {
        synchronized (mIdsToViews) {
            mIdsToViews.remove(id);
        }
    }

    /**
     * Accessibility uses this to find the view in the hierarchy.
@@ -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;
    }
}