Don't put Credentials in HostAuth parcels

The problem is that exchange isn't compiled with this
change, so HostAuth parcels to or from exchange fail.
Ultimately, we'll need to probably create a HostAuth2
object or something along those lines. For now, just
change the format of HostAuth parcels back, so they
stay compatible with exchange, I'll figure out a real
solution later.

Change-Id: I9c8c8639b7b474fe82dfdc37a9e51a0451820105
This commit is contained in:
Martin Hibdon 2013-12-10 17:12:00 -08:00
parent 2bf9590ddd
commit 05723aa0f6
2 changed files with 51 additions and 47 deletions

View File

@ -742,12 +742,13 @@ public final class Account extends EmailContent implements AccountColumns, Parce
// Also, remember which operation in the array they represent // Also, remember which operation in the array they represent
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
if (mHostAuthRecv != null) { if (mHostAuthRecv != null) {
if (mHostAuthRecv.mCredential != null) { // TODO: This causes problems because it's incompatible with Exchange.
recvCredentialsIndex = index++; // if (mHostAuthRecv.mCredential != null) {
ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri) // recvCredentialsIndex = index++;
.withValues(mHostAuthRecv.mCredential.toContentValues()) // ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri)
.build()); // .withValues(mHostAuthRecv.mCredential.toContentValues())
} // .build());
// }
recvIndex = index++; recvIndex = index++;
final ContentProviderOperation.Builder b = ContentProviderOperation.newInsert( final ContentProviderOperation.Builder b = ContentProviderOperation.newInsert(
@ -761,18 +762,19 @@ public final class Account extends EmailContent implements AccountColumns, Parce
ops.add(b.build()); ops.add(b.build());
} }
if (mHostAuthSend != null) { if (mHostAuthSend != null) {
if (mHostAuthSend.mCredential != null) { // TODO: This causes problems because it's incompatible with Exchange.
if (mHostAuthRecv.mCredential != null && // if (mHostAuthSend.mCredential != null) {
mHostAuthRecv.mCredential.equals(mHostAuthSend.mCredential)) { // if (mHostAuthRecv.mCredential != null &&
// mHostAuthRecv.mCredential.equals(mHostAuthSend.mCredential)) {
// These two credentials are identical, use the same row. // These two credentials are identical, use the same row.
sendCredentialsIndex = recvCredentialsIndex; // sendCredentialsIndex = recvCredentialsIndex;
} else { // } else {
sendCredentialsIndex = index++; // sendCredentialsIndex = index++;
ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri) // ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri)
.withValues(mHostAuthRecv.mCredential.toContentValues()) // .withValues(mHostAuthRecv.mCredential.toContentValues())
.build()); // .build());
} // }
} // }
sendIndex = index++; sendIndex = index++;
final ContentProviderOperation.Builder b = ContentProviderOperation.newInsert( final ContentProviderOperation.Builder b = ContentProviderOperation.newInsert(
mHostAuthSend.mBaseUri); mHostAuthSend.mBaseUri);

View File

@ -68,8 +68,6 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par
public byte[] mServerCert = null; public byte[] mServerCert = null;
public long mCredentialKey; public long mCredentialKey;
public transient Credential mCredential;
public static final int CONTENT_ID_COLUMN = 0; public static final int CONTENT_ID_COLUMN = 0;
public static final int CONTENT_PROTOCOL_COLUMN = 1; public static final int CONTENT_PROTOCOL_COLUMN = 1;
public static final int CONTENT_ADDRESS_COLUMN = 2; public static final int CONTENT_ADDRESS_COLUMN = 2;
@ -96,22 +94,23 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par
} }
/** /**
* getOrCreateCredentials * getOrCreateCredential
* Return the credential object for this HostAuth, creating it if it does not yet exist. * Return the credential object for this HostAuth, creating it if it does not yet exist.
* This should not be called on the main thread. * This should not be called on the main thread.
* @param context * @param context
* @return the credential object for this HostAuth * @return the credential object for this HostAuth
*/ */
public Credential getOrCreateCredentials(Context context) { public Credential getOrCreateCredential(Context context) {
// TODO: This causes problems because it's incompatible with Exchange.
if (mCredential == null) { // if (mCredential == null) {
if (mCredentialKey >= 0) { // if (mCredentialKey >= 0) {
mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey); // mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey);
} else { // } else {
mCredential = new Credential(); // mCredential = new Credential();
} // }
} // }
return mCredential; // return mCredential;
return null;
} }
/** /**
@ -122,12 +121,14 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par
* @return * @return
*/ */
public Credential getCredentials(Context context) { public Credential getCredentials(Context context) {
if (mCredential == null) { // TODO: This causes problems because it's incompatible with Exchange.
if (mCredentialKey >= 0) { // if (mCredential == null) {
mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey); // if (mCredentialKey >= 0) {
} // mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey);
} // }
return mCredential; // }
// return mCredential;
return null;
} }
/** /**
@ -370,12 +371,13 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par
dest.writeString(mPassword); dest.writeString(mPassword);
dest.writeString(mDomain); dest.writeString(mDomain);
dest.writeString(mClientCertAlias); dest.writeString(mClientCertAlias);
dest.writeLong(mCredentialKey); // dest.writeLong(mCredentialKey);
if (mCredential == null) { // TODO: This causes problems because it's incompatible with Exchange.
Credential.EMPTY.writeToParcel(dest, flags); // if (mCredential == null) {
} else { // Credential.EMPTY.writeToParcel(dest, flags);
mCredential.writeToParcel(dest, flags); // } else {
} // mCredential.writeToParcel(dest, flags);
// }
} }
/** /**
@ -392,11 +394,11 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par
mPassword = in.readString(); mPassword = in.readString();
mDomain = in.readString(); mDomain = in.readString();
mClientCertAlias = in.readString(); mClientCertAlias = in.readString();
mCredentialKey = in.readLong(); // mCredentialKey = in.readLong();
mCredential = new Credential(in); // mCredential = new Credential(in);
if (mCredential.equals(Credential.EMPTY)) { // if (mCredential.equals(Credential.EMPTY)) {
mCredential = null; // mCredential = null;
} // }
} }
@Override @Override