61 Commits

Author SHA1 Message Date
Hung-ying Tyan
a6cec8feed Synchronize SipWakeupTimer.onReceive()
to fix the race of two threads that change mPendingIntent; one assigns a new one
and the other nullifies it.

Change-Id: I5e01f83ea1ac437811d2073839adef9bd0a30ec9
2011-06-30 18:17:27 +08:00
Hung-ying Tyan
129d0b08fd Make NAT port timeout measurement more flexible.
In two ways:
(1) When there's a session timeout, restart the measurement at a later time
    instead of just stalling.
(2) When there's a port change, do not re-measure the interval if the current
    interval works well in the past. We keep success count and decrement it
    by half when there's a port change. When the count is below a threshold,
    we restart the measurement process.

Change-Id: I7256464435a5e2d2a239bfccaa004e9ceb1d9ce5
2011-06-30 14:37:24 +08:00
Hung-ying Tyan
99705b52ec Record external IP and port from SIP responses
and use them to create the contact header when sending OK response for INVITE.

Bug: 3461707
Change-Id: I5b254618f4920cf10a1460631bcd336778f344ec
2011-06-28 20:05:53 +08:00
repo sync
2093561a58 Support INVITE w/o SDP.
bug:3326873

Change-Id: Ie29d2c61b237fee2d8637f4ba3d293a22469cced
2011-06-28 19:45:10 +08:00
Hung-ying Tyan
233718c3c5 Start keepalive process for the caller of a SIP call
so that the callee can send signals (on-hold or bye) back to the caller.
Without the keepalive, the NAT port for the caller will be timed out during the
call. And the signals will be dropped by the NAT device.

Change-Id: I21848d73469045b2ed9e7281556ab184c594c362
2011-06-27 19:33:24 +08:00
repo sync
1aceda35cc Support Invite w/ Replaces request.
bug:3326870
Change-Id: Idbfbe7e3cc6ba83874d42bfb7d149866f454e70a
2011-06-27 16:20:28 +08:00
Hung-ying Tyan
e65f3a896f Restart NAT port timeout measurement when keepalive fails and other fixes
Misc keepalive fixes including:
+ Restart NAT port timeout measurement when keepalive fails. The max interval
  is set to the current keepalive interval.
+ When exception occurs during sending a keepalive, restarts registration.
+ When exception occurs during measurement, retry for a limited times before
  giving up.

Change-Id: I7aa787a5ec7c4c9b4334aa1017371d9049b3520c
2011-06-24 15:28:15 +08:00
Hung-ying Tyan
4af085ff26 Execute all the due wakeup events in SipWakeupTimer.
Events are sorted by periods. So events of larger periods may have trigger
time (i.e., when the event should be processed) earlier than the ones of smaller
periods. So need to scan the whole queue looking for due events. The scan takes
O(n) time but we expect the queue size to be small.

Change-Id: I08bd3bd9d4bb8decb78f3c91c943396463ca023a
2011-06-23 19:23:13 +08:00
Hung-ying Tyan
12750701d0 Keep the keepalive process going after NAT port is changed.
This is a regression from the CL that makes the keep-alive process a reusable
component.

Change-Id: I1d580588e9e303c532bf620056fc0fe88a2fdcda
2011-06-23 18:23:09 +08:00
Hung-ying Tyan
4a267a9158 Move the keepalive process to SipSessionImpl and make it reusable.
Reuse the new component in the original keepalive process and the NAT port
mapping timeout measurement process.

This is the foundation for fixing the following bug.

Bug: 3464181

Change-Id: If7e951c000503fa64843942ad062c4d853e20c8d
2011-06-23 11:41:37 +08:00
Hung-ying Tyan
ac320b2245 Merge "Move WakeupTimer out of SipService." 2011-06-15 03:17:50 -07:00
Hung-ying Tyan
5621554033 Move WakeupTimer out of SipService.
This is to prepare to move keepalive process to SipSessionGroup before fixing
the following bug.
Bug: 3464181

Change-Id: I57d8f6effad76706b5a76e1269c53d558db88ae4
2011-06-14 17:46:48 +08:00
repo sync
c133781723 Fix the issue of onNetwork in UI thread.
bug:458435

