Parse recipients from RESPOND_VIA_MESSAGE correctly am: fcf6699742 am: 4e646c4948 am: 1efb769573 am: 5729626c46
Change-Id: I556a102be2007103462a588f448fdab6375b8e5f
This commit is contained in:
@@ -100,12 +100,6 @@
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="sms" />
|
||||
<data android:scheme="smsto" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.intent.action.SENDTO" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="mms" />
|
||||
<data android:scheme="mmsto" />
|
||||
</intent-filter>
|
||||
@@ -423,6 +417,8 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="sms" />
|
||||
<data android:scheme="smsto" />
|
||||
<data android:scheme="mms" />
|
||||
<data android:scheme="mmsto" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ import com.android.messaging.datamodel.action.InsertNewMessageAction;
|
||||
import com.android.messaging.datamodel.action.UpdateMessageNotificationAction;
|
||||
import com.android.messaging.datamodel.data.MessageData;
|
||||
import com.android.messaging.datamodel.data.ParticipantData;
|
||||
import com.android.messaging.sms.MmsUtils;
|
||||
import com.android.messaging.ui.UIIntents;
|
||||
import com.android.messaging.ui.conversationlist.ConversationListActivity;
|
||||
import com.android.messaging.util.LogUtil;
|
||||
import com.android.messaging.util.UriUtil;
|
||||
|
||||
/**
|
||||
* Respond to a special intent and send an SMS message without the user's intervention, unless
|
||||
@@ -83,8 +83,8 @@ public class NoConfirmationSmsSendService extends IntentService {
|
||||
final String subject = getText(intent, Intent.EXTRA_SUBJECT);
|
||||
final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID);
|
||||
|
||||
final Uri intentUri = intent.getData();
|
||||
final String recipients = intentUri != null ? MmsUtils.getSmsRecipients(intentUri) : null;
|
||||
// Get a comma-separated list of recipients
|
||||
final String recipients = UriUtil.parseRecipientsFromSmsMmsUri(intent.getData());
|
||||
|
||||
if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) {
|
||||
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
||||
|
||||
@@ -1111,37 +1111,6 @@ public class MmsUtils {
|
||||
return subject;
|
||||
}
|
||||
|
||||
// return a semicolon separated list of phone numbers from a smsto: uri.
|
||||
public static String getSmsRecipients(final Uri uri) {
|
||||
String recipients = uri.getSchemeSpecificPart();
|
||||
final int pos = recipients.indexOf('?');
|
||||
if (pos != -1) {
|
||||
recipients = recipients.substring(0, pos);
|
||||
}
|
||||
recipients = replaceUnicodeDigits(recipients).replace(',', ';');
|
||||
return recipients;
|
||||
}
|
||||
|
||||
// This function was lifted from Telephony.PhoneNumberUtils because it was @hide
|
||||
/**
|
||||
* Replace arabic/unicode digits with decimal digits.
|
||||
* @param number
|
||||
* the number to be normalized.
|
||||
* @return the replaced number.
|
||||
*/
|
||||
private static String replaceUnicodeDigits(final String number) {
|
||||
final StringBuilder normalizedDigits = new StringBuilder(number.length());
|
||||
for (final char c : number.toCharArray()) {
|
||||
final int digit = Character.digit(c, 10);
|
||||
if (digit != -1) {
|
||||
normalizedDigits.append(digit);
|
||||
} else {
|
||||
normalizedDigits.append(c);
|
||||
}
|
||||
}
|
||||
return normalizedDigits.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the data roaming is enabled
|
||||
*/
|
||||
|
||||
@@ -61,7 +61,12 @@ public class LaunchConversationActivity extends Activity implements
|
||||
final Intent intent = getIntent();
|
||||
final String action = intent.getAction();
|
||||
if (Intent.ACTION_SENDTO.equals(action) || Intent.ACTION_VIEW.equals(action)) {
|
||||
String[] recipients = UriUtil.parseRecipientsFromSmsMmsUri(intent.getData());
|
||||
String[] recipients = null;
|
||||
final String commaSeparatedRecipients =
|
||||
UriUtil.parseRecipientsFromSmsMmsUri(intent.getData());
|
||||
if (commaSeparatedRecipients != null) {
|
||||
recipients = commaSeparatedRecipients.split(",");
|
||||
}
|
||||
final boolean haveAddress = !TextUtils.isEmpty(intent.getStringExtra(ADDRESS));
|
||||
final boolean haveEmail = !TextUtils.isEmpty(intent.getStringExtra(Intent.EXTRA_EMAIL));
|
||||
if (recipients == null && (haveAddress || haveEmail)) {
|
||||
|
||||
@@ -324,14 +324,13 @@ public class UriUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract recipient destinations from Uri of form
|
||||
* SCHEME:destionation[,destination]?otherstuff
|
||||
* Extract recipient destinations from Uri of form SCHEME:destination[,destination]?otherstuff
|
||||
* where SCHEME is one of the supported sms/mms schemes.
|
||||
*
|
||||
* @param uri sms/mms uri
|
||||
* @return recipient destinations or null
|
||||
* @return a comma-separated list of recipient destinations or null.
|
||||
*/
|
||||
public static String[] parseRecipientsFromSmsMmsUri(final Uri uri) {
|
||||
public static String parseRecipientsFromSmsMmsUri(final Uri uri) {
|
||||
if (!isSmsMmsUri(uri)) {
|
||||
return null;
|
||||
}
|
||||
@@ -341,7 +340,7 @@ public class UriUtil {
|
||||
}
|
||||
// replaceUnicodeDigits will replace digits typed in other languages (i.e. Egyptian) with
|
||||
// the usual ascii equivalents.
|
||||
return TextUtil.replaceUnicodeDigits(parts[0]).replace(';', ',').split(",");
|
||||
return TextUtil.replaceUnicodeDigits(parts[0]).replace(';', ',');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user