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

Commit cc2dbdc6 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Propagates voice call radio technology to connection"

am: 4d3fdcbc

Change-Id: If13559f4dcf7559f3dcba59dd197138d0e43b999
parents 6c780d00 4d3fdcbc
Loading
Loading
Loading
Loading
+30 −9
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.SystemClock;
import android.telecom.ConferenceParticipant;
import android.telephony.DisconnectCause;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.util.Log;

import java.lang.Override;
@@ -89,7 +90,7 @@ public abstract class Connection {
    public interface Listener {
        public void onVideoStateChanged(int videoState);
        public void onConnectionCapabilitiesChanged(int capability);
        public void onWifiChanged(boolean isWifi);
        public void onCallRadioTechChanged(@ServiceState.RilRadioTechnology int vrat);
        public void onVideoProviderChanged(
                android.telecom.Connection.VideoProvider videoProvider);
        public void onAudioQualityChanged(int audioQuality);
@@ -119,7 +120,7 @@ public abstract class Connection {
        @Override
        public void onConnectionCapabilitiesChanged(int capability) {}
        @Override
        public void onWifiChanged(boolean isWifi) {}
        public void onCallRadioTechChanged(@ServiceState.RilRadioTechnology int vrat) {}
        @Override
        public void onVideoProviderChanged(
                android.telecom.Connection.VideoProvider videoProvider) {}
@@ -206,7 +207,13 @@ public abstract class Connection {
    Object mUserData;
    private int mVideoState;
    private int mConnectionCapabilities;
    private boolean mIsWifi;
    /**
     * Determines the call radio technology for current connection.
     *
     * This is used to propagate the call radio technology to upper layer.
     */
    private @ServiceState.RilRadioTechnology int mCallRadioTech =
            ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
    private boolean mAudioModeIsVoip;
    private int mAudioQuality;
    private int mCallSubstate;
@@ -742,7 +749,17 @@ public abstract class Connection {
     * @return {@code True} if the connection is using a wifi network.
     */
    public boolean isWifi() {
        return mIsWifi;
        return getCallRadioTech() == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
    }

    /**
     * Returns radio technology is used for the connection.
     *
     * @return the RIL Voice Radio Technology used for current connection,
     *         see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
     */
    public @ServiceState.RilRadioTechnology int getCallRadioTech() {
        return mCallRadioTech;
    }

    /**
@@ -813,14 +830,18 @@ public abstract class Connection {
    }

    /**
     * Sets whether a wifi network is used for the connection.
     * Sets RIL voice radio technology used for current connection.
     *
     * @param isWifi {@code True} if wifi is being used.
     * @param vrat the RIL voice radio technology for current connection,
     *             see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
     */
    public void setWifi(boolean isWifi) {
        mIsWifi = isWifi;
    public void setCallRadioTech(@ServiceState.RilRadioTechnology int vrat) {
        if (mCallRadioTech == vrat) {
            return;
        }
        mCallRadioTech = vrat;
        for (Listener l : mListeners) {
            l.onWifiChanged(mIsWifi);
            l.onCallRadioTechChanged(vrat);
        }
    }

+18 −0
Original line number Diff line number Diff line
@@ -1562,6 +1562,24 @@ public class GsmCdmaCallTracker extends CallTracker {
        }
    }

    /**
     * Dispatches the CS call radio technology to all exist connections.
     *
     * @param vrat the RIL voice radio technology for CS calls,
     *             see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
     */
    public void dispatchCsCallRadioTech(@ServiceState.RilRadioTechnology int vrat) {
        if (mConnections == null) {
            log("dispatchCsCallRadioTech: mConnections is null");
            return;
        }
        for (GsmCdmaConnection gsmCdmaConnection : mConnections) {
            if (gsmCdmaConnection != null) {
                gsmCdmaConnection.setCallRadioTech(vrat);
            }
        }
    }

    //CDMA
    /**
     * Check and enable data call after an emergency call is dropped if it's
+6 −0
Original line number Diff line number Diff line
@@ -143,6 +143,8 @@ public class GsmCdmaConnection extends Connection {
        fetchDtmfToneDelay(phone);

        setAudioQuality(getAudioQualityFromDC(dc.audioQuality));

        setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
    }

    /** This is an MO call, created when dialing */
@@ -193,6 +195,8 @@ public class GsmCdmaConnection extends Connection {
        }

        fetchDtmfToneDelay(phone);

        setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
    }

    //CDMA
@@ -215,6 +219,8 @@ public class GsmCdmaConnection extends Connection {
        mConnectTime = 0;
        mParent = parent;
        parent.attachFake(this, GsmCdmaCall.State.WAITING);

        setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
    }


+73 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.telephony.TelephonyManager;
import android.telephony.UssdResponse;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;

import com.android.ims.ImsManager;
import com.android.internal.annotations.VisibleForTesting;
@@ -90,6 +91,7 @@ import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.UiccProfile;
import com.android.internal.telephony.uicc.UiccSlot;
import com.android.internal.util.ArrayUtils;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -229,6 +231,8 @@ public class GsmCdmaPhone extends Phone {
        mSST.registerForNetworkAttached(this, EVENT_REGISTERED_TO_NETWORK, null);
        mDeviceStateMonitor = mTelephonyComponentFactory.makeDeviceStateMonitor(this);
        mAccessNetworksManager = mTelephonyComponentFactory.makeAccessNetworksManager(this);

        mSST.registerForVoiceRegStateOrRatChanged(this, EVENT_VRS_OR_RAT_CHANGED, null);
        logd("GsmCdmaPhone: constructor: sub = " + mPhoneId);
    }

@@ -2540,6 +2544,11 @@ public class GsmCdmaPhone extends Phone {
                }
                Rlog.d(LOG_TAG, "EVENT_GET_RADIO_CAPABILITY: phone rc: " + rc);
                break;
            case EVENT_VRS_OR_RAT_CHANGED:
                ar = (AsyncResult) msg.obj;
                Pair<Integer, Integer> vrsRatPair = (Pair<Integer, Integer>) ar.result;
                onVoiceRegStateOrRatChanged(vrsRatPair.first, vrsRatPair.second);
                break;

            default:
                super.handleMessage(msg);
@@ -3549,6 +3558,70 @@ public class GsmCdmaPhone extends Phone {
        mEcmTimerResetRegistrants.notifyResult(flag);
    }

    private static final int[] VOICE_PS_CALL_RADIO_TECHNOLOGY = {
            ServiceState.RIL_RADIO_TECHNOLOGY_LTE,
            ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA,
            ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
    };

    /**
     * Calculates current RIL voice radio technology for CS calls.
     *
     * This function should only be used in {@link com.android.internal.telephony.GsmCdmaConnection}
     * to indicate current CS call radio technology.
     *
     * @return the RIL voice radio technology used for CS calls,
     *         see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
     */
    public @ServiceState.RilRadioTechnology int getCsCallRadioTech() {
        int calcVrat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
        if (mSST != null) {
            calcVrat = getCsCallRadioTech(mSST.mSS.getVoiceRegState(),
                    mSST.mSS.getRilVoiceRadioTechnology());
        }

        return calcVrat;
    }

    /**
     * Calculates current RIL voice radio technology for CS calls based on current voice
     * registration state and technology.
     *
     * Mark current RIL voice radio technology as unknow when any of below condtion is met:
     *  1) Current RIL voice registration state is not in-service.
     *  2) Current RIL voice radio technology is PS call technology, which means CSFB will
     *     happen later after call connection is established.
     *     It is inappropriate to notify upper layer the PS call technology while current call
     *     is CS call, so before CSFB happens, mark voice radio technology as unknow.
     *     After CSFB happens, {@link #onVoiceRegStateOrRatChanged} will update voice call radio
     *     technology with correct value.
     *
     * @param vrs the voice registration state
     * @param vrat the RIL voice radio technology
     *
     * @return the RIL voice radio technology used for CS calls,
     *         see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
     */
    private @ServiceState.RilRadioTechnology int getCsCallRadioTech(int vrs, int vrat) {
        logd("getCsCallRadioTech, current vrs=" + vrs + ", vrat=" + vrat);
        int calcVrat = vrat;
        if (vrs != ServiceState.STATE_IN_SERVICE
                || ArrayUtils.contains(VOICE_PS_CALL_RADIO_TECHNOLOGY, vrat)) {
            calcVrat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
        }

        logd("getCsCallRadioTech, result calcVrat=" + calcVrat);
        return calcVrat;
    }

    /**
     * Handler of RIL Voice Radio Technology changed event.
     */
    private void onVoiceRegStateOrRatChanged(int vrs, int vrat) {
        logd("onVoiceRegStateOrRatChanged");
        mCT.dispatchCsCallRadioTech(getCsCallRadioTech(vrs, vrat));
    }

    /**
     * Registration point for Ecm timer reset
     *
+2 −1
Original line number Diff line number Diff line
@@ -198,8 +198,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    // Carrier's CDMA prefer mode setting
    protected static final int EVENT_SET_ROAMING_PREFERENCE_DONE    = 44;
    protected static final int EVENT_MODEM_RESET                    = 45;
    protected static final int EVENT_VRS_OR_RAT_CHANGED             = 46;

    protected static final int EVENT_LAST                       = EVENT_MODEM_RESET;
    protected static final int EVENT_LAST                       = EVENT_VRS_OR_RAT_CHANGED;

    // For shared prefs.
    private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
Loading