Refresh authorization token on failed downloads / uploads when notification error...
[pub/Android/ownCloud.git] / src / com / owncloud / android / authenticator / AccountAuthenticator.java
index c6ad9e7..a42c1f2 100644 (file)
@@ -1,9 +1,10 @@
 /* ownCloud Android client application\r
  *   Copyright (C) 2012  Bartek Przybylski\r
+ *   Copyright (C) 2012-2013 ownCloud Inc.\r
  *\r
  *   This program is free software: you can redistribute it and/or modify\r
  *   it under the terms of the GNU General Public License as published by\r
- *   the Free Software Foundation, either version 3 of the License, or\r
+ *   the Free Software Foundation, either version 2 of the License, or\r
  *   (at your option) any later version.\r
  *\r
  *   This program is distributed in the hope that it will be useful,\r
@@ -98,6 +99,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);\r
         intent.putExtra(KEY_REQUIRED_FEATURES, requiredFeatures);\r
         intent.putExtra(KEY_LOGIN_OPTIONS, options);\r
+        intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);\r
 \r
         setIntentFlags(intent);\r
         \r
@@ -173,12 +175,14 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
             return result;\r
         }\r
         \r
-        /// if not stored, return Intent to access the AuthenticatorActivity\r
+        /// if not stored, return Intent to access the AuthenticatorActivity and UPDATE the token for the account\r
         final Intent intent = new Intent(mContext, AuthenticatorActivity.class);\r
         intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);\r
         intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);\r
         intent.putExtra(KEY_LOGIN_OPTIONS, options);\r
         intent.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);\r
+        intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);\r
+        \r
 \r
         final Bundle bundle = new Bundle();\r
         bundle.putParcelable(AccountManager.KEY_INTENT, intent);\r
@@ -194,7 +198,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
     public Bundle hasFeatures(AccountAuthenticatorResponse response,\r
             Account account, String[] features) throws NetworkErrorException {\r
         final Bundle result = new Bundle();\r
-        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);\r
+        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);\r
         return result;\r
     }\r
 \r
@@ -224,8 +228,8 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
 \r
     private void setIntentFlags(Intent intent) {\r
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\r
-        intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);\r
-        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // incompatible with the authorization code grant in OAuth\r
+        //intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);\r
+        //intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // incompatible with the authorization code grant in OAuth\r
         intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);\r
         intent.addFlags(Intent.FLAG_FROM_BACKGROUND);\r
     }\r