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

Commit df0a189f authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Send connection event on handover from WIFI to LTE.

Send a connection event when handover from wifi to LTE occurs for a video
call.  This event is only sent once, the first time it happens.

Also added a test intent which can be sent to reset the preference.

Bug: 30837560
Change-Id: Iefc2c4024d4d1956e8a9153345b6c2892bd7c38b
parent 8e3273be
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.preference.PreferenceManager;
import android.telephony.Rlog;
import android.telephony.ServiceState;

@@ -33,6 +35,7 @@ import com.android.ims.ImsReasonInfo;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.test.TestConferenceEventPackageParser;

import java.io.File;
@@ -79,6 +82,13 @@ public class TelephonyTester {
    private static final String ACTION_TEST_HANDOVER_FAIL =
            "com.android.internal.telephony.TestHandoverFail";

    /**
     * Test-only intent used to reset the shared preference associated with
     * {@link android.telephony.CarrierConfigManager#KEY_NOTIFY_VT_HANDOVER_TO_WIFI_FAILURE_BOOL}.
     */
    private static final String ACTION_RESET_HANDOVER_NOTICE =
            "com.android.internal.telephony.ResetHandoverNotice";

    private static List<ImsExternalCallState> mImsExternalCallStates = null;

    private Phone mPhone;
@@ -105,6 +115,10 @@ public class TelephonyTester {
            } else if (action.equals(ACTION_TEST_HANDOVER_FAIL)) {
                log("handle handover fail test intent");
                handleHandoverFailedIntent();
            } else if (action.equals(ACTION_RESET_HANDOVER_NOTICE)) {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
                sp.edit().putBoolean(ImsPhoneCallTracker.NOTIFIED_HANDOVER_TO_LTE_KEY, false)
                        .commit();
            } else {
                if (DBG) log("onReceive: unknown action=" + action);
            }
@@ -128,6 +142,7 @@ public class TelephonyTester {
                filter.addAction(ACTION_TEST_CONFERENCE_EVENT_PACKAGE);
                filter.addAction(ACTION_TEST_DIALOG_EVENT_PACKAGE);
                filter.addAction(ACTION_TEST_HANDOVER_FAIL);
                filter.addAction(ACTION_RESET_HANDOVER_NOTICE);
                mImsExternalCallStates = new ArrayList<ImsExternalCallState>();
            }

+57 −0
Original line number Diff line number Diff line
@@ -101,6 +101,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    // calls.  This is helpful for debugging.
    private static final boolean VERBOSE_STATE_LOGGING = false; /* stopship if true */

    /**
     * Shared preferences key used to track whether the user has been notified of the fact that a
     * video call has been handed over from WIFI to LTE.
     */
    public static final String NOTIFIED_HANDOVER_TO_LTE_KEY = "notified_handover_video_to_lte_key";

    //Indices map to ImsConfig.FeatureConstants
    private boolean[] mImsFeatureEnabled = {false, false, false, false, false, false};
    private final String[] mImsFeatureStrings = {"VoLTE", "ViLTE", "VoWiFi", "ViWiFi",
@@ -296,6 +302,14 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
     */
    private boolean mSupportDowngradeVtToAudio = false;

    /**
     * Carrier configuration option which determines whether the carrier wants to inform the user
     * when a video call is handed over from WIFI to LTE.
     * See {@link CarrierConfigManager#KEY_NOTIFY_HANDOVER_VIDEO_FROM_WIFI_TO_LTE_BOOL} for more
     * information.
     */
    private boolean mNotifyHandoverVideoFromWifiToLTE = false;

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

        String[] mappings = carrierConfig
                .getStringArray(CarrierConfigManager.KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY);
@@ -1865,6 +1881,27 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                removeMessages(EVENT_CHECK_FOR_WIFI_HANDOVER);
            }

            boolean isHandoverFromWifi =
                    srcAccessTech == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN &&
                            targetAccessTech != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
            if (mNotifyHandoverVideoFromWifiToLTE && isHandoverFromWifi && imsCall.isVideoCall()) {
                if (!hasNotifiedHandoverVideoFromWifiToLTE() ) {
                    log("onCallHandover :: notifying of WIFI to LTE handover.");
                    ImsPhoneConnection conn = findConnection(imsCall);
                    if (conn != null) {
                        conn.onConnectionEvent(
                                TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE,
                                null);
                        setNotifiedHandoverVideoFromWifiToLTE(true);
                    } else {
                        loge("onCallHandover :: failed to notify of handover; connection is null.");
                    }

                } else {
                    log("onCallHandover :: already notified of WIFI to LTE handover.");
                }
            }

            mEventLog.writeOnImsCallHandover(imsCall.getCallSession(),
                    srcAccessTech, targetAccessTech, reasonInfo);
        }
@@ -2707,4 +2744,24 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    public boolean isCarrierDowngradeOfVtCallSupported() {
        return mSupportDowngradeVtToAudio;
    }

    /**
     * @return {@code true} if the user has been previously notified of a video call which has been
     *      handed over from WIFI to LTE, {@code false} otherwise.
     */
    private boolean hasNotifiedHandoverVideoFromWifiToLTE() {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
        return sp.getBoolean(NOTIFIED_HANDOVER_TO_LTE_KEY, false);
    }

    /**
     * Sets whether the user has been notified of the fact a video call has been handed over from
     * WIFI to LTE.  Saved to shared preferences.
     *
     * @param notified {@code true} if the user has been notified, {@code false} otherwise.
     */
    private void setNotifiedHandoverVideoFromWifiToLTE(boolean notified) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
        sp.edit().putBoolean(NOTIFIED_HANDOVER_TO_LTE_KEY, notified).commit();
    }
}