From 6cedc03465bee985c95f5b0b3c5433c490d054b4 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 25 Jun 2014 18:13:48 +0200 Subject: [PATCH] Grant that SingleSessionManager keeps URL updated --- .../lib/common/SingleSessionManager.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/lib/common/SingleSessionManager.java b/src/com/owncloud/android/lib/common/SingleSessionManager.java index f000983e..68ffbe1d 100644 --- a/src/com/owncloud/android/lib/common/SingleSessionManager.java +++ b/src/com/owncloud/android/lib/common/SingleSessionManager.java @@ -33,6 +33,7 @@ import android.accounts.Account; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.content.Context; +import android.net.Uri; import android.util.Log; import com.owncloud.android.lib.common.OwnCloudClient; @@ -81,9 +82,11 @@ public class SingleSessionManager implements OwnCloudClientManager { if (accountName != null) { client = mClientsWithUnknownUsername.remove(sessionName); if (client != null) { - Log.d(TAG, " reusing client {" + sessionName + ", " + client.hashCode() + "}"); + Log.d(TAG, " reusing client {" + sessionName + ", " + + client.hashCode() + "}"); mClientsWithKnownUsername.put(accountName, client); - Log.d(TAG, " moved client to {" + accountName + ", " + client.hashCode() + "}"); + Log.d(TAG, " moved client to {" + accountName + ", " + + client.hashCode() + "}"); } } else { client = mClientsWithUnknownUsername.get(sessionName); @@ -91,7 +94,6 @@ public class SingleSessionManager implements OwnCloudClientManager { } else { Log.d(TAG, " reusing client {" + accountName + ", " + client.hashCode() + "}"); reusingKnown = true; - keepCredentialsUpdated(account, client); } if (client == null) { @@ -117,6 +119,8 @@ public class SingleSessionManager implements OwnCloudClientManager { if (!reusingKnown) { Log.d(TAG, " reusing client {" + sessionName + ", " + client.hashCode() + "}"); } + keepCredentialsUpdated(account, client); + keepUriUpdated(account, client); } return client; @@ -186,4 +190,15 @@ public class SingleSessionManager implements OwnCloudClientManager { } + // this method is just a patch; we need to distinguish accounts in the same host but + // different paths; but that requires updating the accountNames for apps upgrading + private void keepUriUpdated(OwnCloudAccount account, OwnCloudClient reusedClient) { + Uri recentUri = account.getBaseUri(); + if (!recentUri.equals(reusedClient.getBaseUri())) { + reusedClient.setBaseUri(recentUri); + } + + } + + }