diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 13480a82a..a1f7d1d41 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -41,6 +41,8 @@ public final class Config { public static final String LOGTAG = BuildConfig.APP_NAME.toLowerCase(Locale.US); + public static final boolean QUICK_LOG = false; + public static final Jid BUG_REPORTS = Jid.of("bugs@conversations.im"); public static final Uri HELP = Uri.parse("https://help.conversations.im"); diff --git a/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java b/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java index f27bf7fc5..1ff0e0403 100644 --- a/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java +++ b/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java @@ -112,6 +112,7 @@ public class UnifiedPushBroker { Log.d( Config.LOGTAG, account.getJid().asBareJid() + ": try to renew UnifiedPush " + renewal); + UnifiedPushDistributor.quickLog(service,String.format("%s: try to renew UnifiedPush %s", account.getJid(), renewal.toString())); final String hashedApplication = UnifiedPushDistributor.hash(account.getUuid(), renewal.application); final String hashedInstance = @@ -186,7 +187,16 @@ public class UnifiedPushBroker { + renewal.instance + " was updated to " + endpoint); - final UnifiedPushDatabase.ApplicationEndpoint applicationEndpoint = new UnifiedPushDatabase.ApplicationEndpoint(renewal.application, endpoint); + UnifiedPushDistributor.quickLog( + service, + "endpoint for " + + renewal.application + + "/" + + renewal.instance + + " was updated to " + + endpoint); + final UnifiedPushDatabase.ApplicationEndpoint applicationEndpoint = + new UnifiedPushDatabase.ApplicationEndpoint(renewal.application, endpoint); sendEndpoint(messenger, renewal.instance, applicationEndpoint); } } diff --git a/src/main/java/eu/siacs/conversations/services/UnifiedPushDistributor.java b/src/main/java/eu/siacs/conversations/services/UnifiedPushDistributor.java index c5402dec6..a1b4c3e3c 100644 --- a/src/main/java/eu/siacs/conversations/services/UnifiedPushDistributor.java +++ b/src/main/java/eu/siacs/conversations/services/UnifiedPushDistributor.java @@ -102,6 +102,7 @@ public class UnifiedPushDistributor extends BroadcastReceiver { Log.d( Config.LOGTAG, "successfully created UnifiedPush entry. waking up XmppConnectionService"); + quickLog(context, String.format("successfully registered %s (token = %s) for UnifiedPushed", application, instance)); final Intent serviceIntent = new Intent(context, XmppConnectionService.class); serviceIntent.setAction(XmppConnectionService.ACTION_RENEW_UNIFIED_PUSH_ENDPOINTS); serviceIntent.putExtra("instance", instance); @@ -141,6 +142,7 @@ public class UnifiedPushDistributor extends BroadcastReceiver { } final UnifiedPushDatabase unifiedPushDatabase = UnifiedPushDatabase.getInstance(context); if (unifiedPushDatabase.deleteInstance(instance)) { + quickLog(context, String.format("successfully unregistered token %s from UnifiedPushed (application requested unregister)", instance)); Log.d(Config.LOGTAG, "successfully removed " + instance + " from UnifiedPush"); } } @@ -154,6 +156,7 @@ public class UnifiedPushDistributor extends BroadcastReceiver { Log.d(Config.LOGTAG, "app " + application + " has been removed from the system"); final UnifiedPushDatabase database = UnifiedPushDatabase.getInstance(context); if (database.deleteApplication(application)) { + quickLog(context, String.format("successfully removed %s from UnifiedPushed (ACTION_PACKAGE_FULLY_REMOVED)", application)); Log.d(Config.LOGTAG, "successfully removed " + application + " from UnifiedPush"); } } @@ -166,4 +169,11 @@ public class UnifiedPushDistributor extends BroadcastReceiver { .hashString(Joiner.on('\0').join(components), Charsets.UTF_8) .asBytes()); } + + public static void quickLog(final Context context, final String message) { + final Intent intent = new Intent(context, XmppConnectionService.class); + intent.setAction(XmppConnectionService.ACTION_QUICK_LOG); + intent.putExtra("message", message); + context.startService(intent); + } } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index d2f26af79..23998ae53 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -133,6 +133,7 @@ import eu.siacs.conversations.ui.UiCallback; import eu.siacs.conversations.ui.interfaces.OnAvatarPublication; import eu.siacs.conversations.ui.interfaces.OnMediaLoaded; import eu.siacs.conversations.ui.interfaces.OnSearchResultsAvailable; +import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.Compatibility; import eu.siacs.conversations.utils.ConversationsFileObserver; import eu.siacs.conversations.utils.CryptoHelper; @@ -199,6 +200,7 @@ public class XmppConnectionService extends Service { public static final String ACTION_PROVISION_ACCOUNT = "provision_account"; private static final String ACTION_POST_CONNECTIVITY_CHANGE = "eu.siacs.conversations.POST_CONNECTIVITY_CHANGE"; public static final String ACTION_RENEW_UNIFIED_PUSH_ENDPOINTS = "eu.siacs.conversations.UNIFIED_PUSH_RENEW"; + public static final String ACTION_QUICK_LOG = "eu.siacs.conversations.QUICK_LOG"; private static final String SETTING_LAST_ACTIVITY_TS = "last_activity_timestamp"; @@ -864,6 +866,12 @@ public class XmppConnectionService extends Service { case ACTION_FCM_MESSAGE_RECEIVED: Log.d(Config.LOGTAG, "push message arrived in service. account"); break; + case ACTION_QUICK_LOG: + final String message = intent == null ? null : intent.getStringExtra("message"); + if (message != null && Config.QUICK_LOG) { + quickLog(message); + } + break; case Intent.ACTION_SEND: final Uri uri = intent == null ? null : intent.getData(); if (uri != null) { @@ -884,6 +892,23 @@ public class XmppConnectionService extends Service { return START_STICKY; } + private void quickLog(final String message) { + if (Strings.isNullOrEmpty(message)) { + return; + } + final Account account = AccountUtils.getFirstEnabled(this); + if (account == null) { + return; + } + final Conversation conversation = + findOrCreateConversation(account, Config.BUG_REPORTS, false, true); + final Message report = new Message(conversation, message, Message.ENCRYPTION_NONE); + report.setStatus(Message.STATUS_RECEIVED); + conversation.add(report); + databaseBackend.createMessage(report); + updateConversationUi(); + } + private void manageAccountConnectionStatesInternal() { manageAccountConnectionStates(ACTION_INTERNAL_PING, null); }