Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ad27bdd authored by Shriram Ganesh's avatar Shriram Ganesh Committed by Gerrit - the friendly Code Review server
Browse files

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
parent a9fd04f9
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1575,6 +1575,11 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
                    break;
                }

                // If only call in call list is held call it's also a foreground call
                if (mCalls.size() == 1 && call.getState() == CallState.ON_HOLD) {
                    newForegroundCall = call;
                }

                if ((call.isAlive() && call.getState() != CallState.ON_HOLD)
                     || call.getState() == CallState.RINGING) {
                    newForegroundCall = call;
@@ -1603,6 +1608,11 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
                    break;
                }

                // If only call in call list is held call it's also a foreground call
                if (mCalls.size() == 1 && call.getState() == CallState.ON_HOLD) {
                    newForegroundCall = call;
                }

                if ((call.isAlive() && call.getState() != CallState.ON_HOLD)
                     || call.getState() == CallState.RINGING) {
                    newForegroundCall = call;
@@ -1611,6 +1621,16 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
            }
        }

        /* In the case where there are 2 calls, when the Hold button is pressed for active
         * call, as an intermediate state we would have both calls in held state before
         * the background call is moved to active state. In such an intermediate stage
         * updating the newForegroundCall to null causes issues with abandoning audio
         * focus. Skip updating the foreground call with null in such cases. */
        if (newForegroundCall == null && getFirstCallWithState(CallState.ON_HOLD) != null) {
            Log.v(this, "Skip updating foreground call in intermediate stage");
            newForegroundCall = mForegroundCall;
        }

        if (newForegroundCall != mForegroundCall) {
            Log.v(this, "Updating foreground call, %s -> %s.", mForegroundCall, newForegroundCall);
            Call oldForegroundCall = mForegroundCall;