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

Commit d77c2b83 authored by Brad Ebinger's avatar Brad Ebinger Committed by Gerrit Code Review
Browse files

Merge "re-arrange dial interface to support emergency silent redial"

parents 5d0a87bc 5820a838
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -593,6 +593,20 @@ public abstract class Connection {
        }
        }
    }
    }


    /**
     * Set the non-detectable emergency number information.
     */
    public void setNonDetectableEmergencyCallInfo(int eccCategory) {
        if (!mIsEmergencyCall) {
            mIsEmergencyCall = true;
            mEmergencyNumberInfo = new EmergencyNumber(mAddress, ""/*countryIso*/,
                                    ""/*mnc*/, eccCategory,
                                    new ArrayList<String>(),
                                    EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING,
                                    EmergencyNumber.EMERGENCY_CALL_ROUTING_UNKNOWN);
        }
    }

    /**
    /**
     * Set if we have known the user's intent for the call is emergency.
     * Set if we have known the user's intent for the call is emergency.
     *
     *
+45 −20
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import android.util.EventLog;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.PhoneInternalInterface.DialArgs;
import com.android.telephony.Rlog;
import com.android.telephony.Rlog;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
@@ -275,16 +276,17 @@ public class GsmCdmaCallTracker extends CallTracker {
    /**
    /**
     * clirMode is one of the CLIR_ constants
     * clirMode is one of the CLIR_ constants
     */
     */
    public synchronized Connection dialGsm(String dialString, int clirMode, UUSInfo uusInfo,
    public synchronized Connection dialGsm(String dialString, DialArgs dialArgs)
                                        Bundle intentExtras)
            throws CallStateException {
            throws CallStateException {
        int clirMode = dialArgs.clirMode;
        UUSInfo uusInfo = dialArgs.uusInfo;
        Bundle intentExtras = dialArgs.intentExtras;
        boolean isEmergencyCall = dialArgs.isEmergency;

        // note that this triggers call state changed notif
        // note that this triggers call state changed notif
        clearDisconnected();
        clearDisconnected();


        // Check for issues which would preclude dialing and throw a CallStateException.
        // Check for issues which would preclude dialing and throw a CallStateException.
        TelephonyManager tm =
                (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE);
        boolean isEmergencyCall = tm.isEmergencyNumber(dialString);
        checkForDialIssues(isEmergencyCall);
        checkForDialIssues(isEmergencyCall);


        String origNumber = dialString;
        String origNumber = dialString;
@@ -322,7 +324,8 @@ public class GsmCdmaCallTracker extends CallTracker {
        }
        }


        mPendingMO = new GsmCdmaConnection(mPhone, dialString, this, mForegroundCall,
        mPendingMO = new GsmCdmaConnection(mPhone, dialString, this, mForegroundCall,
                isEmergencyCall);
                dialArgs);

        if (intentExtras != null) {
        if (intentExtras != null) {
            Rlog.d(LOG_TAG, "dialGsm - emergency dialer: " + intentExtras.getBoolean(
            Rlog.d(LOG_TAG, "dialGsm - emergency dialer: " + intentExtras.getBoolean(
                    TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL));
                    TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL));
@@ -396,18 +399,20 @@ public class GsmCdmaCallTracker extends CallTracker {
    /**
    /**
     * clirMode is one of the CLIR_ constants
     * clirMode is one of the CLIR_ constants
     */
     */
    private Connection dialCdma(String dialString, int clirMode, Bundle intentExtras)
    private Connection dialCdma(String dialString, DialArgs dialArgs)
            throws CallStateException {
            throws CallStateException {
        int clirMode = dialArgs.clirMode;
        Bundle intentExtras = dialArgs.intentExtras;
        boolean isEmergencyCall = dialArgs.isEmergency;

        // note that this triggers call state changed notif
        // note that this triggers call state changed notif
        clearDisconnected();
        clearDisconnected();


        TelephonyManager tm =
                (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE);
        boolean isEmergencyCall = tm.isEmergencyNumber(dialString);

        // Check for issues which would preclude dialing and throw a CallStateException.
        // Check for issues which would preclude dialing and throw a CallStateException.
        checkForDialIssues(isEmergencyCall);
        checkForDialIssues(isEmergencyCall);


        TelephonyManager tm =
                (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE);
        String origNumber = dialString;
        String origNumber = dialString;
        String operatorIsoContry = tm.getNetworkCountryIso(mPhone.getPhoneId());
        String operatorIsoContry = tm.getNetworkCountryIso(mPhone.getPhoneId());
        String simIsoContry = tm.getSimCountryIsoForPhone(mPhone.getPhoneId());
        String simIsoContry = tm.getSimCountryIsoForPhone(mPhone.getPhoneId());
@@ -436,11 +441,12 @@ public class GsmCdmaCallTracker extends CallTracker {
        // That call must be idle, so place anything that's
        // That call must be idle, so place anything that's
        // there on hold
        // there on hold
        if (mForegroundCall.getState() == GsmCdmaCall.State.ACTIVE) {
        if (mForegroundCall.getState() == GsmCdmaCall.State.ACTIVE) {
            return dialThreeWay(dialString, intentExtras);
            return dialThreeWay(dialString, dialArgs);
        }
        }


        mPendingMO = new GsmCdmaConnection(mPhone, dialString, this, mForegroundCall,
        mPendingMO = new GsmCdmaConnection(mPhone, dialString, this, mForegroundCall,
                isEmergencyCall);
                dialArgs);

        if (intentExtras != null) {
        if (intentExtras != null) {
            Rlog.d(LOG_TAG, "dialGsm - emergency dialer: " + intentExtras.getBoolean(
            Rlog.d(LOG_TAG, "dialGsm - emergency dialer: " + intentExtras.getBoolean(
                    TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL));
                    TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL));
@@ -490,14 +496,16 @@ public class GsmCdmaCallTracker extends CallTracker {
    }
    }


    //CDMA
    //CDMA
    private Connection dialThreeWay(String dialString, Bundle intentExtras) {
    private Connection dialThreeWay(String dialString, DialArgs dialArgs) {
        Bundle intentExtras = dialArgs.intentExtras;

        if (!mForegroundCall.isIdle()) {
        if (!mForegroundCall.isIdle()) {
            // Check data call and possibly set mIsInEmergencyCall
            // Check data call and possibly set mIsInEmergencyCall
            disableDataCallInEmergencyCall(dialString);
            disableDataCallInEmergencyCall(dialString);


            // Attach the new connection to foregroundCall
            // Attach the new connection to foregroundCall
            mPendingMO = new GsmCdmaConnection(mPhone, dialString, this, mForegroundCall,
            mPendingMO = new GsmCdmaConnection(mPhone, dialString, this, mForegroundCall,
                    mIsInEmergencyCall);
                    dialArgs);
            if (intentExtras != null) {
            if (intentExtras != null) {
                Rlog.d(LOG_TAG, "dialThreeWay - emergency dialer " + intentExtras.getBoolean(
                Rlog.d(LOG_TAG, "dialThreeWay - emergency dialer " + intentExtras.getBoolean(
                        TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL));
                        TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL));
@@ -526,24 +534,41 @@ public class GsmCdmaCallTracker extends CallTracker {
        return null;
        return null;
    }
    }


    public Connection dial(String dialString, Bundle intentExtras) throws CallStateException {
    public Connection dial(String dialString, DialArgs dialArgs) throws CallStateException {
        if (isPhoneTypeGsm()) {
        if (isPhoneTypeGsm()) {
            return dialGsm(dialString, CommandsInterface.CLIR_DEFAULT, intentExtras);
            return dialGsm(dialString, dialArgs);
        } else {
        } else {
            return dialCdma(dialString, CommandsInterface.CLIR_DEFAULT, intentExtras);
            return dialCdma(dialString, dialArgs);
        }
        }
    }
    }


    //GSM
    //GSM
    public Connection dialGsm(String dialString, UUSInfo uusInfo, Bundle intentExtras)
    public Connection dialGsm(String dialString, UUSInfo uusInfo, Bundle intentExtras)
            throws CallStateException {
            throws CallStateException {
        return dialGsm(dialString, CommandsInterface.CLIR_DEFAULT, uusInfo, intentExtras);
        return dialGsm(dialString, new DialArgs.Builder<>()
                        .setUusInfo(uusInfo)
                        .setClirMode(CommandsInterface.CLIR_DEFAULT)
                        .setIntentExtras(intentExtras)
                        .build());
    }
    }


    //GSM
    //GSM
    private Connection dialGsm(String dialString, int clirMode, Bundle intentExtras)
    private Connection dialGsm(String dialString, int clirMode, Bundle intentExtras)
            throws CallStateException {
            throws CallStateException {
        return dialGsm(dialString, clirMode, null, intentExtras);
        return dialGsm(dialString, new DialArgs.Builder<>()
                        .setClirMode(clirMode)
                        .setIntentExtras(intentExtras)
                        .build());
    }

    //GSM
    public Connection dialGsm(String dialString, int clirMode, UUSInfo uusInfo, Bundle intentExtras)
             throws CallStateException {
        return dialGsm(dialString, new DialArgs.Builder<>()
                        .setClirMode(clirMode)
                        .setUusInfo(uusInfo)
                        .setIntentExtras(intentExtras)
                        .build());
    }
    }


    public void acceptCall() throws CallStateException {
    public void acceptCall() throws CallStateException {
+11 −2
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.PersistableBundle;
import android.os.PowerManager;
import android.os.PowerManager;
import android.os.Registrant;
import android.os.Registrant;
import android.os.SystemClock;
import android.os.SystemClock;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneNumberUtils;
@@ -38,6 +39,7 @@ import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.PhoneInternalInterface.DialArgs;
import com.android.telephony.Rlog;
import com.android.telephony.Rlog;


/**
/**
@@ -158,7 +160,7 @@ public class GsmCdmaConnection extends Connection {


    /** This is an MO call, created when dialing */
    /** This is an MO call, created when dialing */
    public GsmCdmaConnection (GsmCdmaPhone phone, String dialString, GsmCdmaCallTracker ct,
    public GsmCdmaConnection (GsmCdmaPhone phone, String dialString, GsmCdmaCallTracker ct,
                              GsmCdmaCall parent, boolean isEmergencyCall) {
                              GsmCdmaCall parent, DialArgs dialArgs) {
        super(phone.getPhoneType());
        super(phone.getPhoneType());
        createWakeLock(phone.getContext());
        createWakeLock(phone.getContext());
        acquireWakeLock();
        acquireWakeLock();
@@ -177,8 +179,15 @@ public class GsmCdmaConnection extends Connection {
        }
        }


        mAddress = PhoneNumberUtils.extractNetworkPortionAlt(dialString);
        mAddress = PhoneNumberUtils.extractNetworkPortionAlt(dialString);
        if (isEmergencyCall) {
        if (dialArgs.isEmergency) {
            setEmergencyCallInfo(mOwner);
            setEmergencyCallInfo(mOwner);

            // There was no emergency number info found for this call, however it is
            // still marked as an emergency number. This may happen if it was a redialed
            // non-detectable emergency call from IMS.
            if (getEmergencyNumberInfo() == null) {
                setNonDetectableEmergencyCallInfo(dialArgs.eccCategory);
            }
        }
        }


        mPostDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
        mPostDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
+10 −10
Original line number Original line Diff line number Diff line
@@ -93,6 +93,7 @@ import com.android.internal.telephony.dataconnection.TransportManager;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.imsphone.ImsPhoneMmiCode;
import com.android.internal.telephony.imsphone.ImsPhoneMmiCode;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
@@ -1324,8 +1325,12 @@ public class GsmCdmaPhone extends Phone {
        }
        }
        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
        boolean isEmergency = tm.isEmergencyNumber(dialString);
        boolean isEmergency = tm.isEmergencyNumber(dialString);
        ImsPhone.ImsDialArgs.Builder imsDialArgsBuilder;
        imsDialArgsBuilder = ImsPhone.ImsDialArgs.Builder.from(dialArgs)
                                                 .setIsEmergency(isEmergency);
        mDialArgs = dialArgs = imsDialArgsBuilder.build();

        Phone imsPhone = mImsPhone;
        Phone imsPhone = mImsPhone;
        mDialArgs = dialArgs;


        CarrierConfigManager configManager =
        CarrierConfigManager configManager =
                (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
                (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
@@ -1438,14 +1443,9 @@ public class GsmCdmaPhone extends Phone {
            mIsTestingEmergencyCallbackMode = true;
            mIsTestingEmergencyCallbackMode = true;
            mCi.testingEmergencyCall();
            mCi.testingEmergencyCall();
        }
        }
        if (isPhoneTypeGsm()) {

            return dialInternal(dialString, new DialArgs.Builder<>()
                    .setIntentExtras(dialArgs.intentExtras)
                    .build());
        } else {
        return dialInternal(dialString, dialArgs);
        return dialInternal(dialString, dialArgs);
    }
    }
    }


    /**
    /**
     * @return {@code true} if the user should be informed of an attempt to dial an international
     * @return {@code true} if the user should be informed of an attempt to dial an international
@@ -1510,7 +1510,7 @@ public class GsmCdmaPhone extends Phone {
            if (DBG) logd("dialInternal: dialing w/ mmi '" + mmi + "'...");
            if (DBG) logd("dialInternal: dialing w/ mmi '" + mmi + "'...");


            if (mmi == null) {
            if (mmi == null) {
                return mCT.dialGsm(newDialString, dialArgs.uusInfo, dialArgs.intentExtras);
                return mCT.dialGsm(newDialString, dialArgs);
            } else if (mmi.isTemporaryModeCLIR()) {
            } else if (mmi.isTemporaryModeCLIR()) {
                return mCT.dialGsm(mmi.mDialingNumber, mmi.getCLIRMode(), dialArgs.uusInfo,
                return mCT.dialGsm(mmi.mDialingNumber, mmi.getCLIRMode(), dialArgs.uusInfo,
                        dialArgs.intentExtras);
                        dialArgs.intentExtras);
@@ -1521,7 +1521,7 @@ public class GsmCdmaPhone extends Phone {
                return null;
                return null;
            }
            }
        } else {
        } else {
            return mCT.dial(newDialString, dialArgs.intentExtras);
            return mCT.dial(newDialString, dialArgs);
        }
        }
    }
    }


+5 −2
Original line number Original line Diff line number Diff line
@@ -712,10 +712,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                Rlog.d(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received");
                Rlog.d(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received");
                ar = (AsyncResult) msg.obj;
                ar = (AsyncResult) msg.obj;
                if ((ar.exception == null) && (ar.result != null)) {
                if ((ar.exception == null) && (ar.result != null)) {
                    String dialString = (String) ar.result;
                    SilentRedialParam result = (SilentRedialParam) ar.result;
                    String dialString = result.dialString;
                    int causeCode = result.causeCode;
                    DialArgs dialArgs = result.dialArgs;
                    if (TextUtils.isEmpty(dialString)) return;
                    if (TextUtils.isEmpty(dialString)) return;
                    try {
                    try {
                        Connection cn = dialInternal(dialString, new DialArgs.Builder().build());
                        Connection cn = dialInternal(dialString, dialArgs);
                        Rlog.d(LOG_TAG, "Notify redial connection changed cn: " + cn);
                        Rlog.d(LOG_TAG, "Notify redial connection changed cn: " + cn);
                        if (mImsPhone != null) {
                        if (mImsPhone != null) {
                            // Don't care it is null or not.
                            // Don't care it is null or not.
Loading