aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorellen,yang <ellen.yang@unisoc.com>2023-08-29 09:35:15 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-08-29 09:35:15 +0000
commit18fc849bf343084e82c7c08f9f9c76201a137e0a (patch)
treecdfdec510b7b431b4dccfafe6461a844a58577b9
parent5bb65457150a78269702a09c8ed639da333ae2b5 (diff)
parent6149d266910d96ec0395bdb12038baa80dfe3a3d (diff)
downloadconnectedappssdk-18fc849bf343084e82c7c08f9f9c76201a137e0a.tar.gz
modify the concurrentmodificationexception in the senfers in CrossprofileSenders.java am: 6149d26691
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/connectedappssdk/+/24537586 Change-Id: Ie3cb84447905913a6b2d200eec537a9a6f5583eb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--sdk/src/main/java/com/google/android/enterprise/connectedapps/CrossProfileSender.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/sdk/src/main/java/com/google/android/enterprise/connectedapps/CrossProfileSender.java b/sdk/src/main/java/com/google/android/enterprise/connectedapps/CrossProfileSender.java
index 0432696..91aaadc 100644
--- a/sdk/src/main/java/com/google/android/enterprise/connectedapps/CrossProfileSender.java
+++ b/sdk/src/main/java/com/google/android/enterprise/connectedapps/CrossProfileSender.java
@@ -49,11 +49,13 @@ import com.google.android.enterprise.connectedapps.internal.CrossProfileBundleCa
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.WeakHashMap;
+import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.CountDownLatch;
@@ -283,13 +285,15 @@ public final class CrossProfileSender {
// This is synchronized which isn't massively performant but it only gets accessed once straight
// after creating a Sender, and once each time availability changes
private static final Set<CrossProfileSender> senders =
- synchronizedSet(newSetFromMap(new WeakHashMap<>()));
+ synchronizedSet(newSetFromMap(new WeakHashMap<>()));
private static final BroadcastReceiver profileAvailabilityReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- for (CrossProfileSender sender : senders) {
- sender.scheduledExecutorService.execute(sender::checkAvailability);
+ synchronized (senders) {
+ for (CrossProfileSender sender : senders) {
+ sender.scheduledExecutorService.execute(sender::checkAvailability);
+ }
}
}
};