1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Grant that SingleSessionManager keeps URL updated

This commit is contained in:
David A. Velasco 2014-06-25 18:13:48 +02:00
parent 4c8f31df2f
commit 6cedc03465

View File

@ -33,6 +33,7 @@ import android.accounts.Account;
import android.accounts.AuthenticatorException; import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException; import android.accounts.OperationCanceledException;
import android.content.Context; import android.content.Context;
import android.net.Uri;
import android.util.Log; import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClient;
@ -81,9 +82,11 @@ public class SingleSessionManager implements OwnCloudClientManager {
if (accountName != null) { if (accountName != null) {
client = mClientsWithUnknownUsername.remove(sessionName); client = mClientsWithUnknownUsername.remove(sessionName);
if (client != null) { if (client != null) {
Log.d(TAG, " reusing client {" + sessionName + ", " + client.hashCode() + "}"); Log.d(TAG, " reusing client {" + sessionName + ", " +
client.hashCode() + "}");
mClientsWithKnownUsername.put(accountName, client); mClientsWithKnownUsername.put(accountName, client);
Log.d(TAG, " moved client to {" + accountName + ", " + client.hashCode() + "}"); Log.d(TAG, " moved client to {" + accountName + ", " +
client.hashCode() + "}");
} }
} else { } else {
client = mClientsWithUnknownUsername.get(sessionName); client = mClientsWithUnknownUsername.get(sessionName);
@ -91,7 +94,6 @@ public class SingleSessionManager implements OwnCloudClientManager {
} else { } else {
Log.d(TAG, " reusing client {" + accountName + ", " + client.hashCode() + "}"); Log.d(TAG, " reusing client {" + accountName + ", " + client.hashCode() + "}");
reusingKnown = true; reusingKnown = true;
keepCredentialsUpdated(account, client);
} }
if (client == null) { if (client == null) {
@ -117,6 +119,8 @@ public class SingleSessionManager implements OwnCloudClientManager {
if (!reusingKnown) { if (!reusingKnown) {
Log.d(TAG, " reusing client {" + sessionName + ", " + client.hashCode() + "}"); Log.d(TAG, " reusing client {" + sessionName + ", " + client.hashCode() + "}");
} }
keepCredentialsUpdated(account, client);
keepUriUpdated(account, client);
} }
return 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);
}
}
} }