From 6d5cb44de797041806920cc6f8f323388acee6d7 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 5 Oct 2011 15:14:41 -0700 Subject: [PATCH] Try token revalidation with other form of getAuthToken (not for samsung phones) --- .../gtasks/auth/GtasksTokenValidator.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java index 3b61d3134..8d0482e8c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java @@ -51,7 +51,31 @@ public class GtasksTokenValidator { return token; } catch (IOException i2) { i2.printStackTrace(); - throw new GoogleTasksException(c.getString(R.string.gtasks_error_authRefresh)); + String manufacturer = android.os.Build.MANUFACTURER.toLowerCase(); + if (!manufacturer.contains("samsung")) { // Try with the notifyAuthFailure set to true in case it was that that broke things + accountManager.invalidateAuthToken(token); + future = accountManager.manager.getAuthToken(a, GtasksService.AUTH_TOKEN_TYPE, true, null, null); + try { + if (future.getResult().containsKey(AccountManager.KEY_AUTHTOKEN)) { + result = future.getResult(); + token = result.getString(AccountManager.KEY_AUTHTOKEN); + testService = new GtasksService(token); + try { + testService.ping(); + return token; + } catch (IOException i3) { + i3.printStackTrace(); + throw new GoogleTasksException(c.getString(R.string.gtasks_error_authRefresh)); + } + } else { + throw new GoogleTasksException(c.getString(R.string.gtasks_error_accountManager)); + } + } catch (Exception e) { + throw new GoogleTasksException(e.getLocalizedMessage()); + } + } else { + throw new GoogleTasksException(c.getString(R.string.gtasks_error_authRefresh)); + } } } else { throw new GoogleTasksException(c.getString(R.string.gtasks_error_accountManager)); @@ -62,5 +86,4 @@ public class GtasksTokenValidator { } } - }