summaryrefslogtreecommitdiffstats
path: root/provider_src
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2015-10-07 00:07:38 +0200
committerSteve Kondik <steve@cyngn.com>2015-10-18 14:06:01 -0700
commit6adbdc9f6be5ada87775918321ffdff17ba391c8 (patch)
treeef9aaa1ca07a6cdf5e3a83ba527ec6a905d3bfa4 /provider_src
parentead5cd372cbaecfa6be84cab79189b20ec88a65d (diff)
downloadandroid_packages_apps_Email-6adbdc9f6be5ada87775918321ffdff17ba391c8.tar.gz
android_packages_apps_Email-6adbdc9f6be5ada87775918321ffdff17ba391c8.tar.bz2
android_packages_apps_Email-6adbdc9f6be5ada87775918321ffdff17ba391c8.zip
email: fix empty body update
Currently, body text and html are removed from the content values to be stored as files in the filesystem. This could lead to a IllegalArgumentException because we passed an empty content value to the update operation. We must ensure that we update at least one item. Related BUGDUMP-4037330 and http://forum.cyanogenmod.org/topic/112563-massive-data-use Change-Id: Ib9ba10eb2cb86598bef6e5f8bc11553d09fc4ef8 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'provider_src')
-rw-r--r--provider_src/com/android/email/provider/EmailProvider.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/provider_src/com/android/email/provider/EmailProvider.java b/provider_src/com/android/email/provider/EmailProvider.java
index a73cbf9e3..070a3e6bc 100644
--- a/provider_src/com/android/email/provider/EmailProvider.java
+++ b/provider_src/com/android/email/provider/EmailProvider.java
@@ -2243,7 +2243,22 @@ public class EmailProvider extends ContentProvider
updateValues.remove(BodyColumns.HTML_CONTENT);
updateValues.remove(BodyColumns.TEXT_CONTENT);
- result = db.update(tableName, updateValues, selection, selectionArgs);
+ // Since we removed the html and text values from the update operation,
+ // db.update() can fail because updateValues is empty. Just to a safe check
+ // before continue, and in case check if we found at least the selection
+ // record in db and fill the result variable for later hack check.
+ if (updateValues.size() == 0) {
+ final String proj[] = {BaseColumns._ID};
+ final Cursor c = db.query(Body.TABLE_NAME, proj, selection, selectionArgs,
+ null, null, null);
+ try {
+ result = c.getCount();
+ } finally {
+ c.close();
+ }
+ } else {
+ result = db.update(tableName, updateValues, selection, selectionArgs);
+ }
if (result == 0 && selection.equals(Body.SELECTION_BY_MESSAGE_KEY)) {
// TODO: This is a hack. Notably, the selection equality test above