diff options
author | Brad Ebinger <breadley@google.com> | 2021-03-03 13:25:44 -0800 |
---|---|---|
committer | Brad Ebinger <breadley@google.com> | 2021-03-04 02:06:28 +0000 |
commit | 3215beb9e05d661386c3e28e1d73cd548939a440 (patch) | |
tree | c305e010081f08590f2be030ed25414e015722b2 /telephony/common | |
parent | 48054e5cf49464c8e61faadce1be6797f8f40b5b (diff) |
Parse params needed for SipDelegate routing
Add getViaBranchParameter and getCallId parameter to SipMessage
API in order to allow the SipDelegate to quickly route SipMessages
without requiring the app to peak into the headers.
Bug: 181591815
Test: atest CtsTelephonyTestCases
Change-Id: Iac94f73335ac5caa634b31c10a675aaf91c13af7
Diffstat (limited to 'telephony/common')
-rw-r--r-- | telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java b/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java index c7e7cd5ec64e..179248dd2cf9 100644 --- a/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java +++ b/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java @@ -65,6 +65,11 @@ public class SipMessageParsingUtils { // compact form of the via header key private static final String VIA_SIP_HEADER_KEY_COMPACT = "v"; + // call-id header key + private static final String CALL_ID_SIP_HEADER_KEY = "call-id"; + // compact form of the call-id header key + private static final String CALL_ID_SIP_HEADER_KEY_COMPACT = "i"; + /** * @return true if the SIP message start line is considered a request (based on known request * methods). @@ -124,6 +129,17 @@ public class SipMessageParsingUtils { return null; } + /** + * Return the call-id header key's associated value. + * @param headerString The string containing the headers of the SIP message. + */ + public static String getCallId(String headerString) { + // search for the call-Id header, there should only be one in the header. + List<Pair<String, String>> headers = parseHeaders(headerString, true, + CALL_ID_SIP_HEADER_KEY, CALL_ID_SIP_HEADER_KEY_COMPACT); + return !headers.isEmpty() ? headers.get(0).second : null; + } + private static String[] splitStartLineAndVerify(String startLine) { String[] splitLine = startLine.split(" "); if (isStartLineMalformed(splitLine)) return null; |