Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ba2c04c authored by Torsten Grote's avatar Torsten Grote Committed by Marvin W.
Browse files

Don't say we are connected when push is disabled for current network

This may cause a connection attempt, but in connect(), we'll notice that it is disabled and won't continue to connect.

Change-Id: Id5f00539a48fad16b5e5f55bd336fb8890aa1acc
parent bb68674c
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -248,6 +249,7 @@ public class McsService extends Service implements Handler.Callback {
        // if disabled for active network, heartbeatMs will be -1
        if (heartbeatMs < 0) {
            closeAll();
            return false;
        } else if (SystemClock.elapsedRealtime() - lastHeartbeatAckElapsedRealtime > 2L * heartbeatMs) {
            logd(null, "No heartbeat for " + (SystemClock.elapsedRealtime() - lastHeartbeatAckElapsedRealtime) / 1000 + " seconds, connection assumed to be dead after " + 2 * heartbeatMs / 1000 + " seconds");
            GcmPrefs.get(context).learnTimeout(context, activeNetworkPref);
@@ -436,8 +438,10 @@ public class McsService extends Service implements Handler.Callback {
        try {
            closeAll();
            ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
            activeNetworkPref = GcmPrefs.get(this).getNetworkPrefForInfo(cm.getActiveNetworkInfo());
            if (!GcmPrefs.get(this).isEnabledFor(cm.getActiveNetworkInfo())) {
            NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
            activeNetworkPref = GcmPrefs.get(this).getNetworkPrefForInfo(activeNetworkInfo);
            if (!GcmPrefs.get(this).isEnabledFor(activeNetworkInfo)) {
                logd(this, "Don't connect, because disabled for " + activeNetworkInfo.getTypeName());
                scheduleReconnect(this);
                return;
            }