From 05723aa0f642fbbffd8859dce8181601576e245b Mon Sep 17 00:00:00 2001 From: Martin Hibdon Date: Tue, 10 Dec 2013 17:12:00 -0800 Subject: [PATCH] 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 --- .../android/emailcommon/provider/Account.java | 36 ++++++----- .../emailcommon/provider/HostAuth.java | 62 ++++++++++--------- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/provider/Account.java b/emailcommon/src/com/android/emailcommon/provider/Account.java index 18e37b255..71cea58b3 100755 --- a/emailcommon/src/com/android/emailcommon/provider/Account.java +++ b/emailcommon/src/com/android/emailcommon/provider/Account.java @@ -742,12 +742,13 @@ public final class Account extends EmailContent implements AccountColumns, Parce // Also, remember which operation in the array they represent ArrayList ops = new ArrayList(); if (mHostAuthRecv != null) { - if (mHostAuthRecv.mCredential != null) { - recvCredentialsIndex = index++; - ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri) - .withValues(mHostAuthRecv.mCredential.toContentValues()) - .build()); - } + // TODO: This causes problems because it's incompatible with Exchange. +// if (mHostAuthRecv.mCredential != null) { +// recvCredentialsIndex = index++; +// ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri) +// .withValues(mHostAuthRecv.mCredential.toContentValues()) +// .build()); +// } recvIndex = index++; final ContentProviderOperation.Builder b = ContentProviderOperation.newInsert( @@ -761,18 +762,19 @@ public final class Account extends EmailContent implements AccountColumns, Parce ops.add(b.build()); } if (mHostAuthSend != null) { - if (mHostAuthSend.mCredential != null) { - if (mHostAuthRecv.mCredential != null && - mHostAuthRecv.mCredential.equals(mHostAuthSend.mCredential)) { + // TODO: This causes problems because it's incompatible with Exchange. +// if (mHostAuthSend.mCredential != null) { +// if (mHostAuthRecv.mCredential != null && +// mHostAuthRecv.mCredential.equals(mHostAuthSend.mCredential)) { // These two credentials are identical, use the same row. - sendCredentialsIndex = recvCredentialsIndex; - } else { - sendCredentialsIndex = index++; - ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri) - .withValues(mHostAuthRecv.mCredential.toContentValues()) - .build()); - } - } +// sendCredentialsIndex = recvCredentialsIndex; +// } else { +// sendCredentialsIndex = index++; +// ops.add(ContentProviderOperation.newInsert(mHostAuthRecv.mCredential.mBaseUri) +// .withValues(mHostAuthRecv.mCredential.toContentValues()) +// .build()); +// } +// } sendIndex = index++; final ContentProviderOperation.Builder b = ContentProviderOperation.newInsert( mHostAuthSend.mBaseUri); diff --git a/emailcommon/src/com/android/emailcommon/provider/HostAuth.java b/emailcommon/src/com/android/emailcommon/provider/HostAuth.java index 8c822a392..a221fc527 100644 --- a/emailcommon/src/com/android/emailcommon/provider/HostAuth.java +++ b/emailcommon/src/com/android/emailcommon/provider/HostAuth.java @@ -68,8 +68,6 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par public byte[] mServerCert = null; public long mCredentialKey; - public transient Credential mCredential; - public static final int CONTENT_ID_COLUMN = 0; public static final int CONTENT_PROTOCOL_COLUMN = 1; 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. * This should not be called on the main thread. * @param context * @return the credential object for this HostAuth */ - public Credential getOrCreateCredentials(Context context) { - - if (mCredential == null) { - if (mCredentialKey >= 0) { - mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey); - } else { - mCredential = new Credential(); - } - } - return mCredential; + public Credential getOrCreateCredential(Context context) { + // TODO: This causes problems because it's incompatible with Exchange. +// if (mCredential == null) { +// if (mCredentialKey >= 0) { +// mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey); +// } else { +// mCredential = new Credential(); +// } +// } +// return mCredential; + return null; } /** @@ -122,12 +121,14 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par * @return */ public Credential getCredentials(Context context) { - if (mCredential == null) { - if (mCredentialKey >= 0) { - mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey); - } - } - return mCredential; + // TODO: This causes problems because it's incompatible with Exchange. +// if (mCredential == null) { +// if (mCredentialKey >= 0) { +// mCredential = Credential.restoreCredentialsWithId(context, mCredentialKey); +// } +// } +// return mCredential; + return null; } /** @@ -370,12 +371,13 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par dest.writeString(mPassword); dest.writeString(mDomain); dest.writeString(mClientCertAlias); - dest.writeLong(mCredentialKey); - if (mCredential == null) { - Credential.EMPTY.writeToParcel(dest, flags); - } else { - mCredential.writeToParcel(dest, flags); - } +// dest.writeLong(mCredentialKey); + // TODO: This causes problems because it's incompatible with Exchange. +// if (mCredential == null) { +// Credential.EMPTY.writeToParcel(dest, flags); +// } else { +// mCredential.writeToParcel(dest, flags); +// } } /** @@ -392,11 +394,11 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par mPassword = in.readString(); mDomain = in.readString(); mClientCertAlias = in.readString(); - mCredentialKey = in.readLong(); - mCredential = new Credential(in); - if (mCredential.equals(Credential.EMPTY)) { - mCredential = null; - } +// mCredentialKey = in.readLong(); +// mCredential = new Credential(in); +// if (mCredential.equals(Credential.EMPTY)) { +// mCredential = null; +// } } @Override