summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Allen Su <allenwtsu@google.com> 2021-04-07 03:28:38 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-04-07 03:28:38 +0000
commit823b97e3d1d53a7490aa8b3161b9575f2e7cf622 (patch)
tree93cfcd83e785d2cfa1f200710ac76d9d7cc0fb77
parentf473395dd19e04df7ede7ff1f52282251a9c3102 (diff)
parentbb05a111042033154b89dcd98a7e70430d994223 (diff)
Merge "Change SipMessage API name" am: bb05a11104
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1657802 Change-Id: I3f3315e48071972373cff7b7acb666a34cd7e635
-rw-r--r--core/api/system-current.txt3
-rw-r--r--telephony/java/android/telephony/ims/SipMessage.java24
2 files changed, 26 insertions, 1 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index e6624cdb865a..eebf2831eafc 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -11985,10 +11985,11 @@ package android.telephony.ims {
method public int describeContents();
method @Nullable public String getCallIdParameter();
method @NonNull public byte[] getContent();
- method @NonNull public byte[] getEncodedMessage();
+ method @Deprecated @NonNull public byte[] getEncodedMessage();
method @NonNull public String getHeaderSection();
method @NonNull public String getStartLine();
method @NonNull public String getViaBranchParameter();
+ method @NonNull public byte[] toEncodedMessage();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ims.SipMessage> CREATOR;
}
diff --git a/telephony/java/android/telephony/ims/SipMessage.java b/telephony/java/android/telephony/ims/SipMessage.java
index b5295637d4dd..d21fcab264d3 100644
--- a/telephony/java/android/telephony/ims/SipMessage.java
+++ b/telephony/java/android/telephony/ims/SipMessage.java
@@ -204,7 +204,9 @@ public final class SipMessage implements Parcelable {
/**
* @return the UTF-8 encoded SIP message.
+ * @deprecated Use {@link #toEncodedMessage} instead
*/
+ @Deprecated
public @NonNull byte[] getEncodedMessage() {
byte[] header = new StringBuilder()
.append(mStartLine)
@@ -216,4 +218,26 @@ public final class SipMessage implements Parcelable {
System.arraycopy(mContent, 0, sipMessage, header.length, mContent.length);
return sipMessage;
}
+
+ /**
+ * According RFC-3261 section 7, SIP is a text protocol and uses the UTF-8 charset. Its format
+ * consists of a start-line, one or more header fields, an empty line indicating the end of the
+ * header fields, and an optional message-body.
+ *
+ * <p>
+ * Returns a byte array with UTF-8 format representation of the encoded SipMessage.
+ *
+ * @return byte array with UTF-8 format representation of the encoded SipMessage.
+ */
+ public @NonNull byte[] toEncodedMessage() {
+ byte[] header = new StringBuilder()
+ .append(mStartLine)
+ .append(mHeaderSection)
+ .append(CRLF)
+ .toString().getBytes(UTF_8);
+ byte[] sipMessage = new byte[header.length + mContent.length];
+ System.arraycopy(header, 0, sipMessage, 0, header.length);
+ System.arraycopy(mContent, 0, sipMessage, header.length, mContent.length);
+ return sipMessage;
+ }
}