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

Commit a1693657 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Merge "Dynamically changing MMTEL capability" into tm-dev am: 48c5d5be

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/17922489



Change-Id: Ic45307a3ac7ac017d357da7d9fd4c767d123f462
Ignore-AOSP-First: this is an automerge
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e9180878 48c5d5be
Loading
Loading
Loading
Loading
+98 −47
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.IndentingPrintWriter;
import android.util.LocalLog;
import android.util.Pair;
import android.util.SparseArray;
import android.util.SparseIntArray;

@@ -219,6 +218,15 @@ public class DataNetwork extends StateMachine {
     */
    private static final int EVENT_WAITING_FOR_TEARING_DOWN_CONDITION_MET = 21;

    /** Event for call started. */
    private static final int EVENT_VOICE_CALL_STARTED = 22;

    /** Event for call ended. */
    private static final int EVENT_VOICE_CALL_ENDED = 23;

    /** Event for CSS indicator changed. */
    private static final int EVENT_CSS_INDICATOR_CHANGED = 24;

    /** The default MTU for IPv4 network. */
    private static final int DEFAULT_MTU_V4 = 1280;

@@ -401,7 +409,11 @@ public class DataNetwork extends StateMachine {
            NetworkCapabilities.NET_CAPABILITY_HEAD_UNIT,
            // Connectivity service will support NOT_METERED as a mutable and requestable
            // capability.
            NetworkCapabilities.NET_CAPABILITY_NOT_METERED
            NetworkCapabilities.NET_CAPABILITY_NOT_METERED,
            // Even though MMTEL is an immutable capability, we still make it an mutable capability
            // here before we have a better solution to deal with network transition from VoPS
            // to non-VoPS network.
            NetworkCapabilities.NET_CAPABILITY_MMTEL
    );

    /** The parent state. Any messages not handled by the child state fallback to this. */
@@ -962,15 +974,29 @@ public class DataNetwork extends StateMachine {
            mDataConfigManager.registerForConfigUpdate(getHandler(), EVENT_DATA_CONFIG_UPDATED);
            mPhone.getDisplayInfoController().registerForTelephonyDisplayInfoChanged(
                    getHandler(), EVENT_DISPLAY_INFO_CHANGED, null);
            mPhone.getServiceStateTracker().registerForServiceStateChanged(getHandler(),
                    EVENT_SERVICE_STATE_CHANGED);
            for (int transport : mAccessNetworksManager.getAvailableTransports()) {
                mDataServiceManagers.get(transport)
                        .registerForDataCallListChanged(getHandler(), EVENT_DATA_STATE_CHANGED);
                mPhone.getServiceStateTracker().registerForDataRegStateOrRatChanged(
                        transport, getHandler(), EVENT_SERVICE_STATE_CHANGED, transport);
            }
            mPhone.getCarrierPrivilegesTracker().registerCarrierPrivilegesListener(getHandler(),
                    EVENT_CARRIER_PRIVILEGED_UIDS_CHANGED, null);

            mPhone.getServiceStateTracker().registerForCssIndicatorChanged(
                    getHandler(), EVENT_CSS_INDICATOR_CHANGED, null);
            mPhone.getCallTracker().registerForVoiceCallStarted(
                    getHandler(), EVENT_VOICE_CALL_STARTED, null);
            mPhone.getCallTracker().registerForVoiceCallEnded(
                    getHandler(), EVENT_VOICE_CALL_ENDED, null);
            // Check null for devices not supporting FEATURE_TELEPHONY_IMS.
            if (mPhone.getImsPhone() != null) {
                mPhone.getImsPhone().getCallTracker().registerForVoiceCallStarted(
                        getHandler(), EVENT_VOICE_CALL_STARTED, null);
                mPhone.getImsPhone().getCallTracker().registerForVoiceCallEnded(
                        getHandler(), EVENT_VOICE_CALL_ENDED, null);
            }

            // Only add symmetric code here, for example, registering and unregistering.
            // DefaultState.enter() is the starting point in the life cycle of the DataNetwork,
            // and DefaultState.exit() is the end. For non-symmetric initializing works, put them
@@ -980,13 +1006,21 @@ public class DataNetwork extends StateMachine {
        @Override
        public void exit() {
            logv("Unregistering all events.");
            // Check null for devices not supporting FEATURE_TELEPHONY_IMS.
            if (mPhone.getImsPhone() != null) {
                mPhone.getImsPhone().getCallTracker().unregisterForVoiceCallStarted(getHandler());
                mPhone.getImsPhone().getCallTracker().unregisterForVoiceCallEnded(getHandler());
            }
            mPhone.getCallTracker().unregisterForVoiceCallStarted(getHandler());
            mPhone.getCallTracker().unregisterForVoiceCallEnded(getHandler());

            mPhone.getServiceStateTracker().unregisterForCssIndicatorChanged(getHandler());
            mPhone.getCarrierPrivilegesTracker().unregisterCarrierPrivilegesListener(getHandler());
            for (int transport : mAccessNetworksManager.getAvailableTransports()) {
                mDataServiceManagers.get(transport)
                        .unregisterForDataCallListChanged(getHandler());
                mPhone.getServiceStateTracker().unregisterForDataRegStateOrRatChanged(
                        transport, getHandler());
            }
            mPhone.getServiceStateTracker().unregisterForServiceStateChanged(getHandler());
            mPhone.getDisplayInfoController().unregisterForTelephonyDisplayInfoChanged(
                    getHandler());
            mDataConfigManager.unregisterForConfigUpdate(getHandler());
@@ -999,12 +1033,9 @@ public class DataNetwork extends StateMachine {
                    onDataConfigUpdated();
                    break;
                case EVENT_SERVICE_STATE_CHANGED: {
                    // TODO: Should update suspend state when CSS indicator changes.
                    // TODO: Should update suspend state when call started/ended.
                    mDataCallSessionStats.onDrsOrRatChanged(getDataNetworkType());
                    updateSuspendState();
                    updateTcpBufferSizes();
                    updateBandwidthFromDataConfig();
                    updateDataCallSessionStatsOfDrsOrRatChange((AsyncResult) msg.obj);
                    updateNetworkCapabilities();
                    break;
                }
                case EVENT_ATTACH_NETWORK_REQUEST: {
@@ -1046,6 +1077,9 @@ public class DataNetwork extends StateMachine {
                case EVENT_STUCK_IN_TRANSIENT_STATE:
                case EVENT_DISPLAY_INFO_CHANGED:
                case EVENT_WAITING_FOR_TEARING_DOWN_CONDITION_MET:
                case EVENT_CSS_INDICATOR_CHANGED:
                case EVENT_VOICE_CALL_STARTED:
                case EVENT_VOICE_CALL_ENDED:
                    // Ignore the events when not in the correct state.
                    log("Ignored " + eventToString(msg.what));
                    break;
@@ -1187,10 +1221,6 @@ public class DataNetwork extends StateMachine {
            updateSuspendState();
        }

        @Override
        public void exit() {
        }

        @Override
        public boolean processMessage(Message msg) {
            logv("event=" + eventToString(msg.what));
@@ -1208,7 +1238,7 @@ public class DataNetwork extends StateMachine {
                    // request is from IMS service itself, that means IMS service is already aware
                    // of the tear down. So there is no need to delay in this case.
                    if (tearDownReason != TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED
                            && shouldDelayTearDown()) {
                            && shouldDelayImsTearDown()) {
                        logl("Delay IMS tear down until call ends. reason="
                                + tearDownReasonToString(tearDownReason));
                        break;
@@ -1249,6 +1279,14 @@ public class DataNetwork extends StateMachine {
                    transitionTo(mDisconnectingState);
                    sendMessageDelayed(EVENT_TEAR_DOWN_NETWORK, msg.arg1, msg.arg2);
                    break;
                case EVENT_VOICE_CALL_STARTED:
                case EVENT_VOICE_CALL_ENDED:
                case EVENT_CSS_INDICATOR_CHANGED:
                    // We might entered non-VoPS network. Need to update the network capability to
                    // remove MMTEL capability.
                    updateSuspendState();
                    updateNetworkCapabilities();
                    break;
                default:
                    return NOT_HANDLED;
            }
@@ -1290,6 +1328,9 @@ public class DataNetwork extends StateMachine {
                case EVENT_WAITING_FOR_TEARING_DOWN_CONDITION_MET:
                case EVENT_DISPLAY_INFO_CHANGED:
                case EVENT_TEAR_DOWN_NETWORK:
                case EVENT_CSS_INDICATOR_CHANGED:
                case EVENT_VOICE_CALL_ENDED:
                case EVENT_VOICE_CALL_STARTED:
                    // Defer the request until handover succeeds or fails.
                    deferMessage(msg);
                    break;
@@ -1414,6 +1455,14 @@ public class DataNetwork extends StateMachine {
                case EVENT_DISPLAY_INFO_CHANGED:
                    onDisplayInfoChanged();
                    break;
                case EVENT_CSS_INDICATOR_CHANGED:
                case EVENT_VOICE_CALL_STARTED:
                case EVENT_VOICE_CALL_ENDED:
                    // We might entered non-VoPS network. Need to update the network capability to
                    // remove MMTEL capability.
                    updateSuspendState();
                    updateNetworkCapabilities();
                    break;
                default:
                    return NOT_HANDLED;
            }
@@ -1679,23 +1728,21 @@ public class DataNetwork extends StateMachine {
                    .forEach(builder::addCapability);
        }

        // If voice call is on-going, do not change MMTEL capability, which is a immutable
        // capability. Changing it will result in re-recreating network agent below, and the voice
        // call will drop. Whether tearing down an IMS network or not when VoPS is lost
        if (mPhone.getImsPhone() != null && mPhone.getImsPhone().getCallTracker().getState()
                != PhoneConstants.State.IDLE && mNetworkCapabilities != null
        // If voice call is on-going, do not change MMTEL capability, which is an immutable
        // capability. Changing it will result in CS tearing down IMS network, and the voice
        // call will drop.
        if (shouldDelayImsTearDown() && mNetworkCapabilities != null
                && mNetworkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL)) {
            // Previous capability has MMTEL, so add it again.
            builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
            log("Delayed IMS tear down. Reporting MMTEL capability for now.");
        } else {
            // Always add MMTEL capability on IMS network unless network explicitly indicates VoPS
            // not supported.
            if (mDataProfile.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS)) {
                builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
                if (mTransport == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
                    NetworkRegistrationInfo nri = mPhone.getServiceStateTracker().getServiceState()
                            .getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
                                    AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                    NetworkRegistrationInfo nri = getNetworkRegistrationInfo();
                    if (nri != null) {
                        DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo();
                        // Check if VoPS is supported by the network.
@@ -1703,6 +1750,7 @@ public class DataNetwork extends StateMachine {
                                && !dsri.getVopsSupportInfo().isVopsSupported()) {
                            builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
                        }
                        log("updateNetworkCapabilities: dsri=" + dsri);
                    }
                }
            }
@@ -1899,19 +1947,6 @@ public class DataNetwork extends StateMachine {
        return mDataProfile;
    }

    /**
     * Once RIL Data Radio Technology changes, the new radio technology will be returned in
     * AsyncResult.
     * See
     * {@link com.android.internal.telephony.ServiceStateTracker#registerForDataRegStateOrRatChanged}
     *
     * @param ar RegistrationInfo: {@code Pair(drs, rat)}
     */
    private void updateDataCallSessionStatsOfDrsOrRatChange(AsyncResult ar) {
        Pair<Integer, Integer> drsRatPair = (Pair<Integer, Integer>) ar.result;
        mDataCallSessionStats.onDrsOrRatChanged(drsRatPair.second);
    }

    /**
     * Update data suspended state.
     */
@@ -1923,13 +1958,8 @@ public class DataNetwork extends StateMachine {

        boolean newSuspendedState = false;
        // Get the uncombined service state directly.
        NetworkRegistrationInfo nri = mPhone.getServiceStateTracker().getServiceState()
                .getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, mTransport);
        if (nri == null) {
            loge("Can't get network registration info for "
                    + AccessNetworkConstants.transportTypeToString(mTransport));
            return;
        }
        NetworkRegistrationInfo nri = getNetworkRegistrationInfo();
        if (nri == null) return;

        // Never set suspended for emergency apn. Emergency data connection
        // can work while device is not in service.
@@ -2296,11 +2326,12 @@ public class DataNetwork extends StateMachine {
    }

    /**
     * @return {@code true} if this tear down should be delayed until call ends on this data
     * network. For now this is specific to IMS network only.
     * @return {@code true} if this is an IMS network and tear down should be delayed until call
     * ends on this data network.
     */
    public boolean shouldDelayTearDown() {
    public boolean shouldDelayImsTearDown() {
        return mDataConfigManager.isImsDelayTearDownEnabled()
                && mNetworkCapabilities != null
                && mNetworkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
                && mPhone.getImsPhone() != null
                && mPhone.getImsPhone().getCallTracker().getState()
@@ -2639,6 +2670,20 @@ public class DataNetwork extends StateMachine {
        return new NetworkScore.Builder().setLegacyInt(score).build();
    }

    /**
     * @return Network registration info on the current transport.
     */
    private @Nullable NetworkRegistrationInfo getNetworkRegistrationInfo() {
        NetworkRegistrationInfo nri = mPhone.getServiceStateTracker().getServiceState()
                .getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, mTransport);
        if (nri == null) {
            loge("Can't get network registration info for "
                    + AccessNetworkConstants.transportTypeToString(mTransport));
            return null;
        }
        return nri;
    }

    /**
     * Get the APN type network capability. If there are more than one capabilities that are
     * APN-types, then return the highest priority one.
@@ -3059,6 +3104,12 @@ public class DataNetwork extends StateMachine {
                return "EVENT_STUCK_IN_TRANSIENT_STATE";
            case EVENT_WAITING_FOR_TEARING_DOWN_CONDITION_MET:
                return "EVENT_WAITING_FOR_TEARING_DOWN_CONDITION_MET";
            case EVENT_VOICE_CALL_STARTED:
                return "EVENT_VOICE_CALL_STARTED";
            case EVENT_VOICE_CALL_ENDED:
                return "EVENT_VOICE_CALL_ENDED";
            case EVENT_CSS_INDICATOR_CHANGED:
                return "EVENT_CSS_INDICATOR_CHANGED";
            default:
                return "Unknown(" + event + ")";
        }
+1 −26
Original line number Diff line number Diff line
@@ -892,7 +892,7 @@ public class DataNetworkController extends Handler {
                                            preferredTransport));
                            return;
                        }
                        if (dataNetwork.shouldDelayTearDown()) {
                        if (dataNetwork.shouldDelayImsTearDown()) {
                            log("onDataNetworkHandoverRetryStopped: Delay IMS tear down until call "
                                    + "ends. " + dataNetwork);
                            return;
@@ -1629,31 +1629,6 @@ public class DataNetworkController extends Handler {
            evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_RESTRICTED_BY_NETWORK);
        }

        boolean delayImsTearDown = false;
        if (dataNetwork.shouldDelayTearDown()) {
            // Some carriers requires delay tearing down IMS network until the call ends even if
            // VoPS bit is lost.
            log("Ignore VoPS bit and delay IMS tear down until call ends.");
            delayImsTearDown = true;
        }

        // Check VoPS support (except for the case that we want to delay IMS tear down until the
        // voice call ends.
        if (!delayImsTearDown
                && dataNetwork.getTransport() == AccessNetworkConstants.TRANSPORT_TYPE_WWAN
                && dataNetwork.getNetworkCapabilities().hasCapability(
                        NetworkCapabilities.NET_CAPABILITY_MMTEL)) {
            NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo(
                    NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            if (nri != null) {
                DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo();
                if (dsri != null && dsri.getVopsSupportInfo() != null
                        && !dsri.getVopsSupportInfo().isVopsSupported()) {
                    evaluation.addDataDisallowedReason(DataDisallowedReason.VOPS_NOT_SUPPORTED);
                }
            }
        }

        // Check if device is in CDMA ECBM
        if (mPhone.isInCdmaEcm()) {
            evaluation.addDataDisallowedReason(DataDisallowedReason.CDMA_EMERGENCY_CALLBACK_MODE);
+4 −2
Original line number Diff line number Diff line
@@ -2344,7 +2344,8 @@ public class DataConnection extends StateMachine {
                                + " regState=" + ServiceState.rilServiceStateToString(mDataRegState)
                                + " RAT=" + ServiceState.rilRadioTechnologyToString(mRilRat));
                    }
                    mDataCallSessionStats.onDrsOrRatChanged(mRilRat);
                    mDataCallSessionStats.onDrsOrRatChanged(
                            ServiceState.rilRadioTechnologyToNetworkType(mRilRat));
                    break;

                case EVENT_START_HANDOVER:  //calls startHandover()
@@ -3123,7 +3124,8 @@ public class DataConnection extends StateMachine {
                        mNetworkAgent.sendLinkProperties(mLinkProperties, DataConnection.this);
                    }
                    retVal = HANDLED;
                    mDataCallSessionStats.onDrsOrRatChanged(mRilRat);
                    mDataCallSessionStats.onDrsOrRatChanged(
                            ServiceState.rilRadioTechnologyToNetworkType(mRilRat));
                    break;
                }
                case EVENT_NR_FREQUENCY_CHANGED:
+1 −3
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.NetworkType;
import android.telephony.DataFailCause;
import android.telephony.ServiceState;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting.ProtocolType;
import android.telephony.data.DataCallResponse;
@@ -196,8 +195,7 @@ public class DataCallSessionStats {
     * <p>NOTE: in {@link ServiceStateTracker}, change of channel number will trigger data
     * registration state change.
     */
    public synchronized void onDrsOrRatChanged(@RilRadioTechnology int radioTechnology) {
        @NetworkType int currentRat = ServiceState.rilRadioTechnologyToNetworkType(radioTechnology);
    public synchronized void onDrsOrRatChanged(@NetworkType int currentRat) {
        if (mDataCallSession != null && currentRat != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
            if (mDataCallSession.ratAtEnd != currentRat) {
                mDataCallSession.ratSwitchCount++;
+3 −3
Original line number Diff line number Diff line
@@ -706,9 +706,9 @@ public abstract class TelephonyTest {
                anyInt(), anyBoolean());

        //Misc
        doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS).when(mServiceState).
                getRilDataRadioTechnology();
        doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UMTS,
        doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_LTE).when(mServiceState)
                .getRilDataRadioTechnology();
        doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE,
                TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE))
                .when(mDisplayInfoController).getTelephonyDisplayInfo();
        doReturn(mPhone).when(mCT).getPhone();
Loading