Correct issues with answer/unhold call auto-disconnect.

Telecom will occasionally need to disconnect an ongoing call either:
1. If there is a new incoming call which is answered and the current
ongoing call cannot be held.
2. There is an ongoing call which must be held so another call can be
unheld and the ongoing call cannot be held.

This does not happen often in practice, however there are some cases
involving emergency calls and the RemoteConnectionService API which could
be a problem.
Since an emergency call bypasses the RemoteConnectionService it will be
hosted directly by the TelephonyConnectionService.  Regular calls which
take place at the same time will be hosted by the connection manager via
the RemoteConnectionService API.

In the case of an ongoing e-call and a received call via a connection mgr,
answering the received call would cause the e-call to be disconnected
since it cannot be held.

There is an implicit assumption made in the code that concurrent calls
which are from the same ConnectionService don't need to be dropped in the
above answering or swapping scenarios because it is assumed that the
ConnectionService will handle that logic by itself.

The old logic to determine which calls were part of the "same connection
service" was flawed because it looks only at the ConnectionServiceWrapper
which is associated with each call.  In reality, the Call's target phone
account is a more reliable indicator.  More specifically, the package
name associated with the target phone account.  If there are concurrent
calls which target the same connection service package, the auto drop
logic should not take place.

As a final safety measure, fallbacks are added to ensure that an emergency
call will never be dropped.
In the case of answering an incoming call on a different ConnectionService
where there is an active e-call, the incoming call will instead be
rejected instead of answered.
In the case of swapping from an active e-call to a held non-ecall on a
different ConnectionService, the request is ignored rather than dropping
the e-call.

Test: Added new unit tests for these scenarios.
Test: Manual carrier calling test with simulated e-calls.
Fixes: 129505115
Change-Id: Icc272c53e9b70a9acf54c6836c0a20aa56cc4e75
4 files changed