Expedite keep alive time for token refresh

This commit is contained in:
M66B
2022-07-20 15:56:25 +02:00
parent 85bd4c6967
commit 8162d8e0b3
3 changed files with 17 additions and 16 deletions

View File

@@ -2239,10 +2239,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
throw new StoreClosedException(iservice.getStore(), "Unrecoverable", cause);
}
// Check token expiration
if (!account.isTransient(this))
iservice.check();
// Sends store NOOP
if (EmailService.SEPARATE_STORE_CONNECTION) {
EntityLog.log(this, EntityLog.Type.Account, account,
@@ -2357,6 +2353,16 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
try {
long duration = account.poll_interval * 60 * 1000L;
long trigger = System.currentTimeMillis() + duration;
if (!account.isTransient(this)) {
Long expirationTime = iservice.getAccessTokenExpirationTime();
if (expirationTime != null && expirationTime < trigger) {
EntityLog.log(this, EntityLog.Type.Debug, "Expedite keep alive" +
" from " + new Date(trigger) + " to " + new Date(expirationTime));
trigger = expirationTime;
}
}
EntityLog.log(this, EntityLog.Type.Account, account,
"### " + account.name + " keep alive" +
" wait=" + account.poll_interval + " until=" + new Date(trigger));