summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshwini Munigala <AshwiniM@codeaurora.org>2014-09-29 11:59:44 +0530
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:26:16 -0700
commit89239e80ddb01e01445de13318d8c888d424d0ce (patch)
treeb02d6f59773d7f7e337b89fdf39c4742d1edd547
parentd4d4b642999ff3716ca78cb94010c13f8fe42f93 (diff)
downloadandroid_packages_apps_Bluetooth-89239e80ddb01e01445de13318d8c888d424d0ce.tar.gz
android_packages_apps_Bluetooth-89239e80ddb01e01445de13318d8c888d424d0ce.tar.bz2
android_packages_apps_Bluetooth-89239e80ddb01e01445de13318d8c888d424d0ce.zip
MAP: Modify fetch MessageSize email to get emailBody storage file size
Email App Implementation moved email body parts storage to files instead of direct db entries. Modify MessageSize email to fetch contentURI and calculate size of corresponding files from Email db. Change-Id: I6176485e4c2fe95b8310fd8316d8b14f347f88e1 CRs-fixed: 731435
-rw-r--r--src/com/android/bluetooth/map/BluetoothMapContent.java115
1 files changed, 73 insertions, 42 deletions
diff --git a/src/com/android/bluetooth/map/BluetoothMapContent.java b/src/com/android/bluetooth/map/BluetoothMapContent.java
index f496c3391..d60fb4af0 100644
--- a/src/com/android/bluetooth/map/BluetoothMapContent.java
+++ b/src/com/android/bluetooth/map/BluetoothMapContent.java
@@ -667,24 +667,50 @@ public class BluetoothMapContent {
size = subject.length();
} else if (fi.msgType == FilterInfo.TYPE_MMS) {
size = c.getInt(c.getColumnIndex(Mms.MESSAGE_SIZE));
- } else {
+ } else if (fi.msgType == FilterInfo.TYPE_EMAIL) {
long msgId = Long.valueOf(c.getString(c.getColumnIndex("_id")));
- String[] EMAIL_MSGSIZE_PROJECTION = new String[] { "LENGTH(textContent)", "LENGTH(htmlContent)" };
String textContent, htmlContent;
- Uri uri = Uri.parse("content://com.android.email.provider/body");
- String where = setWhereFilterMessagekey(msgId);
- Cursor cr = mResolver.query(
- uri, EMAIL_MSGSIZE_PROJECTION, where , null, null);
+ Uri uriAddress = Uri.parse("content://com.android.email.provider/body");
+ Cursor cr = mResolver.query(uriAddress,
+ Body.CONTENT_PROJECTION, BodyColumns.MESSAGE_KEY + "=?",
+ new String[] {String.valueOf(msgId)}, null);
if (cr != null && cr.moveToFirst()) {
- do {
- size = cr.getInt(0);
- if(size == -1 || size == 0)
- size = cr.getInt(1);
- break;
- } while (cr.moveToNext());
- }
- if (cr != null) {
- cr.close();
+ ParcelFileDescriptor fd = null;
+ String textContentURI = cr.getString(cr.getColumnIndex(
+ BodyColumns.TEXT_CONTENT_URI));
+ if (textContentURI != null ) {
+ try {
+ Log.v(TAG, " TRY EMAIL BODY textURI " + textContentURI);
+ fd = mResolver.openFileDescriptor(Uri.parse(textContentURI), "r");
+ } catch (FileNotFoundException ex) {
+ if(V) Log.w(TAG, ex);
+ }
+ }
+ if(fd == null ) {
+ String htmlContentURI = cr.getString(cr.getColumnIndex(
+ BodyColumns.HTML_CONTENT_URI));
+ if (htmlContentURI != null ) {
+ try {
+ Log.v(TAG, " TRY EMAIL BODY htmlURI " + htmlContentURI);
+ fd = mResolver.openFileDescriptor(Uri.parse(htmlContentURI), "r");
+ } catch (FileNotFoundException ex) {
+ if(V) Log.w(TAG, ex);
+ }
+ }
+ }
+ if(fd != null ) {
+ //Size in bytes
+ size = (Long.valueOf(fd.getStatSize()).intValue());
+ try {
+ fd.close();
+ } catch (IOException ex) {
+ if(V) Log.w(TAG, ex);
+ }
+
+ } else {
+ Log.e(TAG, "MessageSize Email NOT AVAILABLE");
+ }
+ cr.close();
}
}
if (D) Log.d(TAG, "setSize: " + size);
@@ -1996,7 +2022,6 @@ public class BluetoothMapContent {
private void extractEmailParts(long id, BluetoothMapbMessageMmsEmail message)
{
if (V) Log.v(TAG, "extractEmailParts with id " + id);
- String where = setWhereFilterMessagekey(id);
String emailBody = "";
Uri uriAddress = Uri.parse("content://com.android.email.provider/body");
BluetoothMapbMessageMmsEmail.MimePart part;
@@ -2021,34 +2046,40 @@ public class BluetoothMapContent {
}
// GET FD to parse text or HTML content
ParcelFileDescriptor fd = null;
- try {
- Log.v(TAG, " TRY EMAIL BODY textURI " + textContentURI);
- fd = mResolver.openFileDescriptor(Uri.parse(textContentURI), "r");
- } catch (FileNotFoundException e) {
- Log.w(TAG, e);
+ if(textContentURI != null ) {
+ try {
+ Log.v(TAG, " TRY EMAIL BODY textURI " + textContentURI);
+ fd = mResolver.openFileDescriptor(Uri.parse(textContentURI), "r");
+ } catch (FileNotFoundException e) {
+ if(V) Log.w(TAG, e);
+ }
}
if(fd == null ) {
- //Try HTML content if TEXT CONTENT NULL
- try {
- Log.v(TAG, " TRY EMAIL BODY htmlURI " + htmlContentURI);
- fd = mResolver.openFileDescriptor(Uri.parse(htmlContentURI), "r");
- } catch (FileNotFoundException e) {
- Log.w(TAG, e);
- } catch (NullPointerException e) {
- Log.w(TAG, e);
- }
- String msgBody = readEmailBodyForMessageFd(fd);
- if (msgBody != null) {
- msgBody = msgBody.replaceAll("(?s)(<title>)(.*?)(</title>)", "");
- msgBody = msgBody.replaceAll("(?s)(<style type=\"text/css\".*?>)(.*?)(</style>)", "");
- CharSequence msgText = Html.fromHtml(msgBody);
- emailBody = msgText.toString();
- emailBody = emailBody.replaceAll("(?s)(<!--)(.*?)(-->)", "");
- // Solves problem with Porche Car-kit and Gmails.
- // Changes unix style line conclusion to DOS style
- emailBody = emailBody.replaceAll("(?s)(\\r)", "");
- emailBody = emailBody.replaceAll("(?s)(\\n)", "\r\n");
- }
+ if(htmlContentURI != null ) {
+ //Try HTML content if TEXT CONTENT NULL
+ try {
+ Log.v(TAG, " TRY EMAIL BODY htmlURI " + htmlContentURI);
+ fd = mResolver.openFileDescriptor(Uri.parse(htmlContentURI), "r");
+ } catch (FileNotFoundException e) {
+ if(V) Log.w(TAG, e);
+ } catch (NullPointerException e) {
+ if(V) Log.w(TAG, e);
+ }
+ String msgBody = readEmailBodyForMessageFd(fd);
+ if (msgBody != null) {
+ msgBody = msgBody.replaceAll("(?s)(<title>)(.*?)(</title>)", "");
+ msgBody = msgBody.replaceAll("(?s)(<style type=\"text/css\".*?>)(.*?)(</style>)", "");
+ CharSequence msgText = Html.fromHtml(msgBody);
+ emailBody = msgText.toString();
+ emailBody = emailBody.replaceAll("(?s)(<!--)(.*?)(-->)", "");
+ // Solves problem with Porche Car-kit and Gmails.
+ // Changes unix style line conclusion to DOS style
+ emailBody = emailBody.replaceAll("(?s)(\\r)", "");
+ emailBody = emailBody.replaceAll("(?s)(\\n)", "\r\n");
+ }
+ } else {
+ Log.w(TAG, " FETCH Email BODY File HTML URI FAILED");
+ }
} else {
emailBody = readEmailBodyForMessageFd(fd);
}