From fd81e1977954a710cd3630ef3a9ab6aebff1094c Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Mon, 21 Nov 2011 13:04:26 -0800 Subject: [PATCH] Don't save Policy with Account Change-Id: Ib3601daee8780640a07db573f623e99279c9f9b1 --- .../android/emailcommon/provider/Account.java | 17 +---------------- src/com/android/email/SecurityPolicy.java | 2 +- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/provider/Account.java b/emailcommon/src/com/android/emailcommon/provider/Account.java index 7da0d6193..89be59be2 100755 --- a/emailcommon/src/com/android/emailcommon/provider/Account.java +++ b/emailcommon/src/com/android/emailcommon/provider/Account.java @@ -762,7 +762,6 @@ public final class Account extends EmailContent implements AccountColumns, Parce int index = 0; int recvIndex = -1; int sendIndex = -1; - int policyIndex = -1; // Create operations for saving the send and recv hostAuths // Also, remember which operation in the array they represent @@ -779,12 +778,6 @@ public final class Account extends EmailContent implements AccountColumns, Parce .withValues(mHostAuthSend.toContentValues()) .build()); } - if (mPolicy != null) { - policyIndex = index++; - ops.add(ContentProviderOperation.newInsert(mPolicy.mBaseUri) - .withValues(mPolicy.toContentValues()) - .build()); - } // Create operations for making this the only default account // Note, these are always updates because they change existing accounts @@ -797,7 +790,7 @@ public final class Account extends EmailContent implements AccountColumns, Parce // Now do the Account ContentValues cv = null; - if (recvIndex >= 0 || sendIndex >= 0 || policyIndex >= 0) { + if (recvIndex >= 0 || sendIndex >= 0) { cv = new ContentValues(); if (recvIndex >= 0) { cv.put(Account.HOST_AUTH_KEY_RECV, recvIndex); @@ -805,9 +798,6 @@ public final class Account extends EmailContent implements AccountColumns, Parce if (sendIndex >= 0) { cv.put(Account.HOST_AUTH_KEY_SEND, sendIndex); } - if (policyIndex >= 0) { - cv.put(Account.POLICY_KEY, policyIndex); - } } ContentProviderOperation.Builder b = ContentProviderOperation.newInsert(mBaseUri); @@ -831,11 +821,6 @@ public final class Account extends EmailContent implements AccountColumns, Parce mHostAuthKeySend = newId; mHostAuthSend.mId = newId; } - if (policyIndex >= 0) { - long newId = getId(results[policyIndex].uri); - mPolicyKey = newId; - mPolicy.mId = newId; - } Uri u = results[index].uri; mId = getId(u); return u; diff --git a/src/com/android/email/SecurityPolicy.java b/src/com/android/email/SecurityPolicy.java index 71793a028..94a0a6de6 100644 --- a/src/com/android/email/SecurityPolicy.java +++ b/src/com/android/email/SecurityPolicy.java @@ -564,7 +564,7 @@ public class SecurityPolicy { if (account.mPolicyKey > 0) { oldPolicy = Policy.restorePolicyWithId(mContext, account.mPolicyKey); } - boolean policyChanged = !oldPolicy.equals(policy); + boolean policyChanged = (oldPolicy == null) || !oldPolicy.equals(policy); if (!policyChanged && (TextUtilities.stringOrNullEquals(securityKey, account.mSecuritySyncKey))) { Log.d(Logging.LOG_TAG, "setAccountPolicy; policy unchanged");