From 414d3abca20e8b1c3c97b74efc0404f5f6a78be6 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Mon, 7 Nov 2016 21:48:01 +0100 Subject: removed unnecessary push_mode --- src/main/java/de/pixart/messenger/Config.java | 2 -- .../pixart/messenger/services/EventReceiver.java | 5 --- .../messenger/services/XmppConnectionService.java | 41 ++++++---------------- 3 files changed, 11 insertions(+), 37 deletions(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java index 01c2bcc56..7f62306c5 100644 --- a/src/main/java/de/pixart/messenger/Config.java +++ b/src/main/java/de/pixart/messenger/Config.java @@ -69,8 +69,6 @@ public final class Config { public static final int CONNECT_DISCO_TIMEOUT = 30; public static final int MINI_GRACE_PERIOD = 750; - public static final boolean PUSH_MODE = false; //closes the tcp connection when going to background and after PING_MIN_INTERVAL of inactivity very experimental. only enable this if you want to around with GCM push - public static final int AVATAR_SIZE = 720; public static final Bitmap.CompressFormat AVATAR_FORMAT = Bitmap.CompressFormat.JPEG; diff --git a/src/main/java/de/pixart/messenger/services/EventReceiver.java b/src/main/java/de/pixart/messenger/services/EventReceiver.java index 80e5b06b5..63cefe738 100644 --- a/src/main/java/de/pixart/messenger/services/EventReceiver.java +++ b/src/main/java/de/pixart/messenger/services/EventReceiver.java @@ -3,9 +3,7 @@ package de.pixart.messenger.services; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.net.ConnectivityManager; -import de.pixart.messenger.Config; import de.pixart.messenger.persistance.DatabaseBackend; public class EventReceiver extends BroadcastReceiver { @@ -19,9 +17,6 @@ public class EventReceiver extends BroadcastReceiver { mIntentForService.setAction("other"); } final String action = intent.getAction(); - if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION) && Config.PUSH_MODE) { - return; - } if (action.equals("ui") || DatabaseBackend.getInstance(context).hasEnabledAccounts()) { context.startService(mIntentForService); } diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 88873cdf4..15f76b12f 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -343,16 +343,10 @@ public class XmppConnectionService extends Service { joinMuc(conversation); } account.pendingConferenceJoins.clear(); - scheduleWakeUpCall(Config.PUSH_MODE ? Config.PING_MIN_INTERVAL : Config.PING_MAX_INTERVAL, account.getUuid().hashCode()); + scheduleWakeUpCall(Config.PING_MAX_INTERVAL, account.getUuid().hashCode()); } else if (account.getStatus() == Account.State.OFFLINE || account.getStatus() == Account.State.DISABLED) { resetSendingToWaiting(account); - final boolean disabled = account.isOptionSet(Account.OPTION_DISABLED); - final boolean listeners = checkListeners(); - final boolean pushMode = Config.PUSH_MODE - && mPushManagementService.available(account) - && listeners; - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": push mode="+Boolean.toString(pushMode)+" listeners="+Boolean.toString(listeners)); - if (!disabled && !pushMode) { + if (!account.isOptionSet(Account.OPTION_DISABLED)) { synchronized (mLowPingTimeoutMode) { if (mLowPingTimeoutMode.contains(account.getJid().toBareJid())) { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": went into offline state during low ping mode. reconnecting now"); @@ -705,8 +699,7 @@ public class XmppConnectionService extends Service { refreshAllGcmTokens(); break; case ACTION_IDLE_PING: - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - && !Config.PUSH_MODE) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { scheduleNextIdlePing(); } break; @@ -739,7 +732,7 @@ public class XmppConnectionService extends Service { synchronized (mLowPingTimeoutMode) { long lastReceived = account.getXmppConnection().getLastPacketReceived(); long lastSent = account.getXmppConnection().getLastPingSent(); - long pingInterval = (Config.PUSH_MODE || "ui".equals(action)) ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000; + long pingInterval = "ui".equals(action) ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000; long msToNextPing = (Math.max(lastReceived, lastSent) + pingInterval) - SystemClock.elapsedRealtime(); int pingTimeout = mLowPingTimeoutMode.contains(account.getJid().toBareJid()) ? Config.LOW_PING_TIMEOUT * 1000 : Config.PING_TIMEOUT * 1000; long pingTimeoutIn = (lastSent + pingTimeout) - SystemClock.elapsedRealtime(); @@ -797,21 +790,13 @@ public class XmppConnectionService extends Service { } } if (pingNow) { - final boolean listeners = checkListeners(); for (Account account : pingCandidates) { - if (listeners - && Config.PUSH_MODE - && mPushManagementService.available(account)) { - account.getXmppConnection().waitForPush(); - cancelWakeUpCall(account.getUuid().hashCode()); - } else { - synchronized (mLowPingTimeoutMode) { - final boolean lowTimeout = mLowPingTimeoutMode.contains(account.getJid().toBareJid()); - account.getXmppConnection().sendPing(); - Log.d(Config.LOGTAG, account.getJid().toBareJid() + " send ping (action=" + action + ",listeners=" + Boolean.toString(listeners) + ",lowTimeout=" + Boolean.toString(lowTimeout) + ")"); - scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT, account.getUuid().hashCode()); - } - } + synchronized (mLowPingTimeoutMode) { + final boolean lowTimeout = mLowPingTimeoutMode.contains(account.getJid().toBareJid()); + account.getXmppConnection().sendPing(); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + " send ping (action=" + action + ",lowTimeout=" + Boolean.toString(lowTimeout) + ")"); + scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT, account.getUuid().hashCode()); + } } } if (wakeLock.isHeld()) { @@ -1053,7 +1038,7 @@ public class XmppConnectionService extends Service { toggleForegroundService(); updateUnreadCountBadge(); toggleScreenEventReceiver(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Config.PUSH_MODE) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { scheduleNextIdlePing(); } //start export log service every day at given time @@ -2161,10 +2146,6 @@ public class XmppConnectionService extends Service { if (connection.getFeatures().csi()) { connection.sendInactive(); } - if (Config.PUSH_MODE && mPushManagementService.available(account)) { - connection.waitForPush(); - cancelWakeUpCall(account.getUuid().hashCode()); - } } } } -- cgit v1.2.3