summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Taylor <tomtaylor@google.com>2012-09-06 10:56:32 -0700
committerTom Taylor <tomtaylor@google.com>2012-09-06 10:56:32 -0700
commitca239ab55759fae4b16823329d5f03a52829ff4d (patch)
tree49bbb2c9720cb12f0114cbee0e0816f4b74a07c4 /src
parent553d4e88137b162515524d0a86fbc88c685e6b7d (diff)
downloadMms-ca239ab55759fae4b16823329d5f03a52829ff4d.tar.gz
On receiving a Group MMS the List view displays as two messages received
Bug 7081327 When an mms is sent, the first thing that is received is an mms notification message. This message only contains the address of the sender and not all the other addresses the message was additionally sent to. The messaging app stores this message in a new thread (if there isn't an existing one) of the sender's phone number. Then if the mms auto download setting is turned on (the default), the app will use the information in this notification message to download the content of the message. The app will then receive an mms retrieve confirmation message. This message contains the full addresses of all those in the group conversation. The app then creates (if there isn't an existing one) a thread made up of all the addresses. Then it deletes the original mms notification message. At this point, you see two two threads for the same message. This CL fixes the problem by not creating a thread for notification_ind messages when autodownload is enabled. Messages will show up when they're completely downloaded. Change-Id: If515f134026bafaa2256673de1cff89976df8f59
Diffstat (limited to 'src')
-rw-r--r--src/com/android/mms/transaction/NotificationTransaction.java24
-rw-r--r--src/com/android/mms/transaction/PushReceiver.java7
-rw-r--r--src/com/android/mms/ui/ComposeMessageActivity.java2
3 files changed, 28 insertions, 5 deletions
diff --git a/src/com/android/mms/transaction/NotificationTransaction.java b/src/com/android/mms/transaction/NotificationTransaction.java
index 83b0fb15..5404243b 100644
--- a/src/com/android/mms/transaction/NotificationTransaction.java
+++ b/src/com/android/mms/transaction/NotificationTransaction.java
@@ -32,6 +32,7 @@ import android.content.Context;
import android.database.sqlite.SqliteWrapper;
import android.net.Uri;
import android.provider.Telephony.Mms;
+import android.provider.Telephony.Threads;
import android.provider.Telephony.Mms.Inbox;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -106,8 +107,10 @@ public class NotificationTransaction extends Transaction implements Runnable {
super(context, serviceId, connectionSettings);
try {
+ // Save the pdu. If we can start downloading the real pdu immediately, don't allow
+ // persist() to create a thread for the notificationInd because it causes UI jank.
mUri = PduPersister.getPduPersister(context).persist(
- ind, Inbox.CONTENT_URI);
+ ind, Inbox.CONTENT_URI, !allowAutoDownload());
} catch (MmsException e) {
Log.e(TAG, "Failed to save NotificationInd in constructor.", e);
throw new IllegalArgumentException();
@@ -126,11 +129,17 @@ public class NotificationTransaction extends Transaction implements Runnable {
new Thread(this, "NotificationTransaction").start();
}
- public void run() {
+ public static boolean allowAutoDownload() {
DownloadManager downloadManager = DownloadManager.getInstance();
boolean autoDownload = downloadManager.isAuto();
boolean dataSuspended = (MmsApp.getApplication().getTelephonyManager().getDataState() ==
TelephonyManager.DATA_SUSPENDED);
+ return autoDownload && !dataSuspended;
+ }
+
+ public void run() {
+ DownloadManager downloadManager = DownloadManager.getInstance();
+ boolean autoDownload = allowAutoDownload();
try {
if (LOCAL_LOGV) {
Log.v(TAG, "Notification transaction launched: " + this);
@@ -141,7 +150,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
// download a MM immediately.
int status = STATUS_DEFERRED;
// Don't try to download when data is suspended, as it will fail, so defer download
- if (!autoDownload || dataSuspended) {
+ if (!autoDownload) {
downloadManager.markState(mUri, DownloadManager.STATE_UNSTARTED);
sendNotifyRespInd(status);
return;
@@ -184,6 +193,13 @@ public class NotificationTransaction extends Transaction implements Runnable {
// M-NotifyResp.ind from Inbox.
SqliteWrapper.delete(mContext, mContext.getContentResolver(),
mUri, null, null);
+ if (LOCAL_LOGV) {
+ Log.v(TAG, "NotificationTransaction deleting obsolete threads");
+ }
+ // Delete obsolete threads
+ SqliteWrapper.delete(mContext, mContext.getContentResolver(),
+ Threads.OBSOLETE_THREADS_URI, null, null);
+
// Notify observers with newly received MM.
mUri = uri;
status = STATUS_RETRIEVED;
@@ -216,7 +232,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
Log.e(TAG, Log.getStackTraceString(t));
} finally {
mTransactionState.setContentUri(mUri);
- if (!autoDownload || dataSuspended) {
+ if (!autoDownload) {
// Always mark the transaction successful for deferred
// download since any error here doesn't make sense.
mTransactionState.setState(SUCCESS);
diff --git a/src/com/android/mms/transaction/PushReceiver.java b/src/com/android/mms/transaction/PushReceiver.java
index ebed8fb3..b09573f7 100644
--- a/src/com/android/mms/transaction/PushReceiver.java
+++ b/src/com/android/mms/transaction/PushReceiver.java
@@ -117,7 +117,12 @@ public class PushReceiver extends BroadcastReceiver {
}
if (!isDuplicateNotification(mContext, nInd)) {
- Uri uri = p.persist(pdu, Inbox.CONTENT_URI);
+ // Save the pdu. If we can start downloading the real pdu immediately,
+ // don't allow persist() to create a thread for the notificationInd
+ // because it causes UI jank.
+ Uri uri = p.persist(pdu, Inbox.CONTENT_URI,
+ !NotificationTransaction.allowAutoDownload());
+
// Start service to finish the notification transaction.
Intent svc = new Intent(mContext, TransactionService.class);
svc.putExtra(TransactionBundle.URI, uri.toString());
diff --git a/src/com/android/mms/ui/ComposeMessageActivity.java b/src/com/android/mms/ui/ComposeMessageActivity.java
index a4495576..9aaff362 100644
--- a/src/com/android/mms/ui/ComposeMessageActivity.java
+++ b/src/com/android/mms/ui/ComposeMessageActivity.java
@@ -1948,6 +1948,8 @@ public class ComposeMessageActivity extends Activity
// recipient editor rather than in the message editor.
mRecipientsEditor.requestFocus();
}
+
+ mMsgListAdapter.setIsGroupConversation(mConversation.getRecipients().size() > 1);
}
@Override