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

Commit eb35d8b4 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

DO NOT MERGE Inform registrants of which connection started or stopped the hold tone.

When receiving a hold tone signal and informing registrants via
startOnHoldTone/stopOnHoldTone, also include the connection which initiated
the start/stop. This is necessray to ensure only the TelephonyConnection
which initiated a hold tone issues a Connection Event.

Bug: 25357778
Change-Id: I1590b61affb28c40173f08a8f6233d8efe6a5e6e
parent 509e0e42
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.telephony.CellLocation;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.Rlog;
import android.util.Pair;

import com.android.internal.telephony.Call;
import com.android.internal.telephony.CallStateException;
@@ -102,14 +103,24 @@ abstract class ImsPhoneBase extends PhoneBase {
        mOnHoldRegistrants.remove(h);
    }

    protected void startOnHoldTone() {
        AsyncResult result = new AsyncResult(null, Boolean.TRUE, null);
        mOnHoldRegistrants.notifyRegistrants(result);
    /**
     * Signals all registrants that the remote hold tone should be started for a connection.
     *
     * @param cn The connection.
     */
    protected void startOnHoldTone(Connection cn) {
        Pair<Connection, Boolean> result = new Pair<Connection, Boolean>(cn, Boolean.TRUE);
        mOnHoldRegistrants.notifyRegistrants(new AsyncResult(null, result, null));
    }

    protected void stopOnHoldTone() {
        AsyncResult result = new AsyncResult(null, Boolean.FALSE, null);
        mOnHoldRegistrants.notifyRegistrants(result);
    /**
     * Signals all registrants that the remote hold tone should be stopped for a connection.
     *
     * @param cn The connection.
     */
    protected void stopOnHoldTone(Connection cn) {
        Pair<Connection, Boolean> result = new Pair<Connection, Boolean>(cn, Boolean.FALSE);
        mOnHoldRegistrants.notifyRegistrants(new AsyncResult(null, result, null));
    }

    @Override
+13 −4
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ public final class ImsPhoneCallTracker extends CallTracker {

    private boolean mDesiredMute = false;    // false = mute off
    private boolean mOnHoldToneStarted = false;
    private int mOnHoldToneId = -1;

    PhoneConstants.State mState = PhoneConstants.State.IDLE;

@@ -1163,6 +1164,13 @@ public final class ImsPhoneCallTracker extends CallTracker {
            ImsPhoneConnection conn = findConnection(imsCall);
            if (DBG) log("cause = " + cause + " conn = " + conn);

            if (mOnHoldToneId == System.identityHashCode(conn)) {
                if (conn != null && mOnHoldToneStarted) {
                    mPhone.stopOnHoldTone(conn);
                }
                mOnHoldToneStarted = false;
                mOnHoldToneId = -1;
            }
            if (conn != null && conn.isIncoming() && conn.getConnectTime() == 0) {
                // Missed
                if (cause == DisconnectCause.NORMAL) {
@@ -1297,9 +1305,9 @@ public final class ImsPhoneCallTracker extends CallTracker {
        @Override
        public void onCallResumeReceived(ImsCall imsCall) {
            if (DBG) log("onCallResumeReceived");

            if (mOnHoldToneStarted) {
                mPhone.stopOnHoldTone();
            ImsPhoneConnection conn = findConnection(imsCall);
            if (conn != null && mOnHoldToneStarted) {
                mPhone.stopOnHoldTone(conn);
                mOnHoldToneStarted = false;
            }

@@ -1318,8 +1326,9 @@ public final class ImsPhoneCallTracker extends CallTracker {
            ImsPhoneConnection conn = findConnection(imsCall);
            if (conn != null && conn.getState() == ImsPhoneCall.State.ACTIVE) {
                if (!mOnHoldToneStarted && ImsPhoneCall.isLocalTone(imsCall)) {
                    mPhone.startOnHoldTone();
                    mPhone.startOnHoldTone(conn);
                    mOnHoldToneStarted = true;
                    mOnHoldToneId = System.identityHashCode(conn);
                }
            }