summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-04-28 02:51:42 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-04-28 02:51:42 +0000
commit6ac55087072e7d6c461c14025624d8493f5329a9 (patch)
treec97af28ba52ada3c2513848a058a04903de290ca
parenta344e94edace8291d86592e849333c76d2547e80 (diff)
parentad03a4a1726716b7a79bf717ff1ad97775b3cc26 (diff)
Merge "Expose parsing util methods for telephony validation" am: 5092ae8c8b am: 2bf2f964d7 am: ad03a4a172
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1665959 Change-Id: I9116d44ad96ac2a4af5631541c6b27fe1813c81d
-rw-r--r--telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java18
-rw-r--r--telephony/java/android/telephony/ims/SipDelegateManager.java9
2 files changed, 23 insertions, 4 deletions
diff --git a/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java b/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java
index 179248dd2cf9..33b0bbd23086 100644
--- a/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java
+++ b/telephony/common/com/android/internal/telephony/SipMessageParsingUtils.java
@@ -81,6 +81,15 @@ public class SipMessageParsingUtils {
}
/**
+ * @return true if the SIP message start line is considered a response.
+ */
+ public static boolean isSipResponse(String startLine) {
+ String[] splitLine = splitStartLineAndVerify(startLine);
+ if (splitLine == null) return false;
+ return verifySipResponse(splitLine);
+ }
+
+ /**
* Return the via branch parameter, which is used to identify the transaction ID (request and
* response pair) in a SIP transaction.
* @param headerString The string containing the headers of the SIP message.
@@ -140,7 +149,12 @@ public class SipMessageParsingUtils {
return !headers.isEmpty() ? headers.get(0).second : null;
}
- private static String[] splitStartLineAndVerify(String startLine) {
+ /**
+ * Validate that the start line is correct and split into its three segments.
+ * @param startLine The start line to verify and split.
+ * @return The split start line, which will always have three segments.
+ */
+ public static String[] splitStartLineAndVerify(String startLine) {
String[] splitLine = startLine.split(" ");
if (isStartLineMalformed(splitLine)) return null;
return splitLine;
@@ -184,7 +198,7 @@ public class SipMessageParsingUtils {
* (This is internally an equalsIgnoreMatch comparison).
* @return the matched header keys and values.
*/
- private static List<Pair<String, String>> parseHeaders(String headerString,
+ public static List<Pair<String, String>> parseHeaders(String headerString,
boolean stopAtFirstMatch, String... matchingHeaderKeys) {
// Ensure there is no leading whitespace
headerString = removeLeadingWhitespace(headerString);
diff --git a/telephony/java/android/telephony/ims/SipDelegateManager.java b/telephony/java/android/telephony/ims/SipDelegateManager.java
index aa2e6b94c1f7..a504c9ab1190 100644
--- a/telephony/java/android/telephony/ims/SipDelegateManager.java
+++ b/telephony/java/android/telephony/ims/SipDelegateManager.java
@@ -81,13 +81,18 @@ public class SipDelegateManager {
public static final int MESSAGE_FAILURE_REASON_DELEGATE_CLOSED = 2;
/**
- * The SIP message has an invalid start line and the message can not be sent.
+ * The SIP message has an invalid start line and the message can not be sent or the start line
+ * failed validation due to the request containing a restricted SIP request method.
+ * {@link SipDelegateConnection}s can not send SIP requests for the methods: REGISTER, PUBLISH,
+ * or OPTIONS.
*/
public static final int MESSAGE_FAILURE_REASON_INVALID_START_LINE = 3;
/**
* One or more of the header fields in the header section of the outgoing SIP message is invalid
- * and the SIP message can not be sent.
+ * or contains a restricted header value and the SIP message can not be sent.
+ * {@link SipDelegateConnection}s can not send SIP SUBSCRIBE requests for the "Event" header
+ * value of "presence".
*/
public static final int MESSAGE_FAILURE_REASON_INVALID_HEADER_FIELDS = 4;