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

Commit df90c56b authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Use TelephonyManager.NETWORK_TYPE_* for IMS APIs

Use TelephonyManager.NETWORK_TYPE_* for IMS APIs instead
of ServiceState.

Bug: 147726372
Test: atest FrameworksTelephonyTests
Merged-In: I5938e02800c6e472a30442faf21d7a2c382240df
Change-Id: I5938e02800c6e472a30442faf21d7a2c382240df
parent d9dbaa7f
Loading
Loading
Loading
Loading
+37 −31
Original line number Original line Diff line number Diff line
@@ -27,12 +27,14 @@ import android.telecom.Connection;
import android.telephony.CallQuality;
import android.telephony.CallQuality;
import com.android.telephony.Rlog;
import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsConferenceState;
import android.telephony.ims.ImsConferenceState;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsStreamMediaProfile;
import android.telephony.ims.ImsStreamMediaProfile;
import android.telephony.ims.ImsSuppServiceNotification;
import android.telephony.ims.ImsSuppServiceNotification;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;


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


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


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


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


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


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


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


    /**
    /**
     * Determines the radio access technology for the {@link ImsCall}.
     * Determines the network type for the {@link ImsCall}.
     * @return The {@link ServiceState} {@code RIL_RADIO_TECHNOLOGY_*} code in use.
     * @return The {@link TelephonyManager} {@code NETWORK_TYPE_*} code in use.
     */
     */
    public int getRadioTechnology() {
    public int getNetworkType() {
        synchronized(mLockObj) {
        synchronized(mLockObj) {
            if (mCallProfile == null) {
            if (mCallProfile == null) {
                return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
                return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
            }
            }
            String callType = mCallProfile.getCallExtra(ImsCallProfile.EXTRA_CALL_RAT_TYPE);
            int networkType = mCallProfile.getCallExtraInt(ImsCallProfile.EXTRA_CALL_NETWORK_TYPE,
            if (callType == null || callType.isEmpty()) {
                    TelephonyManager.NETWORK_TYPE_UNKNOWN);
                callType = mCallProfile.getCallExtra(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT);
            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 {
                try {
                radioTechnology = Integer.parseInt(callType);
                    int oldRatTypeConverted = Integer.parseInt(oldRatType);
            } catch (NumberFormatException nfe) {
                    networkType = ServiceState.rilRadioTechnologyToNetworkType(oldRatTypeConverted);
                radioTechnology = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
                } catch (NumberFormatException e) {
                    networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
                }
                }

            }
            return radioTechnology;
            return networkType;
        }
        }
    }
    }