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

Commit 669f90b7 authored by Roshan Pius's avatar Roshan Pius
Browse files

Abandon audioFocus only when all the calls are disconnected.

Due to the change in ag/757925 to abandonAudioFocus when the foreground
call is in disconnected state, we end up prematurely abandoning audio
focus for IMS conference scenarios. When IMS conference is created
first, we disconnect the foreground call before creating the new IMS
conference call. This results in us abandoning audio focus and
reinitializing it when the conference call is created. In this scenario,
there should be a background call which is not in DISCONNECTED state.
So, redo the if check to see if there is any non-DISCONNECTED call in
CallsManager before we abandon audio focus.

BUG: 23759265
Change-Id: I97dc614c6b805a0dff19b063806d8d036f3d894f
parent aad82da8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1667,4 +1667,13 @@ public class Call implements CreateConnectionResponse {
        }
        return CallState.DISCONNECTED;
    }

    /**
     * Determines if this call is in disconnected state and waiting to be destroyed.
     *
     * @return {@code true} if this call is disconected.
     */
    public boolean isDisconnected() {
        return (getState() == CallState.DISCONNECTED || getState() == CallState.ABORTED);
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -520,8 +520,7 @@ final class CallAudioManager extends CallsManagerListenerBase
                Log.v(this, "updateAudioStreamAndMode : no foreground, speeding up MT audio.");
                requestAudioFocusAndSetMode(AudioManager.STREAM_VOICE_CALL,
                                                         AudioManager.MODE_IN_CALL);
            } else if (foregroundCall != null &&
                    foregroundCall.getState() != CallState.DISCONNECTED  &&
            } else if (foregroundCall != null && !foregroundCall.isDisconnected() &&
                    waitingForAccountSelectionCall == null) {
                // In the case where there is a call that is waiting for account selection,
                // this will fall back to abandonAudioFocus() below, which temporarily exits
@@ -540,7 +539,7 @@ final class CallAudioManager extends CallsManagerListenerBase
                Log.v(this, "updateAudioStreamAndMode : tone playing");
                requestAudioFocusAndSetMode(
                        AudioManager.STREAM_VOICE_CALL, mMostRecentlyUsedMode);
            } else if (!hasRingingForegroundCall()) {
            } else if (!hasRingingForegroundCall() && mCallsManager.hasOnlyDisconnectedCalls()) {
                Log.v(this, "updateAudioStreamAndMode : no ringing call");
                abandonAudioFocus();
            } else {
+9 −0
Original line number Diff line number Diff line
@@ -439,6 +439,15 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
        return false;
    }

    boolean hasOnlyDisconnectedCalls() {
        for (Call call : mCalls) {
            if (!call.isDisconnected()) {
                return false;
            }
        }
        return true;
    }

    boolean hasVideoCall() {
        for (Call call : mCalls) {
            if (VideoProfile.isVideo(call.getVideoState())) {