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
2 files changed