|
|
@ -1230,12 +1230,15 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
idlers.clear();
|
|
|
|
idlers.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (state.isRunning())
|
|
|
|
if (state.isRunning()) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (backoff <= CONNECT_BACKOFF_MAX) {
|
|
|
|
if (backoff <= CONNECT_BACKOFF_MAX) {
|
|
|
|
// Short back-off period, keep device awake
|
|
|
|
// Short back-off period, keep device awake
|
|
|
|
EntityLog.log(this, account.name + " backoff=" + backoff);
|
|
|
|
EntityLog.log(this, account.name + " backoff=" + backoff);
|
|
|
|
|
|
|
|
try {
|
|
|
|
state.acquire(backoff * 1000L);
|
|
|
|
state.acquire(backoff * 1000L);
|
|
|
|
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
|
|
|
Log.w(account.name + " backoff " + ex.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Long back-off period, let device sleep
|
|
|
|
// Long back-off period, let device sleep
|
|
|
|
EntityLog.log(this, account.name + " backoff alarm=" + CONNECT_BACKOFF_AlARM);
|
|
|
|
EntityLog.log(this, account.name + " backoff alarm=" + CONNECT_BACKOFF_AlARM);
|
|
|
@ -1247,7 +1250,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
String id = BuildConfig.APPLICATION_ID + ".BACKOFF." + account.id + "." + new Random().nextInt();
|
|
|
|
String id = BuildConfig.APPLICATION_ID + ".BACKOFF." + account.id;
|
|
|
|
PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(id), 0);
|
|
|
|
PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(id), 0);
|
|
|
|
registerReceiver(alarm, new IntentFilter(id));
|
|
|
|
registerReceiver(alarm, new IntentFilter(id));
|
|
|
|
|
|
|
|
|
|
|
@ -1267,6 +1270,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
wlAccount.release();
|
|
|
|
wlAccount.release();
|
|
|
|
state.acquire(2 * CONNECT_BACKOFF_AlARM * 60 * 1000L);
|
|
|
|
state.acquire(2 * CONNECT_BACKOFF_AlARM * 60 * 1000L);
|
|
|
|
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
|
|
|
Log.w(account.name + " backoff " + ex.toString());
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
wlAccount.acquire();
|
|
|
|
wlAccount.acquire();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1276,6 +1281,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
unregisterReceiver(alarm);
|
|
|
|
unregisterReceiver(alarm);
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
|
|
|
|
// Should not happen, but does happen
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1283,8 +1289,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
|
|
|
|
|
|
|
if (backoff <= CONNECT_BACKOFF_MAX)
|
|
|
|
if (backoff <= CONNECT_BACKOFF_MAX)
|
|
|
|
backoff *= 2;
|
|
|
|
backoff *= 2;
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
|
|
|
Log.w(account.name + " backoff " + ex.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|