Refresh token on each connect

This commit is contained in:
M66B 2018-08-28 06:58:57 +00:00
parent fe17a18d24
commit 0ac5c41052
1 changed files with 16 additions and 15 deletions

View File

@ -389,23 +389,24 @@ public class ServiceSynchronize extends LifecycleService {
final DB db = DB.getInstance(this);
final ExecutorService executor = Executors.newSingleThreadExecutor();
boolean debug = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("debug", false);
if (debug)
System.setProperty("mail.socket.debug", "true");
// Refresh token
if (account.auth_type == Helper.AUTH_TYPE_GMAIL) {
account.password = Helper.refreshToken(this, "com.google", account.user, account.password);
db.account().setAccountPassword(account.id, account.password);
}
Properties props = MessageHelper.getSessionProperties(account.auth_type);
final Session isession = Session.getInstance(props, null);
isession.setDebug(debug);
// adb -t 1 logcat | grep "fairemail\|System.out"
int backoff = CONNECT_BACKOFF_START;
while (state.running) {
// Debug
boolean debug = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("debug", false);
if (debug)
System.setProperty("mail.socket.debug", "true");
// Refresh token
if (account.auth_type == Helper.AUTH_TYPE_GMAIL) {
account.password = Helper.refreshToken(this, "com.google", account.user, account.password);
db.account().setAccountPassword(account.id, account.password);
}
Properties props = MessageHelper.getSessionProperties(account.auth_type);
final Session isession = Session.getInstance(props, null);
isession.setDebug(debug);
// adb -t 1 logcat | grep "fairemail\|System.out"
final IMAPStore istore = (IMAPStore) isession.getStore("imaps");
final Map<EntityFolder, IMAPFolder> folders = new HashMap<>();
List<Thread> noops = new ArrayList<>();