Skip to content

Commit 4c22ea5

Browse files
committed
Usage of mVisibleNotifications now should synchronize on this
1 parent 903faae commit 4c22ea5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

com.unity.mobile.notifications/Runtime/Android/Plugins/com/unity/androidnotifications/UnityNotificationManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ private Set<String> findInvalidNotificationIds(Set<String> ids) {
428428
invalid.remove(id);
429429
}
430430
}
431-
else synchronized (UnityNotificationManager.class) {
431+
else synchronized (this) {
432432
for (Integer visibleId : mVisibleNotifications) {
433433
String id = String.valueOf(visibleId);
434434
invalid.remove(id);
@@ -548,7 +548,7 @@ public int checkNotificationStatus(int id) {
548548
if (id == n.getId())
549549
return 2;
550550
}
551-
} else synchronized (UnityNotificationManager.class) {
551+
} else synchronized (this) {
552552
for (Integer notificationId : mVisibleNotifications) {
553553
if (notificationId.intValue() == id)
554554
return 2;
@@ -631,7 +631,7 @@ public void onReceive(Intent intent) {
631631
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
632632
if (KEY_NOTIFICATION_DISMISSED.equals(intent.getAction())) {
633633
int removedId = intent.getIntExtra(KEY_NOTIFICATION_DISMISSED, -1);
634-
if (removedId > 0) synchronized (UnityNotificationManager.class) {
634+
if (removedId > 0) synchronized (this) {
635635
mVisibleNotifications.remove(removedId);
636636
}
637637
return;
@@ -676,7 +676,7 @@ private void notify(int id, Notification notification) {
676676
boolean showInForeground = notification.extras.getBoolean(KEY_SHOW_IN_FOREGROUND, true);
677677
if (!isInForeground() || showInForeground) {
678678
getNotificationManager().notify(id, notification);
679-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) synchronized (UnityNotificationManager.class) {
679+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) synchronized (this) {
680680
mVisibleNotifications.add(Integer.valueOf(id));
681681
}
682682
}

0 commit comments

Comments
 (0)