Cherripick from master CL 79833, 79417, 78864, 80332, 87500
Add new audio mode and recording source for audio communications
other than telelphony.
The audio mode MODE_IN_CALL signals the system the device a phone
call is currently underway. There was no way for audio video
chat or VoIP applications to signal a call is underway, but not
using the telephony resources. This change introduces a new mode
to address this. Changes in other parts of the system (java
and native) are required to take this new mode into account.
The generic AudioPolicyManager is updated to not use its phone
state variable directly, but to use two new convenience methods,
isInCall() and isStateInCall(int) instead.
Add a recording source used to designate a recording stream for
voice communications such as VoIP.
Update the platform-independent audio policy manager to pass the
nature of the audio recording source to the audio policy client
interface through the AudioPolicyClientInterface::setParameters()
method.
SIP calls should set the audio mode to MODE_IN_COMMUNICATION,
Audio mode MODE_IN_CALL is reserved for telephony.
SIP: Enable built-in echo canceler if available.
1. Always initialize AudioRecord with VOICE_COMMUNICATION.
2. If echo canceler is available, disable our echo suppressor.
Note that this CL is intentionally not correcting the
getAudioSourceMax() return value in MediaRecorder.java as the
new source is hidden here.
Change-Id: Ie68cd03c50553101aa2ad838fe9459b2cf151bc8
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
Originally a stream does not send packets when it is receive-only or there is
nothing to mix. However, this causes some problems with certain firewalls and
proxies. A firewall might remove a port mapping when there is no outgoing
packet for a preiod of time, and a proxy might wait for incoming packets from
both sides before start forwarding. To solve these problems, we send out a
silence packet on the stream for every second. It should be good enough to
keep the stream alive with relatively low resources.
Bug: 3119690
Change-Id: Ib9c55e5dddfba28928bd9b376832b68bda24c0e4
This is to make SipManager.isVoipSupported() effective.
Also add NPE check now that we may return null SipAudioCall when VOIP is not
supported.
Bug: 3251016
Change-Id: Icd551123499f55eef190743b90980922893c4a13
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
+ Also fix race between ending and changing (holding/unholding) a SIP call.
+ Remove an unused method.
Bug : 3128233
Change-Id: Ie18d8333a88f0d9906d54988243d909b58e07e4b
instead of silently returning null and causing NPE in applications as returning
null is not documented in the javadoc.
Add connection to the connection list in SipCall after dial() succeeds so that
we don't need to clean up if it fails. The original code will cause the failed
connection to continue to live in the SipCall and in next dial() attempt, a new
connection is created and the in-call screen sees two connections in the call
and thus shows conference call UI.
Bug: 3157234, 3157387
Change-Id: Iabc3235f781c4f1e09384a67ad56b09ad2c12e5e
Make it return true for all existing accounts.
Rename mOpened to mOpenedToReceiveCalls to make it less confusing.
Bug: 3155849
Change-Id: I327f411bf76afd73434ad1fa2ffef3db1e35d778
Rewrite using integer arithmetic to get full 32-bit precision instead
of 23-bit in single precision floating-points.
Bug: 3029745
Change-Id: If67dcc403923755f403d08bbafb41ebce26e4e8b
(watch out auto-merge conflict for SipAudioCall).
Bug: 3113033, related CL: https://android-git/g/#change,75185
Change-Id: Ib48d3b990e229e0b341e47e10e76934e1a50d10f
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
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
+ 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
+ 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
+ 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
Add a retry count and give up after two attempts.
Also stop auto registration when server is unreachable.
And rename onError() to restartLater() for better readability.
http://b/issue?id=3066573
Change-Id: Icfa65c58546a1e2bf8e59e29584a3926c53c479b