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

Commit 2f9f55d5 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Drop video calls when data is disabled.

Handle dropping of video calls for one of two reasons:
1. User disables data.
2. User exceeds the data limit policy on their device.

In both cases, terminate any ongoing video calls.  Ensures the correct
disconnect cause is propagated up to the InCallService.

Bug: 30702393
Change-Id: I36d236c8f69f9dc5b17368cc5329ac1df991fac4
parent 508daf6f
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -28,15 +28,15 @@ import android.util.Pair;
 */
public class DataEnabledSettings {

    private static final int REASON_REGISTERED = 0;
    public static final int REASON_REGISTERED = 0;

    private static final int REASON_INTERNAL_DATA_ENABLED = 1;
    public static final int REASON_INTERNAL_DATA_ENABLED = 1;

    private static final int REASON_USER_DATA_ENABLED = 2;
    public static final int REASON_USER_DATA_ENABLED = 2;

    private static final int REASON_POLICY_DATA_ENABLED = 3;
    public static final int REASON_POLICY_DATA_ENABLED = 3;

    private static final int REASON_DATA_ENABLED_BY_CARRIER = 4;
    public static final int REASON_DATA_ENABLED_BY_CARRIER = 4;

    /**
     * responds to the setInternalDataEnabled call - used internally to turn off data.
+28 −5
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyEventLog;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.dataconnection.DataEnabledSettings;
import com.android.internal.telephony.gsm.SuppServiceNotification;

/**
@@ -1362,6 +1363,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {

            case ImsReasonInfo.CODE_MAXIMUM_NUMBER_OF_CALLS_REACHED:
                return DisconnectCause.MAXIMUM_NUMBER_OF_CALLS_REACHED;

            case ImsReasonInfo.CODE_DATA_DISABLED:
                return DisconnectCause.DATA_DISABLED;

            case ImsReasonInfo.CODE_DATA_LIMIT_REACHED:
                return DisconnectCause.DATA_LIMIT_REACHED;
            default:
        }

@@ -2613,20 +2620,36 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    /**
     * Handler of data enabled changed event
     * @param enabled True if data is enabled, otherwise disabled.
     * @param reason Reason for data enabled/disabled
     * @param reason Reason for data enabled/disabled (see {@code REASON_*} in
     *      {@link DataEnabledSettings}.
     */
    private void onDataEnabledChanged(boolean enabled, int reason) {

        log("onDataEnabledChanged: enabled=" + enabled + ", reason=" + reason);
        ImsManager.getInstance(mPhone.getContext(), mPhone.getPhoneId()).setDataEnabled(enabled);

        if (enabled == false) {
            // If data are disabled while there are ongoing VT calls, we need to downgrade
            // the VT calls (except on VT over Wifi)
        if (!enabled) {
            int reasonCode;
            if (reason == DataEnabledSettings.REASON_POLICY_DATA_ENABLED) {
                reasonCode = ImsReasonInfo.CODE_DATA_LIMIT_REACHED;
            } else if (reason == DataEnabledSettings.REASON_USER_DATA_ENABLED) {
                reasonCode = ImsReasonInfo.CODE_DATA_DISABLED;
            } else {
                // Unexpected code, default to data disabled.
                reasonCode = ImsReasonInfo.CODE_DATA_DISABLED;
            }

            // If data is disabled while there are ongoing VT calls which are not taking place over
            // wifi, then they should be disconnected to prevent the user from incurring further
            // data charges.
            for (ImsPhoneConnection conn : mConnections) {
                ImsCall imsCall = conn.getImsCall();
                if (imsCall != null && imsCall.isVideoCall() && !imsCall.isWifiCall()) {
                    modifyVideoCall(imsCall, VideoProfile.STATE_AUDIO_ONLY);
                    try {
                        imsCall.terminate(ImsReasonInfo.CODE_USER_TERMINATED, reasonCode);
                    } catch (ImsException ie) {
                        loge("Couldn't terminate call " + imsCall);
                    }
                }
            }
        }