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>
This commit is contained in:
parent
ead5cd372c
commit
6adbdc9f6b
@ -2243,7 +2243,22 @@ public class EmailProvider extends ContentProvider
|
||||
updateValues.remove(BodyColumns.HTML_CONTENT);
|
||||
updateValues.remove(BodyColumns.TEXT_CONTENT);
|
||||
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user