From 3215beb9e05d661386c3e28e1d73cd548939a440 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Wed, 3 Mar 2021 13:25:44 -0800 Subject: 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 --- .../internal/telephony/SipMessageParsingUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'telephony/common') 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> 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; -- cgit v1.2.3