Merge "[RCS]Add getEncodedMessage() in SipMessage.java" am: 725e04e4f1 am: d5253e5321
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1554295 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ic6272bf2debe4430ac9cde2e2a7a85f7f943ee62
This commit is contained in:
@@ -11880,6 +11880,7 @@ package android.telephony.ims {
|
|||||||
ctor public SipMessage(@NonNull String, @NonNull String, @NonNull byte[]);
|
ctor public SipMessage(@NonNull String, @NonNull String, @NonNull byte[]);
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
method @NonNull public byte[] getContent();
|
method @NonNull public byte[] getContent();
|
||||||
|
method @NonNull public byte[] getEncodedMessage();
|
||||||
method @NonNull public String getHeaderSection();
|
method @NonNull public String getHeaderSection();
|
||||||
method @NonNull public String getStartLine();
|
method @NonNull public String getStartLine();
|
||||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package android.telephony.ims;
|
package android.telephony.ims;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -39,6 +41,7 @@ import java.util.Objects;
|
|||||||
public final class SipMessage implements Parcelable {
|
public final class SipMessage implements Parcelable {
|
||||||
// Should not be set to true for production!
|
// Should not be set to true for production!
|
||||||
private static final boolean IS_DEBUGGING = Build.IS_ENG;
|
private static final boolean IS_DEBUGGING = Build.IS_ENG;
|
||||||
|
private static final String CRLF = "\r\n";
|
||||||
|
|
||||||
private final String mStartLine;
|
private final String mStartLine;
|
||||||
private final String mHeaderSection;
|
private final String mHeaderSection;
|
||||||
@@ -165,4 +168,19 @@ public final class SipMessage implements Parcelable {
|
|||||||
result = 31 * result + Arrays.hashCode(mContent);
|
result = 31 * result + Arrays.hashCode(mContent);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the UTF-8 encoded SIP message.
|
||||||
|
*/
|
||||||
|
public @NonNull byte[] getEncodedMessage() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user