|
@@ -70,6 +70,7 @@ import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientList
|
|
import com.owncloud.android.lib.common.OwnCloudAccount;
|
|
import com.owncloud.android.lib.common.OwnCloudAccount;
|
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
|
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
|
|
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
|
|
|
|
+import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
|
|
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
|
|
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
|
|
import com.owncloud.android.lib.common.network.CertificateCombinedException;
|
|
import com.owncloud.android.lib.common.network.CertificateCombinedException;
|
|
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
|
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
|
@@ -1000,8 +1001,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|
showAuthStatus();
|
|
showAuthStatus();
|
|
Log_OC.d(TAG, result.getLogMessage());
|
|
Log_OC.d(TAG, result.getLogMessage());
|
|
} else {
|
|
} else {
|
|
- updateAccountAuthentication();
|
|
|
|
- success = true;
|
|
|
|
|
|
+ try {
|
|
|
|
+ updateAccountAuthentication();
|
|
|
|
+ success = true;
|
|
|
|
+
|
|
|
|
+ } catch (AccountNotFoundException e) {
|
|
|
|
+ Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);
|
|
|
|
+ Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1367,8 +1375,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|
success = createAccount();
|
|
success = createAccount();
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- updateAccountAuthentication();
|
|
|
|
- success = true;
|
|
|
|
|
|
+ try {
|
|
|
|
+ updateAccountAuthentication();
|
|
|
|
+ success = true;
|
|
|
|
+
|
|
|
|
+ } catch (AccountNotFoundException e) {
|
|
|
|
+ Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);
|
|
|
|
+ Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (success) {
|
|
if (success) {
|
|
@@ -1417,16 +1432,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|
* Kills the session kept by OwnCloudClientManager so that a new one will created with
|
|
* Kills the session kept by OwnCloudClientManager so that a new one will created with
|
|
* the new credentials when needed.
|
|
* the new credentials when needed.
|
|
*/
|
|
*/
|
|
- private void updateAccountAuthentication() {
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(
|
|
|
|
- new OwnCloudAccount(mAccount, this) // TODO avoid this creation may block the main thread
|
|
|
|
- );
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
+ private void updateAccountAuthentication() throws AccountNotFoundException {
|
|
|
|
|
|
|
|
+ OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(
|
|
|
|
+ new OwnCloudAccount(mAccount, this)
|
|
|
|
+ );
|
|
|
|
|
|
Bundle response = new Bundle();
|
|
Bundle response = new Bundle();
|
|
response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);
|
|
response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);
|