diff --git a/app/src/main/java/eu/faircode/email/GmailState.java b/app/src/main/java/eu/faircode/email/GmailState.java index 5178e729e4..3772b2129c 100644 --- a/app/src/main/java/eu/faircode/email/GmailState.java +++ b/app/src/main/java/eu/faircode/email/GmailState.java @@ -53,8 +53,8 @@ public class GmailState { return token; } - void refresh(@NonNull Context context, @NonNull String user, boolean expired) throws AuthenticatorException, OperationCanceledException, IOException { - if (expired || acquired + TOKEN_LIFETIME < new Date().getTime()) + void refresh(@NonNull Context context, @NonNull String user, boolean expire) throws AuthenticatorException, OperationCanceledException, IOException { + if (expire || acquired + TOKEN_LIFETIME < new Date().getTime()) try { if (token != null) { EntityLog.log(context, "Invalidating token user=" + user); @@ -73,7 +73,10 @@ public class GmailState { EntityLog.log(context, "Getting token user=" + user); AccountManager am = AccountManager.get(context); - String newToken = am.blockingGetAuthToken(account, ServiceAuthenticator.getAuthTokenType(TYPE_GOOGLE), true); + String newToken = am.blockingGetAuthToken( + account, + ServiceAuthenticator.getAuthTokenType(TYPE_GOOGLE), + true); if (newToken != null && !newToken.equals(token)) { token = newToken; diff --git a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java index ebf9cf5b85..cd301d826f 100644 --- a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java +++ b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java @@ -80,19 +80,19 @@ public class ServiceAuthenticator extends Authenticator { return new PasswordAuthentication(user, token); } - String refreshToken(boolean expired) throws AuthenticatorException, OperationCanceledException, IOException, JSONException, MessagingException { + String refreshToken(boolean expire) throws AuthenticatorException, OperationCanceledException, IOException, JSONException, MessagingException { if (auth == AUTH_TYPE_GMAIL) { - GmailState gmailState = GmailState.jsonDeserialize(password); - gmailState.refresh(context, user, expired); + GmailState authState = GmailState.jsonDeserialize(password); + authState.refresh(context, user, expire); - String newPassword = gmailState.jsonSerializeString(); + String newPassword = authState.jsonSerializeString(); if (!Objects.equals(password, newPassword)) { password = newPassword; if (intf != null) intf.onPasswordChanged(password); } - return gmailState.getAccessToken(); + return authState.getAccessToken(); } else if (auth == AUTH_TYPE_OAUTH) { AuthState authState = AuthState.jsonDeserialize(password); OAuthRefresh(context, provider, authState);