diff options
author | Chia-chi Yeh <chiachi@android.com> | 2011-08-30 13:58:35 -0700 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2011-08-30 13:59:11 -0700 |
commit | 5f760064e1975a50e4abb63e560731c8b2c7b56c (patch) | |
tree | 4fab26d7e7cc53ad2da7fa21ba0e16d47c0a2858 /voip | |
parent | fbc4fe3e329285b17f2586c81d6894355dd32b12 (diff) | |
download | frameworks_base-5f760064e1975a50e4abb63e560731c8b2c7b56c.zip frameworks_base-5f760064e1975a50e4abb63e560731c8b2c7b56c.tar.gz frameworks_base-5f760064e1975a50e4abb63e560731c8b2c7b56c.tar.bz2 |
SIP: add the check for expiry time in Contact header.
There can be three expiry times in the same message header. We
choose the smaller value in Expires header and Contact header,
and then we obey the value defined in Min-Expires header. If
none of them is set, the default value is used.
Bug: 5178284
Change-Id: Ie9d4a48c93863e82e5197bb4a0db3f4fec56857c
Diffstat (limited to 'voip')
-rw-r--r-- | voip/java/com/android/server/sip/SipSessionGroup.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/voip/java/com/android/server/sip/SipSessionGroup.java b/voip/java/com/android/server/sip/SipSessionGroup.java index 3b3cbf3..49effa8 100644 --- a/voip/java/com/android/server/sip/SipSessionGroup.java +++ b/voip/java/com/android/server/sip/SipSessionGroup.java @@ -72,6 +72,7 @@ import javax.sip.TransactionUnavailableException; import javax.sip.address.Address; import javax.sip.address.SipURI; import javax.sip.header.CSeqHeader; +import javax.sip.header.ContactHeader; import javax.sip.header.ExpiresHeader; import javax.sip.header.FromHeader; import javax.sip.header.HeaderAddress; @@ -873,16 +874,21 @@ class SipSessionGroup implements SipListener { } private int getExpiryTime(Response response) { - int expires = EXPIRY_TIME; - ExpiresHeader expiresHeader = (ExpiresHeader) - response.getHeader(ExpiresHeader.NAME); - if (expiresHeader != null) expires = expiresHeader.getExpires(); - expiresHeader = (ExpiresHeader) - response.getHeader(MinExpiresHeader.NAME); - if (expiresHeader != null) { - expires = Math.max(expires, expiresHeader.getExpires()); - } - return expires; + int time = -1; + ContactHeader contact = (ContactHeader) response.getHeader(ContactHeader.NAME); + if (contact != null) { + time = contact.getExpires(); + } + ExpiresHeader expires = (ExpiresHeader) response.getHeader(ExpiresHeader.NAME); + if (expires != null && (time < 0 || time > expires.getExpires())) { + time = expires.getExpires(); + } + expires = (ExpiresHeader) response.getHeader(MinExpiresHeader.NAME); + if (expires != null && time < expires.getExpires()) { + time = expires.getExpires(); + } + Log.v(TAG, "Expiry time = " + time); + return (time > 0) ? time : EXPIRY_TIME; } private boolean registeringToReady(EventObject evt) |