This will temporarily start a thread for answering calls, we are
going to add a handler thread to handle this soon.

Change-Id: I9079038d671e1b1631c6e663fc2c3de297d97428
2011-06-13 17:46:41 +08:00
Chung-yih Wang
bb0a989c17 Add KeepAlive Interval Measurement.
Change-Id: Id5ea2fcfa0bcd45198e773a5842d39eacc8ae400
2011-06-09 18:19:07 +08:00
Brad Fitzpatrick
fae5e2894f am 6f67e7bf: am 2e383bc6: Merge "Making it possible to call SIP calls with special allowed chars."
* commit '6f67e7bf831147257e078dd72a22f2e43e009122':
  Making it possible to call SIP calls with special allowed chars.
2011-03-29 08:45:30 -07:00
Magnus Strandberg
b5c72ead01 Making it possible to call SIP calls with special allowed chars.
Since String.replaceFirst uses regex and since SIP user names are
allowed to include regex charaters such as '+', the code must
fist convert the string to a literal pattern String before using
replaceFirst method.

Change-Id: I25eac852bd620724ca1c5b2befc023af9dae3c1a
2011-03-22 08:03:58 +01:00
Chung-yih Wang
fcd0e50da5 Add rport argument for a reinvite request.
bug:3461707
Change-Id: I69a4f84dde3929c754c838fd12e624b774f44826
2011-02-21 11:53:58 +08:00
Hung-ying Tyan
14b6d0620b Merge changes Ib70e0cf2,I0691cd70 into gingerbread
* changes:
  SipService: registers broadcast receivers on demand.
  SipService: release wake lock for cancelled tasks.
2011-01-24 19:41:42 -08:00
Hung-ying Tyan
f46013b672 Merge "Merge "SipService: registers broadcast receivers on demand."" into honeycomb 2011-01-18 02:25:52 -08:00
Hung-ying Tyan
e9b5407727 Merge "SipService: registers broadcast receivers on demand."
The previous implementation registers receivers when SipService starts up.
If the user doesn't use SIP at all, SipService will still process connecivity
and wifi state change events, which involves holding wake lock and thus
consumes power unnecessarily.

With this CL, SipService is completely idle if the user doesn't use SIP at all.
It registers receivers only when at least one account is opened.

Bug: 3326998
Change-Id: Idea43747f8204b0ccad3fc05a1b1c0b29c9b2557
2011-01-18 16:55:44 +08:00
Hung-ying Tyan
40f2cacbc9 Merge "SipService: release wake lock for cancelled tasks."
Bug: 3327004
Change-Id: Ice47f973b5f2969f26eaa83a3e4795b2e153ba8b
2011-01-18 16:50:56 +08:00
Chung-yih Wang
0f7de88cb9 Merge "Add auth. username in SipProfile." from gingerbread.
bug:3326867
Change-Id: Ic67dd7d4858f28224e4f01ad8b65bcd3a3c15f10
2011-01-12 11:43:27 +08:00
Chung-yih Wang
f268a2f848 Add auth. username in SipProfile.
bug:3326867
Change-Id: I2a62c75fb3f5e9c6ec2e00b29396e93b0c183d9b
2011-01-07 15:21:54 +08:00
Hung-ying Tyan
f0bb1ce70f SipService: registers broadcast receivers on demand.
The previous implementation registers receivers when SipService starts up.
If the user doesn't use SIP at all, SipService will still process connecivity
and wifi state change events, which involves holding wake lock and thus
consumes power unnecessarily.

With this CL, SipService is completely idle if the user doesn't use SIP at all.
It registers receivers only when at least one account is opened.

Bug: 3326998
Change-Id: Ib70e0cf2c808e0ebab4c3c43dcab5532d24e5eeb
2011-01-07 11:57:22 +08:00
Hung-ying Tyan
0c01e6e060 SipService: release wake lock for cancelled tasks.
Bug: 3327004
Change-Id: I0691cd70edf61f815ecb0613aca85babd89f6cc4
2011-01-06 13:05:29 +08:00
Hung-ying Tyan
a936b256eb Remove SIP realm/domain check
as the realm may be different from the domain.

