mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
config option to reset attempt counts when changing network (default=true)
This commit is contained in:
parent
c4a4dd2392
commit
d9e5035c08
@ -29,6 +29,7 @@ public final class Config {
|
|||||||
public static final boolean NO_PROXY_LOOKUP = false; //useful to debug ibb
|
public static final boolean NO_PROXY_LOOKUP = false; //useful to debug ibb
|
||||||
public static final boolean DISABLE_STRING_PREP = false; // setting to true might increase startup performance
|
public static final boolean DISABLE_STRING_PREP = false; // setting to true might increase startup performance
|
||||||
public static final boolean EXTENDED_SM_LOGGING = true; // log stanza counts
|
public static final boolean EXTENDED_SM_LOGGING = true; // log stanza counts
|
||||||
|
public static final boolean RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE = true; //setting to true might increase power consumption
|
||||||
|
|
||||||
public static final long MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000;
|
public static final long MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000;
|
||||||
public static final long MAM_MAX_CATCHUP = MILLISECONDS_IN_DAY / 2;
|
public static final long MAM_MAX_CATCHUP = MILLISECONDS_IN_DAY / 2;
|
||||||
|
@ -424,6 +424,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
final String action = intent == null ? null : intent.getAction();
|
final String action = intent == null ? null : intent.getAction();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case ConnectivityManager.CONNECTIVITY_ACTION:
|
||||||
|
if (hasInternetConnection() && Config.RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE) {
|
||||||
|
resetAllAttemptCounts(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ACTION_MERGE_PHONE_CONTACTS:
|
case ACTION_MERGE_PHONE_CONTACTS:
|
||||||
if (mRestoredFromDatabase) {
|
if (mRestoredFromDatabase) {
|
||||||
PhoneHelper.loadPhoneContacts(getApplicationContext(),
|
PhoneHelper.loadPhoneContacts(getApplicationContext(),
|
||||||
@ -442,14 +447,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
toggleForegroundService();
|
toggleForegroundService();
|
||||||
break;
|
break;
|
||||||
case ACTION_TRY_AGAIN:
|
case ACTION_TRY_AGAIN:
|
||||||
for(Account account : accounts) {
|
resetAllAttemptCounts(false);
|
||||||
if (account.hasErrorStatus()) {
|
|
||||||
final XmppConnection connection = account.getXmppConnection();
|
|
||||||
if (connection != null) {
|
|
||||||
connection.resetAttemptCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ACTION_DISABLE_ACCOUNT:
|
case ACTION_DISABLE_ACCOUNT:
|
||||||
try {
|
try {
|
||||||
@ -531,6 +529,18 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetAllAttemptCounts(boolean reallyAll) {
|
||||||
|
Log.d(Config.LOGTAG,"resetting all attepmt counts");
|
||||||
|
for(Account account : accounts) {
|
||||||
|
if (account.hasErrorStatus() || reallyAll) {
|
||||||
|
final XmppConnection connection = account.getXmppConnection();
|
||||||
|
if (connection != null) {
|
||||||
|
connection.resetAttemptCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasInternetConnection() {
|
public boolean hasInternetConnection() {
|
||||||
ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
|
ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
|
||||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
Loading…
Reference in New Issue
Block a user