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

Commit a20d318a authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Use TelephonyManager.NETWORK_TYPE_* for IMS APIs

am: df90c56b

Change-Id: I31a3d3a9cb2872a7e364d78901a4f31c37712150
parents 721b19d7 df90c56b
Loading
Loading
Loading
Loading
+37 −31
Original line number Diff line number Diff line
@@ -27,12 +27,14 @@ import android.telecom.Connection;
import android.telephony.CallQuality;
import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsConferenceState;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsStreamMediaProfile;
import android.telephony.ims.ImsSuppServiceNotification;
import android.text.TextUtils;
import android.util.Log;

import com.android.ims.internal.ConferenceParticipant;
@@ -3074,10 +3076,10 @@ public class ImsCall implements ICall {
            }
        }

        public void callSessionHandover(ImsCallSession session, int srcAccessTech,
            int targetAccessTech, ImsReasonInfo reasonInfo) {
        public void callSessionHandover(ImsCallSession session, int srcNetworkType,
            int targetNetworkType, ImsReasonInfo reasonInfo) {
            logi("callSessionHandover :: session=" + session + ", srcAccessTech=" +
                srcAccessTech + ", targetAccessTech=" + targetAccessTech + ", reasonInfo=" +
                    srcNetworkType + ", targetAccessTech=" + targetNetworkType + ", reasonInfo=" +
                reasonInfo);

            ImsCall.Listener listener;
@@ -3088,7 +3090,9 @@ public class ImsCall implements ICall {

            if (listener != null) {
                try {
                    listener.onCallHandover(ImsCall.this, srcAccessTech, targetAccessTech,
                    listener.onCallHandover(ImsCall.this,
                            ServiceState.networkTypeToRilRadioTechnology(srcNetworkType),
                            ServiceState.networkTypeToRilRadioTechnology(targetNetworkType),
                            reasonInfo);
                } catch (Throwable t) {
                    loge("callSessionHandover :: ", t);
@@ -3097,10 +3101,10 @@ public class ImsCall implements ICall {
        }

        @Override
        public void callSessionHandoverFailed(ImsCallSession session, int srcAccessTech,
            int targetAccessTech, ImsReasonInfo reasonInfo) {
        public void callSessionHandoverFailed(ImsCallSession session, int srcNetworkType,
            int targetNetworkType, ImsReasonInfo reasonInfo) {
            loge("callSessionHandoverFailed :: session=" + session + ", srcAccessTech=" +
                srcAccessTech + ", targetAccessTech=" + targetAccessTech + ", reasonInfo=" +
                    srcNetworkType + ", targetAccessTech=" + targetNetworkType + ", reasonInfo=" +
                reasonInfo);

            ImsCall.Listener listener;
@@ -3111,7 +3115,9 @@ public class ImsCall implements ICall {

            if (listener != null) {
                try {
                    listener.onCallHandoverFailed(ImsCall.this, srcAccessTech, targetAccessTech,
                    listener.onCallHandoverFailed(ImsCall.this,
                            ServiceState.networkTypeToRilRadioTechnology(srcNetworkType),
                            ServiceState.networkTypeToRilRadioTechnology(targetNetworkType),
                            reasonInfo);
                } catch (Throwable t) {
                    loge("callSessionHandoverFailed :: ", t);
@@ -3490,8 +3496,8 @@ public class ImsCall implements ICall {
        ImsCallProfile imsCallProfile = mCallProfile;
        if (imsCallProfile != null) {
            sb.append(" mCallProfile:" + imsCallProfile);
            sb.append(" tech:");
            sb.append(imsCallProfile.getCallExtra(ImsCallProfile.EXTRA_CALL_RAT_TYPE));
            sb.append(" networkType:");
            sb.append(getNetworkType());
        }
        sb.append(" updateRequest:");
        sb.append(updateRequestToString(mUpdateRequest));
@@ -3590,35 +3596,35 @@ public class ImsCall implements ICall {
            if (mCallProfile == null) {
                return false;
            }
            int radioTechnology = getRadioTechnology();
            return radioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
            return getNetworkType() == TelephonyManager.NETWORK_TYPE_IWLAN;
        }
    }

    /**
     * Determines the radio access technology for the {@link ImsCall}.
     * @return The {@link ServiceState} {@code RIL_RADIO_TECHNOLOGY_*} code in use.
     * Determines the network type for the {@link ImsCall}.
     * @return The {@link TelephonyManager} {@code NETWORK_TYPE_*} code in use.
     */
    public int getRadioTechnology() {
    public int getNetworkType() {
        synchronized(mLockObj) {
            if (mCallProfile == null) {
                return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
            }
            String callType = mCallProfile.getCallExtra(ImsCallProfile.EXTRA_CALL_RAT_TYPE);
            if (callType == null || callType.isEmpty()) {
                callType = mCallProfile.getCallExtra(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT);
            int networkType = mCallProfile.getCallExtraInt(ImsCallProfile.EXTRA_CALL_NETWORK_TYPE,
                    TelephonyManager.NETWORK_TYPE_UNKNOWN);
            if (networkType == TelephonyManager.NETWORK_TYPE_UNKNOWN) {
                //  Try to look at old extras to see if the ImsService is using deprecated behavior.
                String oldRatType = mCallProfile.getCallExtra(ImsCallProfile.EXTRA_CALL_RAT_TYPE);
                if (TextUtils.isEmpty(oldRatType)) {
                    oldRatType = mCallProfile.getCallExtra(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT);
                }

            // The RIL (sadly) sends us the EXTRA_CALL_RAT_TYPE as a string extra, rather than an
            // integer extra, so we need to parse it.
            int radioTechnology = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
                try {
                radioTechnology = Integer.parseInt(callType);
            } catch (NumberFormatException nfe) {
                radioTechnology = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
                    int oldRatTypeConverted = Integer.parseInt(oldRatType);
                    networkType = ServiceState.rilRadioTechnologyToNetworkType(oldRatTypeConverted);
                } catch (NumberFormatException e) {
                    networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
                }

            return radioTechnology;
            }
            return networkType;
        }
    }