Fix speaker not restored during call hold toggle.

In CallAudioManager, the logic for audio states during a call
are dependent on held call being retained as a foreground call
for retaining speaker state. If the foreground call becomes null,
then audio focus is abandoned. Due to this, the state of speaker
being on is lost.

In CallsManager logic for updating foreground call, the
foreground call becomes null in certain cases. First case is when
there is a single call in Held State. Second case is in certain
states such as a active and held call, when the active call is put
on hold to swap with the held call, both the calls are in held state
during an intermediate stage. At this point the current logic will
make the foreground call as none.

There are 2 fixes. First, if the only call in Calls Manager is a
held call, retain that as a foreground call. Second, if the
foreground call is going to be updated to null and there exists
atleast one call in held state in Calls Manager, do not update
the foreground call to null.

Ideally, we would like to fix the logic in CallsAudioManager, but
since this might be more risk we will tweak the logic for
foreground call to satisfy the limitation in CallsAudioManager.

Change-Id: I22d4042bd04fc14460cedec5523323402e63ac98
CRs-Fixed: 932840
1 file changed