Added expedite tolerance

This commit is contained in:
M66B 2022-07-20 20:43:15 +02:00
parent 4b79f6bbee
commit 4452f1c1b2
2 changed files with 8 additions and 1 deletions

View File

@ -151,6 +151,8 @@ public class ServiceAuthenticator extends Authenticator {
long now = new Date().getTime(); long now = new Date().getTime();
Long expiration = authState.getAccessTokenExpirationTime(); Long expiration = authState.getAccessTokenExpirationTime();
boolean needsRefresh = (expiration != null && expiration < now); boolean needsRefresh = (expiration != null && expiration < now);
if (needsRefresh)
authState.setNeedsTokenRefresh(true);
if (!needsRefresh && forceRefresh && if (!needsRefresh && forceRefresh &&
expiration != null && expiration != null &&

View File

@ -64,6 +64,8 @@ import com.sun.mail.imap.IMAPStore;
import com.sun.mail.imap.protocol.IMAPProtocol; import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.imap.protocol.IMAPResponse; import com.sun.mail.imap.protocol.IMAPResponse;
import net.openid.appauth.AuthState;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File; import java.io.File;
@ -2356,7 +2358,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (!account.isTransient(this)) { if (!account.isTransient(this)) {
Long expirationTime = iservice.getAccessTokenExpirationTime(); Long expirationTime = iservice.getAccessTokenExpirationTime();
if (expirationTime != null && expirationTime < trigger) { if (expirationTime != null &&
expirationTime < trigger &&
expirationTime > new Date().getTime()) {
expirationTime += AuthState.EXPIRY_TIME_TOLERANCE_MS;
EntityLog.log(this, EntityLog.Type.Debug, "Expedite keep alive" + EntityLog.log(this, EntityLog.Type.Debug, "Expedite keep alive" +
" from " + new Date(trigger) + " to " + new Date(expirationTime)); " from " + new Date(trigger) + " to " + new Date(expirationTime));
trigger = expirationTime; trigger = expirationTime;