summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorallu.haribabu <allu.haribabu@gmail.com>2016-05-04 18:02:51 +0530
committerSteve Kondik <steve@cyngn.com>2016-08-28 20:43:01 -0700
commit8bbbc98239e12f521fdc4a7ad73115a415361ed4 (patch)
tree39bd313abed332c805b1b6255fff445a3ee3aa07
parentebada54422b89dbf023f782c8a45d5c522c3dfe5 (diff)
downloadandroid_packages_apps_Messaging-8bbbc98239e12f521fdc4a7ad73115a415361ed4.tar.gz
android_packages_apps_Messaging-8bbbc98239e12f521fdc4a7ad73115a415361ed4.tar.bz2
android_packages_apps_Messaging-8bbbc98239e12f521fdc4a7ad73115a415361ed4.zip
Phone did not receives Mms delivery report message
MMS delivery report is receiving when MMS delivery report is enabled but UI is not handled to let the user know.So UI display is handled Bug: FEIJ-130 Change-Id: Ie6611d45102590da7f985e4f05c78eefb1205cf2
-rw-r--r--src/com/android/messaging/sms/MmsUtils.java86
1 files changed, 85 insertions, 1 deletions
diff --git a/src/com/android/messaging/sms/MmsUtils.java b/src/com/android/messaging/sms/MmsUtils.java
index 4f5d223..b819fc4 100644
--- a/src/com/android/messaging/sms/MmsUtils.java
+++ b/src/com/android/messaging/sms/MmsUtils.java
@@ -26,11 +26,13 @@ import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
+import android.database.DatabaseUtils;
import android.media.MediaMetadataRetriever;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
+import android.provider.BaseColumns;
import android.provider.Settings;
import android.provider.Telephony;
import android.provider.Telephony.Mms;
@@ -45,12 +47,17 @@ import android.text.util.Rfc822Tokenizer;
import com.android.messaging.Factory;
import com.android.messaging.R;
+import com.android.messaging.datamodel.BugleDatabaseOperations;
+import com.android.messaging.datamodel.DataModel;
import com.android.messaging.datamodel.MediaScratchFileProvider;
import com.android.messaging.datamodel.action.DownloadMmsAction;
import com.android.messaging.datamodel.action.SendMessageAction;
import com.android.messaging.datamodel.data.MessageData;
import com.android.messaging.datamodel.data.MessagePartData;
import com.android.messaging.datamodel.data.ParticipantData;
+import com.android.messaging.datamodel.DatabaseHelper;
+import com.android.messaging.datamodel.DatabaseWrapper;
+import com.android.messaging.datamodel.MessagingContentProvider;
import com.android.messaging.mmslib.InvalidHeaderValueException;
import com.android.messaging.mmslib.MmsException;
import com.android.messaging.mmslib.SqliteWrapper;
@@ -58,6 +65,8 @@ import com.android.messaging.mmslib.pdu.CharacterSets;
import com.android.messaging.mmslib.pdu.EncodedStringValue;
import com.android.messaging.mmslib.pdu.GenericPdu;
import com.android.messaging.mmslib.pdu.NotificationInd;
+import com.android.messaging.mmslib.pdu.ReadOrigInd;
+import com.android.messaging.mmslib.pdu.DeliveryInd;
import com.android.messaging.mmslib.pdu.PduBody;
import com.android.messaging.mmslib.pdu.PduComposer;
import com.android.messaging.mmslib.pdu.PduHeaders;
@@ -2318,8 +2327,68 @@ public class MmsUtils {
final int type = pdu.getMessageType();
Uri messageUri = null;
+ long threadId = -1;
switch (type) {
- case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
+ case PduHeaders.MESSAGE_TYPE_DELIVERY_IND: {
+ long localId = -1;
+ String messageId = new String(((DeliveryInd) pdu).getMessageId());
+ //Update Telephony DB
+ Cursor cursor = getCursorFromMessageId(context, messageId);
+ if (cursor != null) {
+ try {
+ if ((cursor.getCount() == 1) && cursor.moveToFirst()) {
+ threadId = cursor.getLong(cursor.getColumnIndex(Mms.THREAD_ID));
+ localId = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID));
+ }
+ } finally {
+ cursor.close();
+ }
+ }
+ if (threadId == -1 || localId == -1) {
+ // The associated SendReq isn't found, therefore skip
+ // processing this PDU.
+ break;
+ }
+ Uri inboxUri = null;
+ try {
+ inboxUri = p.persist(pdu, Mms.Inbox.CONTENT_URI, subId, subPhoneNumber,
+ null);
+ // Update thread ID for ReadOrigInd & DeliveryInd.
+ ContentValues values = new ContentValues(1);
+ values.put(Mms.THREAD_ID, threadId);
+ SqliteWrapper.update(context, context.getContentResolver(), inboxUri, values,
+ null, null);
+ } catch (final MmsException e) {
+ LogUtil.e(TAG, "Failed to save the data from PUSH: type=" + type, e);
+ }
+ // Update local message
+ final DatabaseWrapper db = DataModel.get().getDatabase();
+ db.beginTransaction();
+ try {
+ int status = ((DeliveryInd) pdu).getStatus();
+ if (status == PduHeaders.STATUS_RETRIEVED ||
+ status == PduHeaders.STATUS_FORWARDED) {
+ final ContentValues values = new ContentValues();
+ status = MessageData.BUGLE_STATUS_OUTGOING_DELIVERED;
+ values.put(DatabaseHelper.MessageColumns.STATUS, status);
+ Uri mUri = Uri.withAppendedPath(Mms.CONTENT_URI, String.valueOf(localId));
+ final MessageData messageData =
+ BugleDatabaseOperations.readMessageData(db, mUri);
+ // Check the message was not removed before the delivery report comes in
+ if (messageData != null) {
+ // Row must exist as was just loaded above (on ActionService thread)
+ BugleDatabaseOperations.updateMessageRow(db, messageData.getMessageId(),
+ values);
+ MessagingContentProvider.notifyMessagesChanged(
+ messageData.getConversationId());
+ }
+ db.setTransactionSuccessful();
+ }
+ } finally {
+ db.endTransaction();
+ }
+ break;
+ }
case PduHeaders.MESSAGE_TYPE_READ_ORIG_IND: {
// TODO: Should this be commented out?
// threadId = findThreadId(context, pdu, type);
@@ -2403,6 +2472,21 @@ public class MmsUtils {
return mms;
}
+ private static Cursor getCursorFromMessageId(Context context, String messageId) {
+ StringBuilder sb = new StringBuilder('(');
+ sb.append(Mms.MESSAGE_ID);
+ sb.append('=');
+ sb.append(DatabaseUtils.sqlEscapeString(messageId));
+ sb.append(" AND ");
+ sb.append(Mms.MESSAGE_TYPE);
+ sb.append('=');
+ sb.append(PduHeaders.MESSAGE_TYPE_SEND_REQ);
+ Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
+ Mms.CONTENT_URI, new String[]{BaseColumns._ID, Mms.THREAD_ID},
+ sb.toString(), null, null);
+ return cursor;
+ }
+
public static Uri insertSendingMmsMessage(final Context context, final List<String> recipients,
final MessageData content, final int subId, final String subPhoneNumber,
final long timestamp) {