Bug: 3283834
Change-Id: I64c9f0d6d626afdb397c5d378d30afa9d6a64ca9
2010-12-17 10:20:06 +08:00
Hung-ying Tyan
58ee2acba8 Check port in create peer's SIP profile.
SipURI returns port -1 when port is not present in the URI.
Don't call SipProfile.Builder.setPort() when that happens.

Bug: 3291248
Change-Id: I8e608cbc56ea82862df55fdba885f6a864db83ab
2010-12-16 20:46:50 +08:00
Chung-yih Wang
f053292d7a Fix SIP bug of different transport/port used for requests.
bug: http://b/3156148
Change-Id: I4fa5b274d2e90ebde12d9e99822dc193a65bad32
2010-12-07 10:36:19 +08:00
Hung-ying Tyan
06e8cdc0f8 Fix race between ending and answering a SIP call.
+ Also fix race between ending and changing (holding/unholding) a SIP call.
+ Remove an unused method.

Bug : 3128233

Change-Id: Ie18d8333a88f0d9906d54988243d909b58e07e4b
2010-12-01 15:02:36 +08:00
Hung-ying Tyan
4189d99b6e Do not suppress error feedback during a SIP call.
Bug: 3124788
Change-Id: Ia0a06f72336d1795515428eba0c9f875c32d13d1
2010-11-30 17:00:45 +08:00
Hung-ying Tyan
349f3509f7 Merge "Correct SipService.isOpened() implementation." into gingerbread 2010-11-30 00:56:57 -08:00
Hung-ying Tyan
262cdfca7a Correct SipService.isOpened() implementation.
Make it return true for all existing accounts.
Rename mOpened to mOpenedToReceiveCalls to make it less confusing.

Bug: 3155849
Change-Id: I327f411bf76afd73434ad1fa2ffef3db1e35d778
2010-11-02 15:17:50 +08:00
Hung-ying Tyan
5d0c5cf2d6 Notify SipSessions before closing SIP stack.
Bug: 3116480
Change-Id: I748d63382ade250aed27ccb09ea68c76a433fd27
2010-10-25 16:12:26 +08:00
Hung-ying Tyan
60c45d0269 Clean up pending sessions on incoming call in SipService
Bug: 3122186
Change-Id: I25c9aa19d138f6940a29025d54e7bc2ffb7daa29
2010-10-22 09:01:49 +08:00
Chung-yih Wang
4944fdd771 Periodically scan wifi when wifi is not connected and wifi lock is
grabbed in SipService.

bug: http://b/3077454
Change-Id: I153974325c29e0f927c8eb7fdbc4725aaf10087d
2010-10-19 14:09:30 -07:00
Hung-ying Tyan
0a6e717fb6 Handle dialing a SIP call to self.
Reply BUSY HERE response so server may redirect the call to the voice mailbox.

http://b/issue?id=3103072
http://b/issue?id=3109479

Change-Id: I81f5dd59ad87298dd9dda87084538ee460eabba8
2010-10-19 14:00:11 -07:00
Joe Onorato
431bb22695 Reduce logging.
Remember, the system and main logs are
    - Shared resources
    - Primarily for recording problems
    - To be used only for large grained events during normal operation

Bug: 3104855
Change-Id: I136fbd101917dcbc8ebc3f96f276426b48bde7b7
2010-10-19 15:08:05 -04:00
Chung-yih Wang
b4116c09fb Fix the incorrect environment variable name for the thread pool size.
bug: http://b/3099715
Change-Id: I531048414f22c8edcd9c4f815c12a0bdd6347640
2010-10-19 11:31:52 +08:00
Chung-yih Wang
66cc5355a1 Set the thread pool size of NIST sip stack to one.
Set the thread pool size to one to fix the out-of-order packets
seen in sip service when the device is waken up from sleep.

bug:http://b/3099715
Change-Id: Ia169e3fde77488068c369e3345ecf6a6d8ddf792
2010-10-18 16:00:47 +08:00
Hung-ying Tyan
28f63c0689 SipService: add wake lock for incoming INVITE packets.
+ Keep the wake lock for 500ms. (Some measurements on N1 indicate 160~180ms
  needed to bring up InCallScreen but since INVITE doesn't come in frequently
  we can be more generous just to be safe.)
