@@ -93,7 +93,8 @@ public final class AccessibilityInteractionClient
9393
9494 private final Rect mTempBounds = new Rect ();
9595
96- private final SparseArray <IAccessibilityServiceConnection > mConnectionCache =
96+ // The connection cache is shared between all interrogating threads.
97+ private static final SparseArray <IAccessibilityServiceConnection > sConnectionCache =
9798 new SparseArray <IAccessibilityServiceConnection >();
9899
99100 /**
@@ -539,8 +540,8 @@ private Message getSameProcessMessageAndClear() {
539540 * @return The cached connection if such.
540541 */
541542 public IAccessibilityServiceConnection getConnection (int connectionId ) {
542- synchronized (mConnectionCache ) {
543- return mConnectionCache .get (connectionId );
543+ synchronized (sConnectionCache ) {
544+ return sConnectionCache .get (connectionId );
544545 }
545546 }
546547
@@ -551,8 +552,8 @@ public IAccessibilityServiceConnection getConnection(int connectionId) {
551552 * @param connection The connection.
552553 */
553554 public void addConnection (int connectionId , IAccessibilityServiceConnection connection ) {
554- synchronized (mConnectionCache ) {
555- mConnectionCache .put (connectionId , connection );
555+ synchronized (sConnectionCache ) {
556+ sConnectionCache .put (connectionId , connection );
556557 }
557558 }
558559
@@ -562,8 +563,8 @@ public void addConnection(int connectionId, IAccessibilityServiceConnection conn
562563 * @param connectionId The connection id.
563564 */
564565 public void removeConnection (int connectionId ) {
565- synchronized (mConnectionCache ) {
566- mConnectionCache .remove (connectionId );
566+ synchronized (sConnectionCache ) {
567+ sConnectionCache .remove (connectionId );
567568 }
568569 }
569570}
0 commit comments