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

Commit e11d07ac authored by Brad Ebinger's avatar Brad Ebinger Committed by Android (Google) Code Review
Browse files

Merge changes from topic "fix_ims_cs_redial" into sc-dev

* changes:
  Add a new version of Phone#dial that informs the caller of the Phone
  Revert "Fix issue where redial connection change is notified on wrong phone."
parents b5145e70 2d5d3a60
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -1326,8 +1327,8 @@ public class GsmCdmaPhone extends Phone {
    }

    @Override
    public Connection dial(String dialString, @NonNull DialArgs dialArgs)
            throws CallStateException {
    public Connection dial(String dialString, @NonNull DialArgs dialArgs,
            Consumer<Phone> chosenPhoneConsumer) throws CallStateException {
        if (!isPhoneTypeGsm() && dialArgs.uusInfo != null) {
            throw new CallStateException("Sending UUS information NOT supported in CDMA!");
        }
@@ -1410,6 +1411,7 @@ public class GsmCdmaPhone extends Phone {
                || useImsForEmergency) {
            try {
                if (DBG) logd("Trying IMS PS call");
                chosenPhoneConsumer.accept(imsPhone);
                return imsPhone.dial(dialString, dialArgs);
            } catch (CallStateException e) {
                if (DBG) logd("IMS PS call exception " + e +
@@ -1466,6 +1468,7 @@ public class GsmCdmaPhone extends Phone {
            mCi.testingEmergencyCall();
        }

        chosenPhoneConsumer.accept(this);
        return dialInternal(dialString, dialArgs);
    }

+17 −25
Original line number Diff line number Diff line
@@ -200,8 +200,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    // Single Radio Voice Call Continuity
    @VisibleForTesting
    protected static final int EVENT_SRVCC_STATE_CHANGED             = 31;
    @VisibleForTesting
    public static final int EVENT_INITIATE_SILENT_REDIAL           = 32;
    private static final int EVENT_INITIATE_SILENT_REDIAL           = 32;
    private static final int EVENT_RADIO_NOT_AVAILABLE              = 33;
    private static final int EVENT_UNSOL_OEM_HOOK_RAW               = 34;
    protected static final int EVENT_GET_RADIO_CAPABILITY           = 35;
@@ -357,11 +356,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private static final boolean LCE_PULL_MODE = true;
    private int mLceStatus = RILConstants.LCE_NOT_AVAILABLE;
    protected TelephonyComponentFactory mTelephonyComponentFactory;
    /**
     * Should ALWAYS be {@code true} in production code.  This is used only used in tests so that we
     * can disable the read checks which interfer with unit testing.
     */
    private boolean mAreThreadChecksEnabled = true;

    //IMS
    /**
@@ -743,7 +737,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                break;

            case EVENT_INITIATE_SILENT_REDIAL:
                Rlog.i(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received");
                // This is an ImsPhone -> GsmCdmaPhone redial
                // See ImsPhone#initiateSilentRedial
                Rlog.d(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received");
                ar = (AsyncResult) msg.obj;
                if ((ar.exception == null) && (ar.result != null)) {
                    SilentRedialParam result = (SilentRedialParam) ar.result;
@@ -753,12 +749,20 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                    if (TextUtils.isEmpty(dialString)) return;
                    try {
                        Connection cn = dialInternal(dialString, dialArgs);
                        Rlog.i(LOG_TAG, "Notify redial connection changed cn: " + cn);
                        notifyRedialConnectionChanged(cn);
                        // The ImsPhoneConnection that is owned by the ImsPhone is currently the
                        // one with a callback registered to TelephonyConnection. Notify the
                        // redial happened over that Phone so that it can be replaced with the
                        // new GSM/CDMA Connection.
                        Rlog.d(LOG_TAG, "Notify redial connection changed cn: " + cn);
                        if (mImsPhone != null) {
                            // Don't care it is null or not.
                            mImsPhone.notifyRedialConnectionChanged(cn);
                        }
                    } catch (CallStateException e) {
                        Rlog.e(LOG_TAG, "Notify redial connection changed - silent redial failed: "
                                + e);
                        notifyRedialConnectionChanged(null);
                        Rlog.e(LOG_TAG, "silent redial failed: " + e);
                        if (mImsPhone != null) {
                            mImsPhone.notifyRedialConnectionChanged(null);
                        }
                    }
                }
                break;
@@ -1764,9 +1768,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * the thread that originally obtained this Phone instance.
     */
    private void checkCorrectThread(Handler h) {
        if (!mAreThreadChecksEnabled) {
            return;
        }
        if (h.getLooper() != mLooper) {
            throw new RuntimeException(
                    "com.android.internal.telephony.Phone must be used from within one thread");
@@ -5036,13 +5037,4 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private static String pii(String s) {
        return Rlog.pii(LOG_TAG, s);
    }

    /**
     * Used in unit tests to disable the thread checks.  Should not be used otherwise.
     * @param enabled {@code true} if thread checks are enabled, {@code false} otherwise.
     */
    @VisibleForTesting
    public void setAreThreadChecksEnabled(boolean enabled) {
        mAreThreadChecksEnabled = enabled;
    }
}
+23 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.internal.telephony.PhoneConstants.DataState;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.function.Consumer;

/**
 * Internal interface used to control the phone; SDK developers cannot
@@ -489,12 +490,33 @@ public interface PhoneInternalInterface {
     *
     * @param dialString The dial string.
     * @param dialArgs Parameters to perform the dial with.
     * @param chosenPhone The Phone (either GsmCdmaPhone or ImsPhone) that has been chosen to dial
     *                    this number. This is used for any setup that should occur before dial
     *                    actually occurs.
     * @exception CallStateException if a new outgoing call is not currently
     *                possible because no more call slots exist or a call exists
     *                that is dialing, alerting, ringing, or waiting. Other
     *                errors are handled asynchronously.
     */
    Connection dial(String dialString, @NonNull DialArgs dialArgs) throws CallStateException;
    Connection dial(String dialString, @NonNull DialArgs dialArgs,
            Consumer<Phone> chosenPhone) throws CallStateException;

    /**
     * Initiate a new voice connection. This happens asynchronously, so you
     * cannot assume the audio path is connected (or a call index has been
     * assigned) until PhoneStateChanged notification has occurred.
     *
     * @param dialString The dial string.
     * @param dialArgs Parameters to perform the dial with.
     * @exception CallStateException if a new outgoing call is not currently
     *                possible because no more call slots exist or a call exists
     *                that is dialing, alerting, ringing, or waiting. Other
     *                errors are handled asynchronously.
     */
    default Connection dial(String dialString, @NonNull DialArgs dialArgs)
            throws CallStateException {
        return dial(dialString, dialArgs, (phone) -> {});
    }

    /**
     * Initiate a new conference connection. This happens asynchronously, so you
+8 −1
Original line number Diff line number Diff line
@@ -919,7 +919,9 @@ public class ImsPhone extends ImsPhoneBase {
    }

    @Override
    public Connection dial(String dialString, DialArgs dialArgs) throws CallStateException {
    public Connection dial(String dialString, DialArgs dialArgs,
            Consumer<Phone> chosenPhoneConsumer) throws CallStateException {
        chosenPhoneConsumer.accept(this);
        return dialInternal(dialString, dialArgs, null);
    }

@@ -1888,6 +1890,7 @@ public class ImsPhone extends ImsPhoneBase {
                }
                break;
            case EVENT_INITIATE_VOLTE_SILENT_REDIAL: {
                // This is a CS -> IMS redial
                if (VDBG) logd("EVENT_INITIATE_VOLTE_SILENT_REDIAL");
                ar = (AsyncResult) msg.obj;
                if (ar.exception == null && ar.result != null) {
@@ -1900,6 +1903,10 @@ public class ImsPhone extends ImsPhoneBase {
                    try {
                        Connection cn = dial(dialString,
                                updateDialArgsForVolteSilentRedial(dialArgs, causeCode));
                        // The GSM/CDMA Connection that is owned by the GsmCdmaPhone is currently
                        // the one with a callback registered to TelephonyConnection. Notify the
                        // redial happened over that Phone so that it can be replaced with the
                        // new ImsPhoneConnection.
                        Rlog.d(LOG_TAG, "Notify volte redial connection changed cn: " + cn);
                        if (mDefaultPhone != null) {
                            // don't care it is null or not.
+4 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.internal.telephony.PhoneNotifier;
import com.android.telephony.Rlog;

import java.text.ParseException;
import java.util.function.Consumer;
import java.util.regex.Pattern;

/**
@@ -192,7 +193,9 @@ public class SipPhone extends SipPhoneBase {
    }

    @Override
    public Connection dial(String dialString, DialArgs dialArgs) throws CallStateException {
    public Connection dial(String dialString, DialArgs dialArgs,
            Consumer<Phone> chosenPhoneConsumer) throws CallStateException {
        chosenPhoneConsumer.accept(this);
        synchronized (SipPhone.class) {
            return dialInternal(dialString, dialArgs.videoState);
        }
Loading