Parse recipients from RESPOND_VIA_MESSAGE correctly am: fcf6699742
Change-Id: Ie293c1c84489e4a1f20972bc056f6d2af67b79b4
This commit is contained in:
+2
-6
@@ -100,12 +100,6 @@
|
|||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<data android:scheme="sms" />
|
<data android:scheme="sms" />
|
||||||
<data android:scheme="smsto" />
|
<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="mms" />
|
||||||
<data android:scheme="mmsto" />
|
<data android:scheme="mmsto" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -423,6 +417,8 @@
|
|||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:scheme="sms" />
|
<data android:scheme="sms" />
|
||||||
<data android:scheme="smsto" />
|
<data android:scheme="smsto" />
|
||||||
|
<data android:scheme="mms" />
|
||||||
|
<data android:scheme="mmsto" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ import com.android.messaging.datamodel.action.InsertNewMessageAction;
|
|||||||
import com.android.messaging.datamodel.action.UpdateMessageNotificationAction;
|
import com.android.messaging.datamodel.action.UpdateMessageNotificationAction;
|
||||||
import com.android.messaging.datamodel.data.MessageData;
|
import com.android.messaging.datamodel.data.MessageData;
|
||||||
import com.android.messaging.datamodel.data.ParticipantData;
|
import com.android.messaging.datamodel.data.ParticipantData;
|
||||||
import com.android.messaging.sms.MmsUtils;
|
|
||||||
import com.android.messaging.ui.UIIntents;
|
import com.android.messaging.ui.UIIntents;
|
||||||
import com.android.messaging.ui.conversationlist.ConversationListActivity;
|
import com.android.messaging.ui.conversationlist.ConversationListActivity;
|
||||||
import com.android.messaging.util.LogUtil;
|
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
|
* 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 String subject = getText(intent, Intent.EXTRA_SUBJECT);
|
||||||
final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID);
|
final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID);
|
||||||
|
|
||||||
final Uri intentUri = intent.getData();
|
// Get a comma-separated list of recipients
|
||||||
final String recipients = intentUri != null ? MmsUtils.getSmsRecipients(intentUri) : null;
|
final String recipients = UriUtil.parseRecipientsFromSmsMmsUri(intent.getData());
|
||||||
|
|
||||||
if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) {
|
if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) {
|
||||||
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
||||||
|
|||||||
@@ -1111,37 +1111,6 @@ public class MmsUtils {
|
|||||||
return subject;
|
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
|
* @return Whether the data roaming is enabled
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,7 +61,12 @@ public class LaunchConversationActivity extends Activity implements
|
|||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (Intent.ACTION_SENDTO.equals(action) || Intent.ACTION_VIEW.equals(action)) {
|
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 haveAddress = !TextUtils.isEmpty(intent.getStringExtra(ADDRESS));
|
||||||
final boolean haveEmail = !TextUtils.isEmpty(intent.getStringExtra(Intent.EXTRA_EMAIL));
|
final boolean haveEmail = !TextUtils.isEmpty(intent.getStringExtra(Intent.EXTRA_EMAIL));
|
||||||
if (recipients == null && (haveAddress || haveEmail)) {
|
if (recipients == null && (haveAddress || haveEmail)) {
|
||||||
|
|||||||
@@ -324,14 +324,13 @@ public class UriUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract recipient destinations from Uri of form
|
* Extract recipient destinations from Uri of form SCHEME:destination[,destination]?otherstuff
|
||||||
* SCHEME:destionation[,destination]?otherstuff
|
|
||||||
* where SCHEME is one of the supported sms/mms schemes.
|
* where SCHEME is one of the supported sms/mms schemes.
|
||||||
*
|
*
|
||||||
* @param uri sms/mms uri
|
* @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)) {
|
if (!isSmsMmsUri(uri)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -341,7 +340,7 @@ public class UriUtil {
|
|||||||
}
|
}
|
||||||
// replaceUnicodeDigits will replace digits typed in other languages (i.e. Egyptian) with
|
// replaceUnicodeDigits will replace digits typed in other languages (i.e. Egyptian) with
|
||||||
// the usual ascii equivalents.
|
// the usual ascii equivalents.
|
||||||
return TextUtil.replaceUnicodeDigits(parts[0]).replace(';', ',').split(",");
|
return TextUtil.replaceUnicodeDigits(parts[0]).replace(';', ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user