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

Commit 8e3273be authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Add support for downgrade to audio when data limit is reached." into nyc-mr1-dev

parents d5b505aa 2e7e09e7
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,7 @@ public abstract class Connection {
        public void onExitedEcmMode();
        public void onExitedEcmMode();
        public void onCallPullFailed(Connection externalConnection);
        public void onCallPullFailed(Connection externalConnection);
        public void onHandoverToWifiFailed();
        public void onHandoverToWifiFailed();
        public void onConnectionEvent(String event, Bundle extras);
    }
    }


    /**
    /**
@@ -133,6 +134,8 @@ public abstract class Connection {
        public void onCallPullFailed(Connection externalConnection) {}
        public void onCallPullFailed(Connection externalConnection) {}
        @Override
        @Override
        public void onHandoverToWifiFailed() {}
        public void onHandoverToWifiFailed() {}
        @Override
        public void onConnectionEvent(String event, Bundle extras) {}
    }
    }


    public static final int AUDIO_QUALITY_STANDARD = 1;
    public static final int AUDIO_QUALITY_STANDARD = 1;
@@ -658,6 +661,13 @@ public abstract class Connection {
        return mConnectionCapabilities;
        return mConnectionCapabilities;
    }
    }


    /**
     * @return {@code} true if the connection has the specified capabilities.
     */
    public boolean hasCapabilities(int connectionCapabilities) {
        return (mConnectionCapabilities & connectionCapabilities) == connectionCapabilities;
    }

    /**
    /**
     * Applies a capability to a capabilities bit-mask.
     * Applies a capability to a capabilities bit-mask.
     *
     *
@@ -950,6 +960,15 @@ public abstract class Connection {
        }
        }
    }
    }


    /**
     * Notifies the connection of a connection event.
     */
    public void onConnectionEvent(String event, Bundle extras) {
        for (Listener l : mListeners) {
            l.onConnectionEvent(event, extras);
        }
    }

    /**
    /**
     * Notifies this Connection of a request to disconnect a participant of the conference managed
     * Notifies this Connection of a request to disconnect a participant of the conference managed
     * by the connection.
     * by the connection.
+38 −4
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.preference.PreferenceManager;
import android.preference.PreferenceManager;
import android.telecom.ConferenceParticipant;
import android.telecom.ConferenceParticipant;
@@ -289,6 +290,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
     */
     */
    private boolean mNotifyVtHandoverToWifiFail = false;
    private boolean mNotifyVtHandoverToWifiFail = false;


    /**
     * Carrier configuration option which determines whether the carrier supports downgrading a
     * TX/RX/TX-RX video call directly to an audio-only call.
     */
    private boolean mSupportDowngradeVtToAudio = false;

    /**
    /**
     * Carrier configuration option which defines a mapping from pairs of
     * Carrier configuration option which defines a mapping from pairs of
     * {@link ImsReasonInfo#getCode()} and {@link ImsReasonInfo#getExtraMessage()} values to a new
     * {@link ImsReasonInfo#getCode()} and {@link ImsReasonInfo#getExtraMessage()} values to a new
@@ -543,6 +550,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                        CarrierConfigManager.KEY_ALLOW_ADD_CALL_DURING_VIDEO_CALL_BOOL);
                        CarrierConfigManager.KEY_ALLOW_ADD_CALL_DURING_VIDEO_CALL_BOOL);
        mNotifyVtHandoverToWifiFail = carrierConfig.getBoolean(
        mNotifyVtHandoverToWifiFail = carrierConfig.getBoolean(
                CarrierConfigManager.KEY_NOTIFY_VT_HANDOVER_TO_WIFI_FAILURE_BOOL);
                CarrierConfigManager.KEY_NOTIFY_VT_HANDOVER_TO_WIFI_FAILURE_BOOL);
        mSupportDowngradeVtToAudio = carrierConfig.getBoolean(
                CarrierConfigManager.KEY_SUPPORT_DOWNGRADE_VT_TO_AUDIO_BOOL);


        String[] mappings = carrierConfig
        String[] mappings = carrierConfig
                .getStringArray(CarrierConfigManager.KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY);
                .getStringArray(CarrierConfigManager.KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY);
@@ -2645,6 +2654,23 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            for (ImsPhoneConnection conn : mConnections) {
            for (ImsPhoneConnection conn : mConnections) {
                ImsCall imsCall = conn.getImsCall();
                ImsCall imsCall = conn.getImsCall();
                if (imsCall != null && imsCall.isVideoCall() && !imsCall.isWifiCall()) {
                if (imsCall != null && imsCall.isVideoCall() && !imsCall.isWifiCall()) {
                    if (conn.hasCapabilities(
                            Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL |
                                    Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE)) {

                        // If the carrier supports downgrading to voice, then we can simply issue a
                        // downgrade to voice instead of terminating the call.
                        if (reasonCode == ImsReasonInfo.CODE_DATA_DISABLED) {
                            conn.onConnectionEvent(TelephonyManager.EVENT_DOWNGRADE_DATA_DISABLED,
                                    null);
                        } else if (reasonCode == ImsReasonInfo.CODE_DATA_LIMIT_REACHED) {
                            conn.onConnectionEvent(
                                    TelephonyManager.EVENT_DOWNGRADE_DATA_LIMIT_REACHED, null);
                        }
                        modifyVideoCall(imsCall, VideoProfile.STATE_AUDIO_ONLY);
                    } else {
                        // If the carrier does not support downgrading to voice, the only choice we
                        // have is to terminate the call.
                        try {
                        try {
                            imsCall.terminate(ImsReasonInfo.CODE_USER_TERMINATED, reasonCode);
                            imsCall.terminate(ImsReasonInfo.CODE_USER_TERMINATED, reasonCode);
                        } catch (ImsException ie) {
                        } catch (ImsException ie) {
@@ -2653,6 +2679,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                    }
                    }
                }
                }
            }
            }
        }


        // This will call into updateVideoCallFeatureValue and eventually all clients will be
        // This will call into updateVideoCallFeatureValue and eventually all clients will be
        // asynchronously notified that the availability of VT over LTE has changed.
        // asynchronously notified that the availability of VT over LTE has changed.
@@ -2673,4 +2700,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        }
        }
        return false;
        return false;
    }
    }

    /**
     * @return {@code true} if downgrading of a video call to audio is supported.
     */
    public boolean isCarrierDowngradeOfVtCallSupported() {
        return mSupportDowngradeVtToAudio;
    }
}
}
+20 −14
Original line number Original line Diff line number Diff line
@@ -233,38 +233,32 @@ public class ImsPhoneConnection extends Connection implements
    }
    }


    private static int applyLocalCallCapabilities(ImsCallProfile localProfile, int capabilities) {
    private static int applyLocalCallCapabilities(ImsCallProfile localProfile, int capabilities) {
        Rlog.w(LOG_TAG, "applyLocalCallCapabilities - localProfile = "+localProfile);
        capabilities = removeCapability(capabilities,
        capabilities = removeCapability(capabilities,
                Connection.Capability.SUPPORTS_VT_LOCAL_BIDIRECTIONAL
                Connection.Capability.SUPPORTS_VT_LOCAL_BIDIRECTIONAL);
                | Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);


        switch (localProfile.mCallType) {
        switch (localProfile.mCallType) {
            case ImsCallProfile.CALL_TYPE_VT:
            case ImsCallProfile.CALL_TYPE_VT:
                capabilities = addCapability(capabilities,
                // Fall-through
                        Connection.Capability.SUPPORTS_VT_LOCAL_BIDIRECTIONAL);
                break;
            case ImsCallProfile.CALL_TYPE_VIDEO_N_VOICE:
            case ImsCallProfile.CALL_TYPE_VIDEO_N_VOICE:
                capabilities = addCapability(capabilities,
                capabilities = addCapability(capabilities,
                        Connection.Capability.SUPPORTS_VT_LOCAL_BIDIRECTIONAL
                        Connection.Capability.SUPPORTS_VT_LOCAL_BIDIRECTIONAL);
                        | Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);
                break;
                break;
        }
        }
        return capabilities;
        return capabilities;
    }
    }


    private static int applyRemoteCallCapabilities(ImsCallProfile remoteProfile, int capabilities) {
    private static int applyRemoteCallCapabilities(ImsCallProfile remoteProfile, int capabilities) {
        Rlog.w(LOG_TAG, "applyRemoteCallCapabilities - remoteProfile = "+remoteProfile);
        capabilities = removeCapability(capabilities,
        capabilities = removeCapability(capabilities,
                Connection.Capability.SUPPORTS_VT_REMOTE_BIDIRECTIONAL
                Connection.Capability.SUPPORTS_VT_REMOTE_BIDIRECTIONAL);
                | Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE);


        switch (remoteProfile.mCallType) {
        switch (remoteProfile.mCallType) {
            case ImsCallProfile.CALL_TYPE_VT:
            case ImsCallProfile.CALL_TYPE_VT:
                capabilities = addCapability(capabilities,
                // fall-through
                        Connection.Capability.SUPPORTS_VT_REMOTE_BIDIRECTIONAL);
                break;
            case ImsCallProfile.CALL_TYPE_VIDEO_N_VOICE:
            case ImsCallProfile.CALL_TYPE_VIDEO_N_VOICE:
                capabilities = addCapability(capabilities,
                capabilities = addCapability(capabilities,
                        Connection.Capability.SUPPORTS_VT_REMOTE_BIDIRECTIONAL
                        Connection.Capability.SUPPORTS_VT_REMOTE_BIDIRECTIONAL);
                        | Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE);
                break;
                break;
        }
        }
        return capabilities;
        return capabilities;
@@ -841,6 +835,18 @@ public class ImsPhoneConnection extends Connection implements
            // Check for a change in the capabilities for the call and update
            // Check for a change in the capabilities for the call and update
            // {@link ImsPhoneConnection} with this information.
            // {@link ImsPhoneConnection} with this information.
            int capabilities = getConnectionCapabilities();
            int capabilities = getConnectionCapabilities();

            // Use carrier config to determine if downgrading directly to audio-only is supported.
            if (mOwner.isCarrierDowngradeOfVtCallSupported()) {
                capabilities = addCapability(capabilities,
                        Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE |
                                Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);
            } else {
                capabilities = removeCapability(capabilities,
                        Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE |
                                Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);
            }

            // Get the current local call capabilities which might be voice or video or both.
            // Get the current local call capabilities which might be voice or video or both.
            ImsCallProfile localCallProfile = imsCall.getLocalCallProfile();
            ImsCallProfile localCallProfile = imsCall.getLocalCallProfile();
            Rlog.v(LOG_TAG, "update localCallProfile=" + localCallProfile);
            Rlog.v(LOG_TAG, "update localCallProfile=" + localCallProfile);