summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/google/android/mms/pdu/GenericPdu.java21
-rw-r--r--core/java/com/google/android/mms/pdu/PduComposer.java48
-rw-r--r--core/java/com/google/android/mms/pdu/ReadRecInd.java21
-rw-r--r--core/java/com/google/android/mms/pdu/SendReq.java21
4 files changed, 53 insertions, 58 deletions
diff --git a/core/java/com/google/android/mms/pdu/GenericPdu.java b/core/java/com/google/android/mms/pdu/GenericPdu.java
index 46c6e008e5b6..705de6afb8b6 100644
--- a/core/java/com/google/android/mms/pdu/GenericPdu.java
+++ b/core/java/com/google/android/mms/pdu/GenericPdu.java
@@ -89,4 +89,25 @@ public class GenericPdu {
public void setMmsVersion(int value) throws InvalidHeaderValueException {
mPduHeaders.setOctet(value, PduHeaders.MMS_VERSION);
}
+
+ /**
+ * Get From value.
+ * From-value = Value-length
+ * (Address-present-token Encoded-string-value | Insert-address-token)
+ *
+ * @return the value
+ */
+ public EncodedStringValue getFrom() {
+ return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
+ }
+
+ /**
+ * Set From value.
+ *
+ * @param value the value
+ * @throws NullPointerException if the value is null.
+ */
+ public void setFrom(EncodedStringValue value) {
+ mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
+ }
}
diff --git a/core/java/com/google/android/mms/pdu/PduComposer.java b/core/java/com/google/android/mms/pdu/PduComposer.java
index 094e992e64da..8b31936f609e 100644
--- a/core/java/com/google/android/mms/pdu/PduComposer.java
+++ b/core/java/com/google/android/mms/pdu/PduComposer.java
@@ -450,6 +450,29 @@ public class PduComposer {
appendQuotedString(str.getBytes());
}
+ private EncodedStringValue appendAddressType(EncodedStringValue address) {
+ EncodedStringValue temp = null;
+
+ try {
+ int addressType = checkAddressType(address.getString());
+ temp = EncodedStringValue.copy(address);
+ if (PDU_PHONE_NUMBER_ADDRESS_TYPE == addressType) {
+ // Phone number.
+ temp.appendTextString(STRING_PHONE_NUMBER_ADDRESS_TYPE.getBytes());
+ } else if (PDU_IPV4_ADDRESS_TYPE == addressType) {
+ // Ipv4 address.
+ temp.appendTextString(STRING_IPV4_ADDRESS_TYPE.getBytes());
+ } else if (PDU_IPV6_ADDRESS_TYPE == addressType) {
+ // Ipv6 address.
+ temp.appendTextString(STRING_IPV6_ADDRESS_TYPE.getBytes());
+ }
+ } catch (NullPointerException e) {
+ return null;
+ }
+
+ return temp;
+ }
+
/**
* Append header to mMessage.
*/
@@ -489,21 +512,8 @@ public class PduComposer {
EncodedStringValue temp;
for (int i = 0; i < addr.length; i++) {
- try {
- int addressType = checkAddressType(addr[i].getString());
- temp = EncodedStringValue.copy(addr[i]);
- if (PDU_PHONE_NUMBER_ADDRESS_TYPE == addressType) {
- // Phone number.
- temp.appendTextString(
- STRING_PHONE_NUMBER_ADDRESS_TYPE.getBytes());
- } else if (PDU_IPV4_ADDRESS_TYPE == addressType) {
- // Ipv4 address.
- temp.appendTextString(STRING_IPV4_ADDRESS_TYPE.getBytes());
- } else if (PDU_IPV6_ADDRESS_TYPE == addressType) {
- // Ipv6 address.
- temp.appendTextString(STRING_IPV6_ADDRESS_TYPE.getBytes());
- }
- } catch (NullPointerException e) {
+ temp = appendAddressType(addr[i]);
+ if (temp == null) {
return PDU_COMPOSE_CONTENT_ERROR;
}
@@ -530,7 +540,13 @@ public class PduComposer {
// Address-present-token = <Octet 128>
append(PduHeaders.FROM_ADDRESS_PRESENT_TOKEN);
- appendEncodedString(from);
+
+ temp = appendAddressType(from);
+ if (temp == null) {
+ return PDU_COMPOSE_CONTENT_ERROR;
+ }
+
+ appendEncodedString(temp);
int flen = fstart.getLength();
mStack.pop();
diff --git a/core/java/com/google/android/mms/pdu/ReadRecInd.java b/core/java/com/google/android/mms/pdu/ReadRecInd.java
index 0a4dbf097eba..880e3ac3ddd4 100644
--- a/core/java/com/google/android/mms/pdu/ReadRecInd.java
+++ b/core/java/com/google/android/mms/pdu/ReadRecInd.java
@@ -73,27 +73,6 @@ public class ReadRecInd extends GenericPdu {
}
/**
- * Get From value.
- * From-value = Value-length
- * (Address-present-token Encoded-string-value | Insert-address-token)
- *
- * @return the value
- */
- public EncodedStringValue getFrom() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
- }
-
- /**
- * Set From value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setFrom(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
- }
-
- /**
* Get Message-ID value.
*
* @return the value
diff --git a/core/java/com/google/android/mms/pdu/SendReq.java b/core/java/com/google/android/mms/pdu/SendReq.java
index 9ea6e471382c..597cd00b9961 100644
--- a/core/java/com/google/android/mms/pdu/SendReq.java
+++ b/core/java/com/google/android/mms/pdu/SendReq.java
@@ -226,27 +226,6 @@ public class SendReq extends MultimediaMessagePdu {
}
/**
- * Get From value.
- * From-value = Value-length
- * (Address-present-token Encoded-string-value | Insert-address-token)
- *
- * @return the value
- */
- public EncodedStringValue getFrom() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
- }
-
- /**
- * Set From value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setFrom(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
- }
-
- /**
* Get X-Mms-Message-Class value.
* Message-class-value = Class-identifier | Token-text
* Class-identifier = Personal | Advertisement | Informational | Auto