+ Move MyWakeupLock out of SipService so SipSessionGroup can use it without
  awkward inter-dependency with SipService.
  + Add acquire(int timeout) to be used to create the "timed" wake lock.

http://b/issue?id=3081828

Change-Id: Iffd1d78d1a5cae9f795252ada75310917095204d
2010-10-15 09:25:17 +08:00
Hung-ying Tyan
bd57eeafe0 SipService: add wake lock for multiple components.
+ Add MyWakeLock to maintain a global wake lock for multiple components.
  + Use a Set to store components that want to hold the lock.
  + When the first component enters the set, we grab the global wake lock.
  + When the set becomes empty, we release the global lock.
  + In places like no account being opened to receive calls, we reset the
    wake lock just to be safe from possible leakage.
+ Make MyExecutor aware of the wake lock. It will grab the wake lock on
  behalf of the task so that tasks don't need to worry about the lock.
  + Connectivity receiver is modified to be executed in MyExecutor.
  + WakeupTimer handler is already protected by AlarmManager's wake lock but
    all the timeout handlers that register themselves to the WakeupTimer are
    to be executed in MyExecutor to be protected by the wake lock.
  + Remove unnecessary code in the Keepalive and registration processes. Since
    both processes are executed in MyExecutor submitted by the WakeupTimer (as
    they are timeout handlers registered to the WakeupTimer), they don't need
    to add themselves to MyExecutor explicitly in their run() callbacks.
+ Make the keepalive process wait for at most 3 seconds instead of forever for
  server response. It could cause the wake lock to be held longer than necessary
  and is a potential cause for ANR.

http://b/issue?id=3081828

Related bug:
http://b/issue?id=3087153

Change-Id: Idee0ddb837e67daa0d5092c012bb242bd7c18431
2010-10-14 16:54:47 +08:00
Hung-ying Tyan
4f8fd10f76 Make SipService listen to WIFI state change events.
+ Grab a WIFI lock if any account is opened to receive calls and WIFI is enabled
+ Release the WIFI lock if no account is opened to receive calls or WIFI is
  disabled
+ Remove screen on/off event receiver

http://b/issue?id=3077454

Change-Id: Ifdf60a850bcf4106c75ec1e7563b26d8b33d7e92
2010-10-13 17:11:58 +08:00
Hung-ying Tyan
f1b1eec9de Merge "SipService: mScreenOn is flipped to wrong value." into gingerbread 2010-10-12 19:44:17 -07:00
Hung-ying Tyan
d6fc979edb SipService: mScreenOn is flipped to wrong value.
http://b/issue?id=3077454

Change-Id: I23b6f70730074689b939e449c2c202ce8ffb586f
2010-10-13 10:25:07 +08:00
Hung-ying Tyan
ebc886c857 Fix SipSessionGroup from throwing ConcurrentModificationException
http://b/issue?id=3087256

Change-Id: I67df64105db7c1295649f1f3ce77f99025ce3d44
2010-10-12 15:41:11 +08:00
Hung-ying Tyan
685b61b711 SipService: fix a missing switch-case break.
Change-Id: I638eecd8000293d4cb37b3595c02ca33df4924eb
2010-10-12 10:46:29 +08:00
Hung-ying Tyan
692cac9fdd SipHelper: add debug log for challenge responses.
Change-Id: If0143a0f076ef30b1b8998e477df933923bfa7b1
2010-10-11 11:26:50 +08:00
Chung-yih Wang
c7fda188ae Do not release the wifi lock if the screen is off.
We need to be able to receive calls if the device is able to
reassociate with any AP later on.

Change-Id: Ib7aafb98386bf250ed9b5ec0a5b519594efa1649
2010-10-09 08:37:40 +08:00
Hung-ying Tyan
aa562ffdb8 SipService: add permission check for using API
Change-Id: Ifd85ba07f1b913011cb3e80e5027c67bfe3db280
2010-10-08 11:57:18 +08:00
Hung-ying Tyan
9db99a4dc1 Make SipService broadcast SIP_SERVICE_UP when it's up.
http://b/issue?id=3062010

Change-Id: I13419fa3a8fdfba1977260f703e4dcaa42a6606c
2010-10-07 09:15:25 +08:00