Don't reconnect to gcm when opening settings

This doesn't treat the underlying issues and can make debugging harder if we suddenly auto-connect due to this.

Change-Id: I9c04c78e8ebda8472b0cd8c7b0b0deb2e2300139
This commit is contained in:
Torsten Grote 2021-10-13 13:13:19 -03:00 committed by Marvin W
parent 14d666a163
commit 00a06d4b94
2 changed files with 4 additions and 10 deletions

View File

@ -244,9 +244,10 @@ public class McsService extends Service implements Handler.Callback {
}
// consider connection to be dead if we did not receive an ack within twice the heartbeat interval
int heartbeatMs = GcmPrefs.get(context).getHeartbeatMsFor(activeNetworkPref);
if (heartbeatMs < 0) { // TODO how can this be negative?
// if disabled for active network, heartbeatMs will be -1
if (heartbeatMs < 0) {
closeAll();
} else if (SystemClock.elapsedRealtime() - lastHeartbeatAckElapsedRealtime > 2 * heartbeatMs) {
} 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);
return false;

View File

@ -5,7 +5,6 @@
package org.microg.gms.ui
import android.content.Intent
import android.content.Context
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
@ -14,8 +13,6 @@ import androidx.preference.Preference
import com.google.android.gms.R
import org.microg.gms.checkin.getCheckinServiceInfo
import org.microg.gms.gcm.GcmDatabase
import org.microg.gms.gcm.McsConstants.ACTION_RECONNECT
import org.microg.gms.gcm.TriggerReceiver
import org.microg.gms.gcm.getGcmServiceInfo
import org.microg.gms.safetynet.getSafetyNetServiceInfo
import org.microg.nlp.client.UnifiedLocationClient
@ -65,10 +62,6 @@ class SettingsFragment : ResourceSettingsFragment() {
if (gcmServiceInfo.configuration.enabled) {
val database = GcmDatabase(context)
val regCount = database.registrationList.size
// check if we are connected as we should be and re-connect if not
if (!gcmServiceInfo.connected) {
context.sendBroadcast(Intent(ACTION_RECONNECT, null, context, TriggerReceiver::class.java))
}
database.close()
findPreference<Preference>(PREF_GCM)!!.summary = getString(R.string.service_status_enabled_short) + " - " + resources.getQuantityString(R.plurals.gcm_registered_apps_counter, regCount, regCount)
} else {
@ -79,7 +72,7 @@ class SettingsFragment : ResourceSettingsFragment() {
findPreference<Preference>(PREF_SNET)!!.setSummary(if (getSafetyNetServiceInfo(context).configuration.enabled) R.string.service_status_enabled_short else R.string.service_status_disabled_short)
val backendCount = UnifiedLocationClient[context].getLocationBackends().size + UnifiedLocationClient[context].getGeocoderBackends().size
findPreference<Preference>(PREF_UNIFIEDNLP)!!.summary = resources.getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount);
findPreference<Preference>(PREF_UNIFIEDNLP)!!.summary = resources.getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount)
findPreference<Preference>(PREF_EXPOSURE)?.isVisible = NearbyPreferencesIntegration.isAvailable
findPreference<Preference>(PREF_EXPOSURE)?.icon = NearbyPreferencesIntegration.getIcon(context)