aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-05-31 21:12:47 +0200
committerChristian Schneppe <christian@pix-art.de>2017-05-31 21:12:47 +0200
commita63146118140e6d2cad0d35ce00a105b8dfe72c0 (patch)
treea66ae4d8b69f4af05bfa87d3a849125e4d7b7b3c /src/main/java/de
parentf6c5da6d56a07867169db2ff68a52cbf9621cf9b (diff)
synchronize on dedicated lock for catchup instead of account
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/services/NotificationService.java9
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java8
2 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java
index 917bc9c30..ace144942 100644
--- a/src/main/java/de/pixart/messenger/services/NotificationService.java
+++ b/src/main/java/de/pixart/messenger/services/NotificationService.java
@@ -52,13 +52,14 @@ import de.pixart.messenger.xmpp.XmppConnection;
public class NotificationService {
+ public static final Object CATCHUP_LOCK = new Object();
+ private static final String CONVERSATIONS_GROUP = "de.pixart.messenger";
+ private final XmppConnectionService mXmppConnectionService;
+ private final LinkedHashMap<String, ArrayList<Message>> notifications = new LinkedHashMap<>();
private static final int NOTIFICATION_ID_MULTIPLIER = 1024 * 1024;
public static final int NOTIFICATION_ID = 2 * NOTIFICATION_ID_MULTIPLIER;
public static final int FOREGROUND_NOTIFICATION_ID = NOTIFICATION_ID_MULTIPLIER * 4;
public static final int ERROR_NOTIFICATION_ID = NOTIFICATION_ID_MULTIPLIER * 6;
- private static final String CONVERSATIONS_GROUP = "de.pixart.messenger";
- private final XmppConnectionService mXmppConnectionService;
- private final LinkedHashMap<String, ArrayList<Message>> notifications = new LinkedHashMap<>();
private Conversation mOpenConversation;
private boolean mIsInForeground;
private long mLastNotification;
@@ -179,7 +180,7 @@ public class NotificationService {
}
public void push(final Message message) {
- synchronized (message.getConversation().getAccount()) {
+ synchronized (CATCHUP_LOCK) {
final XmppConnection connection = message.getConversation().getAccount().getXmppConnection();
if (connection.isWaitingForSmCatchup()) {
connection.incrementSmCatchupMessageCounter();
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index cfb6751f4..7a4aa15fd 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -65,6 +65,7 @@ import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Message;
import de.pixart.messenger.entities.ServiceDiscoveryResult;
import de.pixart.messenger.generator.IqGenerator;
+import de.pixart.messenger.services.NotificationService;
import de.pixart.messenger.services.XmppConnectionService;
import de.pixart.messenger.ui.EditAccountActivity;
import de.pixart.messenger.utils.DNSHelper;
@@ -648,15 +649,20 @@ public class XmppConnection implements Runnable {
final AckPacket ack = new AckPacket(this.stanzasReceived, smVersion);
tagWriter.writeStanzaAsync(ack);
} else if (nextTag.isStart("a")) {
- synchronized (account) {
+ boolean accountUiNeedsRefresh = false;
+ synchronized (NotificationService.CATCHUP_LOCK) {
if (mWaitingForSmCatchup.compareAndSet(true, false)) {
int count = mSmCatchupMessageCounter.get();
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": SM catchup complete (" + count + ")");
+ accountUiNeedsRefresh = true;
if (count > 0) {
mXmppConnectionService.getNotificationService().finishBacklog(true, account);
}
}
}
+ if (accountUiNeedsRefresh) {
+ mXmppConnectionService.updateAccountUi();
+ }
final Element ack = tagReader.readElement(nextTag);
lastPacketReceived = SystemClock.elapsedRealtime();
try {