@@ -91,7 +91,8 @@ public final class AccessibilityInteractionClient
9191
9292 private final Rect mTempBounds = new Rect ();
9393
94- private final SparseArray <IAccessibilityServiceConnection > mConnectionCache =
94+ // The connection cache is shared between all interrogating threads.
95+ private static final SparseArray <IAccessibilityServiceConnection > sConnectionCache =
9596 new SparseArray <IAccessibilityServiceConnection >();
9697
9798 /**
@@ -517,8 +518,8 @@ private Message getSameProcessMessageAndClear() {
517518 * @return The cached connection if such.
518519 */
519520 public IAccessibilityServiceConnection getConnection (int connectionId ) {
520- synchronized (mConnectionCache ) {
521- return mConnectionCache .get (connectionId );
521+ synchronized (sConnectionCache ) {
522+ return sConnectionCache .get (connectionId );
522523 }
523524 }
524525
@@ -529,8 +530,8 @@ public IAccessibilityServiceConnection getConnection(int connectionId) {
529530 * @param connection The connection.
530531 */
531532 public void addConnection (int connectionId , IAccessibilityServiceConnection connection ) {
532- synchronized (mConnectionCache ) {
533- mConnectionCache .put (connectionId , connection );
533+ synchronized (sConnectionCache ) {
534+ sConnectionCache .put (connectionId , connection );
534535 }
535536 }
536537
@@ -540,8 +541,8 @@ public void addConnection(int connectionId, IAccessibilityServiceConnection conn
540541 * @param connectionId The connection id.
541542 */
542543 public void removeConnection (int connectionId ) {
543- synchronized (mConnectionCache ) {
544- mConnectionCache .remove (connectionId );
544+ synchronized (sConnectionCache ) {
545+ sConnectionCache .remove (connectionId );
545546 }
546547 }
547548}
0 commit comments