fix bug 2100169: add the line1 number + "/TYPE=PLMN" when sending a pdu.

Change-Id: I289b81118006bf146d94384f91d4b0fa5215ec46
diff --git a/core/java/com/google/android/mms/pdu/GenericPdu.java b/core/java/com/google/android/mms/pdu/GenericPdu.java
index 46c6e00..705de6a 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 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 094e992..8b31936 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 @@
         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 @@
 
                 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 @@
 
                     // 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 0a4dbf0..880e3ac 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 @@
     }
 
     /**
-     * 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 9ea6e47..597cd00 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 @@
     }
 
     /**
-     * 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