From 5fd81cad4cb328cf9882e84728886625f086114c Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 13 Oct 2009 10:51:11 -0700 Subject: [PATCH] Add truncation at 100k (EAS 2.5) and 200k (EAS 12) (#2184807) * Prevents OOM errors with huge message bodies Change-Id: Ie093215f96a514b3a1bcd31aa1f5957d1ada7719 --- src/com/android/exchange/Eas.java | 5 ++++- src/com/android/exchange/EasSyncService.java | 23 ++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/com/android/exchange/Eas.java b/src/com/android/exchange/Eas.java index 3702222fb..c005544fb 100644 --- a/src/com/android/exchange/Eas.java +++ b/src/com/android/exchange/Eas.java @@ -63,7 +63,10 @@ public class Eas { public static final String BODY_PREFERENCE_TEXT = "1"; public static final String BODY_PREFERENCE_HTML = "2"; - public static final String DEFAULT_BODY_TRUNCATION_SIZE = "50000"; + // For EAS 12, we use HTML, so we want a larger size than in EAS 2.5 + public static final String EAS12_TRUNCATION_SIZE = "200000"; + // For EAS 2.5, truncation is a code; the largest is "7", which is 100k + public static final String EAS2_5_TRUNCATION_SIZE = "7"; public static final int FOLDER_STATUS_OK = 1; public static final int FOLDER_STATUS_INVALID_KEY = 9; diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java index a60466924..cfe17e703 100644 --- a/src/com/android/exchange/EasSyncService.java +++ b/src/com/android/exchange/EasSyncService.java @@ -988,26 +988,25 @@ public class EasSyncService extends AbstractSyncService { } s.data(Tags.SYNC_WINDOW_SIZE, className.equals("Email") ? EMAIL_WINDOW_SIZE : PIM_WINDOW_SIZE); - boolean options = false; + + // Handle options + s.start(Tags.SYNC_OPTIONS); + // Set the lookback appropriately (EAS calls this a "filter") for all but Contacts if (!className.equals("Contacts")) { - // Set the lookback appropriately (EAS calls this a "filter") - s.start(Tags.SYNC_OPTIONS).data(Tags.SYNC_FILTER_TYPE, getFilterType()); - options = true; + s.data(Tags.SYNC_FILTER_TYPE, getFilterType()); } + // Set the truncation amount for all classes if (mProtocolVersionDouble >= 12.0) { - if (!options) { - options = true; - s.start(Tags.SYNC_OPTIONS); - } s.start(Tags.BASE_BODY_PREFERENCE) // HTML for email; plain text for everything else .data(Tags.BASE_TYPE, (className.equals("Email") ? Eas.BODY_PREFERENCE_HTML - : Eas.BODY_PREFERENCE_TEXT)) + : Eas.BODY_PREFERENCE_TEXT)) + .data(Tags.BASE_TRUNCATION_SIZE, Eas.EAS12_TRUNCATION_SIZE) .end(); + } else { + s.data(Tags.SYNC_TRUNCATION, Eas.EAS2_5_TRUNCATION_SIZE); } - if (options) { - s.end(); - } + s.end(); // Send our changes up to the server target.sendLocalChanges(s);