Merge commit 'e2886eebee1759509602bf391ff7087279115c6b' into eclair-sholes-release
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 102e92b..f9b433c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -199,6 +199,9 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
+ <action android:name="android.intent.action.SERVICE_STATE" />
+ </intent-filter>
+ <intent-filter>
<action android:name="com.android.mms.transaction.MESSAGE_SENT" />
<!-- TODO Do a better data match here. -->
<data android:scheme="content" />
diff --git a/src/com/android/mms/data/WorkingMessage.java b/src/com/android/mms/data/WorkingMessage.java
index 4c3e76a..8c131fc 100644
--- a/src/com/android/mms/data/WorkingMessage.java
+++ b/src/com/android/mms/data/WorkingMessage.java
@@ -797,18 +797,18 @@
mConversation = conv;
// Convert to MMS if there are any email addresses in the recipient list.
- setHasEmail(conv.getRecipients().containsEmail(), false);
+ setHasEmail(conv.getRecipients().containsEmail());
}
/**
* Hint whether or not this message will be delivered to an
* an email address.
*/
- public void setHasEmail(boolean hasEmail, boolean notify) {
+ public void setHasEmail(boolean hasEmail) {
if (MmsConfig.getEmailGateway() != null) {
- updateState(RECIPIENTS_REQUIRE_MMS, false, notify);
+ updateState(RECIPIENTS_REQUIRE_MMS, false, true);
} else {
- updateState(RECIPIENTS_REQUIRE_MMS, hasEmail, notify);
+ updateState(RECIPIENTS_REQUIRE_MMS, hasEmail, true);
}
}
diff --git a/src/com/android/mms/transaction/SmsReceiver.java b/src/com/android/mms/transaction/SmsReceiver.java
index 8c70dff..6d8ab2b 100644
--- a/src/com/android/mms/transaction/SmsReceiver.java
+++ b/src/com/android/mms/transaction/SmsReceiver.java
@@ -31,14 +31,6 @@
public class SmsReceiver extends BroadcastReceiver {
static final Object mStartingServiceSync = new Object();
static PowerManager.WakeLock mStartingService;
- private static SmsReceiver sInstance;
-
- public static SmsReceiver getInstance() {
- if (sInstance == null) {
- sInstance = new SmsReceiver();
- }
- return sInstance;
- }
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/src/com/android/mms/transaction/SmsReceiverService.java b/src/com/android/mms/transaction/SmsReceiverService.java
index f3e094d..59cc688 100644
--- a/src/com/android/mms/transaction/SmsReceiverService.java
+++ b/src/com/android/mms/transaction/SmsReceiverService.java
@@ -35,7 +35,6 @@
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.database.Cursor;
import android.net.Uri;
import android.os.Handler;
@@ -186,7 +185,6 @@
}
public synchronized void sendFirstQueuedMessage() {
- boolean success = true;
// get all the queued messages from the database
final Uri uri = Uri.parse("content://sms/queued");
ContentResolver resolver = getContentResolver();
@@ -194,6 +192,7 @@
SEND_PROJECTION, null, null, "date ASC"); // date ASC so we send out in
// same order the user tried
// to send messages.
+
if (c != null) {
try {
if (c.moveToFirst()) {
@@ -219,7 +218,6 @@
} catch (MmsException e) {
Log.e(TAG, "sendFirstQueuedMessage: failed to send message " + msgUri
+ ", caught ", e);
- success = false;
} finally {
// Since sendMessage adds a new message to the outbox rather than
// moving the old one, the old one must be deleted here
@@ -235,17 +233,15 @@
c.close();
}
}
- if (success) {
- // We successfully sent all the messages in the queue. We don't need to
- // be notified of any service changes any longer.
- unRegisterForServiceStateChanges();
- }
}
private void handleSmsSent(Intent intent) {
Uri uri = intent.getData();
if (mResultCode == Activity.RESULT_OK) {
+ if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
+ Log.v(TAG, "handleSmsSent sending uri: " + uri);
+ }
if (!Sms.moveMessageToFolder(this, uri, Sms.MESSAGE_TYPE_SENT)) {
Log.e(TAG, "handleSmsSent: failed to move message " + uri + " to sent folder");
}
@@ -258,11 +254,6 @@
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "handleSmsSent: no service, queuing message w/ uri: " + uri);
}
- // We got an error with no service or no radio. Register for state changes so
- // when the status of the connection/radio changes, we can try to send the
- // queued up messages.
- registerForServiceStateChanges();
- // We couldn't send the message, put in the queue to retry later.
Sms.moveMessageToFolder(this, uri, Sms.MESSAGE_TYPE_QUEUED);
mToastHandler.sendEmptyMessage(1);
} else {
@@ -473,31 +464,6 @@
context.startActivity(smsDialogIntent);
}
- private void registerForServiceStateChanges() {
- Context context = getApplicationContext();
- unRegisterForServiceStateChanges();
-
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
- if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
- Log.v(TAG, "registerForServiceStateChanges");
- }
-
- context.registerReceiver(SmsReceiver.getInstance(), intentFilter);
- }
-
- private void unRegisterForServiceStateChanges() {
- if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
- Log.v(TAG, "unRegisterForServiceStateChanges");
- }
- try {
- Context context = getApplicationContext();
- context.unregisterReceiver(SmsReceiver.getInstance());
- } catch (IllegalArgumentException e) {
- // Allow un-matched register-unregister calls
- }
- }
-
}
diff --git a/src/com/android/mms/ui/ComposeMessageActivity.java b/src/com/android/mms/ui/ComposeMessageActivity.java
index 2eb4dd7..e6cec9c 100644
--- a/src/com/android/mms/ui/ComposeMessageActivity.java
+++ b/src/com/android/mms/ui/ComposeMessageActivity.java
@@ -549,7 +549,7 @@
}
mWorkingMessage.setWorkingRecipients(mRecipientsEditor.getNumbers());
- mWorkingMessage.setHasEmail(mRecipientsEditor.containsEmail(), true);
+ mWorkingMessage.setHasEmail(mRecipientsEditor.containsEmail());
checkForTooManyRecipients();