From 0ba4892d3e4efd71bba98d00e424f75db2f0536e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 12 Jun 2020 09:08:09 +0200 Subject: [PATCH] RTP: write log message on background thread --- .../siacs/conversations/services/XmppConnectionService.java | 4 ++++ .../siacs/conversations/xmpp/jingle/JingleRtpConnection.java | 2 +- src/{conversations => main}/res/menu/activity_rtp_session.xml | 0 3 files changed, 5 insertions(+), 1 deletion(-) rename src/{conversations => main}/res/menu/activity_rtp_session.xml (100%) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index ebac40f99..a6cc30e98 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -3303,6 +3303,10 @@ public class XmppConnectionService extends Service { updateConversationUi(); } + public void createMessageAsync(final Message message) { + mDatabaseWriterExecutor.execute(()-> databaseBackend.createMessage(message)); + } + public void updateMessage(Message message, String uuid) { if (!databaseBackend.updateMessage(message, uuid)) { Log.e(Config.LOGTAG, "error updated message in DB after edit"); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index 4dadb599d..e45b79997 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -1219,7 +1219,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web final Conversational conversational = message.getConversation(); if (conversational instanceof Conversation) { ((Conversation) conversational).add(this.message); - xmppConnectionService.databaseBackend.createMessage(message); + xmppConnectionService.createMessageAsync(message); xmppConnectionService.updateConversationUi(); } else { throw new IllegalStateException("Somehow the conversation in a message was a stub"); diff --git a/src/conversations/res/menu/activity_rtp_session.xml b/src/main/res/menu/activity_rtp_session.xml similarity index 100% rename from src/conversations/res/menu/activity_rtp_session.xml rename to src/main/res/menu/activity_rtp_session.xml