aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-02-08 04:15:32 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-02-08 04:15:32 +0000
commitaf698d7b957dccc8971f7b9524117288f554a03e (patch)
tree737615ab1b94828e539a9a7fbb0c75669229cd1c
parent551e63a25455174ee5da8bf7d9439c4046ca8f38 (diff)
parent8d9cccc1c22f8404bf7780c1d965a8ba7afae1e2 (diff)
downloadtelephony-oreo-mr1-cuttlefish-testing.tar.gz
Merge cherrypicks of [3581037, 3581038, 3580473, 3580624, 3580656, 3580657, 3580658, 3580382, 3580474, 3580475, 3581039, 3581040, 3580476, 3580206, 3581527, 3580955, 3580956, 3580957, 3580958, 3580959, 3580960, 3580961, 3580962, 3580963, 3580964, 3580965, 3580966, 3581567, 3581568, 3581569, 3581570, 3581571, 3580625, 3580626, 3581587, 3581513, 3581514, 3581515, 3580477, 3581588, 3580659, 3580660, 3580383, 3580384, 3580478, 3580719, 3580479, 3580480, 3581385, 3581528, 3581041, 3581042, 3581043, 3581044, 3581045, 3581046, 3581607, 3580385, 3580481, 3580482, 3580483, 3580661, 3580662, 3580663, 3580664, 3580665, 3580484, 3580485, 3581608, 3581609, 3581610, 3581611, 3581612, 3581589, 3581613, 3580486, 3581519, 3581627, 3581628, 3581529, 3581530, 3581531, 3581629, 3581630] into oc-mr1-releaseandroid-wear-8.1.0_r1android-8.1.0_r19oreo-mr1-wear-releaseoreo-mr1-releaseoreo-mr1-cuttlefish-testing
Change-Id: Ie460ffdf2ca9b51145f787a24709faf834669480
-rw-r--r--src/java/com/android/internal/telephony/InboundSmsHandler.java4
-rw-r--r--src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java204
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java3
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java65
4 files changed, 254 insertions, 22 deletions
diff --git a/src/java/com/android/internal/telephony/InboundSmsHandler.java b/src/java/com/android/internal/telephony/InboundSmsHandler.java
index 391de50019..2d663cd713 100644
--- a/src/java/com/android/internal/telephony/InboundSmsHandler.java
+++ b/src/java/com/android/internal/telephony/InboundSmsHandler.java
@@ -165,9 +165,9 @@ public abstract class InboundSmsHandler extends StateMachine {
* state */
private static final int EVENT_STATE_TIMEOUT = 10;
- /** Timeout duration for EVENT_STATE_TIMEOUT */
+ /** Timeout duration for EVENT_STATE_TIMEOUT (5 minutes) */
@VisibleForTesting
- public static final int STATE_TIMEOUT = 30000;
+ public static final int STATE_TIMEOUT = 5 * 60 * 1000;
/** Wakelock release delay when returning to idle state. */
private static final int WAKELOCK_TIMEOUT = 3000;
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
index 072da68ed9..bdb1e11863 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
@@ -24,7 +24,10 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
+import android.net.NetworkRequest;
import android.net.NetworkStats;
import android.net.Uri;
import android.os.AsyncResult;
@@ -227,6 +230,24 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
}
};
+ /**
+ * Tracks whether we are currently monitoring network connectivity for the purpose of warning
+ * the user of an inability to handover from LTE to WIFI for video calls.
+ */
+ private boolean mIsMonitoringConnectivity = false;
+
+ /**
+ * Network callback used to schedule the handover check when a wireless network connects.
+ */
+ private ConnectivityManager.NetworkCallback mNetworkCallback =
+ new ConnectivityManager.NetworkCallback() {
+ @Override
+ public void onAvailable(Network network) {
+ Rlog.i(LOG_TAG, "Network available: " + network);
+ scheduleHandoverCheck();
+ }
+ };
+
//***** Constants
static final int MAX_CONNECTIONS = 7;
@@ -580,6 +601,22 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
private boolean mNotifyHandoverVideoFromWifiToLTE = false;
/**
+ * Carrier configuration option which determines whether the carrier wants to inform the user
+ * when a video call is handed over from LTE to WIFI.
+ * See {@link CarrierConfigManager#KEY_NOTIFY_HANDOVER_VIDEO_FROM_LTE_TO_WIFI_BOOL} for more
+ * information.
+ */
+ private boolean mNotifyHandoverVideoFromLTEToWifi = false;
+
+ /**
+ * When {@code} false, indicates that no handover from LTE to WIFI has occurred during the start
+ * of the call.
+ * When {@code true}, indicates that the start of call handover from LTE to WIFI has been
+ * attempted (it may have suceeded or failed).
+ */
+ private boolean mHasPerformedStartOfCallHandover = false;
+
+ /**
* Carrier configuration option which determines whether the carrier supports the
* {@link VideoProfile#STATE_PAUSED} signalling.
* See {@link CarrierConfigManager#KEY_SUPPORT_PAUSE_IMS_VIDEO_CALLS_BOOL} for more information.
@@ -986,6 +1023,16 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
return;
}
+ updateCarrierConfigCache(carrierConfig);
+ }
+
+ /**
+ * Updates the local carrier config cache from a bundle obtained from the carrier config
+ * manager. Also supports unit testing by injecting configuration at test time.
+ * @param carrierConfig The config bundle.
+ */
+ @VisibleForTesting
+ public void updateCarrierConfigCache(PersistableBundle carrierConfig) {
mAllowEmergencyVideoCalls =
carrierConfig.getBoolean(CarrierConfigManager.KEY_ALLOW_EMERGENCY_VIDEO_CALLS_BOOL);
mTreatDowngradedVideoCallsAsVideoCalls =
@@ -1003,6 +1050,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
CarrierConfigManager.KEY_SUPPORT_DOWNGRADE_VT_TO_AUDIO_BOOL);
mNotifyHandoverVideoFromWifiToLTE = carrierConfig.getBoolean(
CarrierConfigManager.KEY_NOTIFY_HANDOVER_VIDEO_FROM_WIFI_TO_LTE_BOOL);
+ mNotifyHandoverVideoFromLTEToWifi = carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_NOTIFY_HANDOVER_VIDEO_FROM_LTE_TO_WIFI_BOOL);
mIgnoreDataEnabledChangedForVideoCalls = carrierConfig.getBoolean(
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS);
mIsViLteDataMetered = carrierConfig.getBoolean(
@@ -2016,13 +2065,18 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
processCallStateChange(imsCall, ImsPhoneCall.State.ACTIVE,
DisconnectCause.NOT_DISCONNECTED);
- if (mNotifyVtHandoverToWifiFail &&
- !imsCall.isWifiCall() && imsCall.isVideoCall() && isWifiConnected()) {
- // Schedule check to see if handover succeeded.
- sendMessageDelayed(obtainMessage(EVENT_CHECK_FOR_WIFI_HANDOVER, imsCall),
- HANDOVER_TO_WIFI_TIMEOUT_MS);
+ if (mNotifyVtHandoverToWifiFail && imsCall.isVideoCall() && !imsCall.isWifiCall()) {
+ if (isWifiConnected()) {
+ // Schedule check to see if handover succeeded.
+ sendMessageDelayed(obtainMessage(EVENT_CHECK_FOR_WIFI_HANDOVER, imsCall),
+ HANDOVER_TO_WIFI_TIMEOUT_MS);
+ } else {
+ // No wifi connectivity, so keep track of network availability for potential
+ // handover.
+ registerForConnectivityChanges();
+ }
}
-
+ mHasPerformedStartOfCallHandover = false;
mMetrics.writeOnImsCallStarted(mPhone.getPhoneId(), imsCall.getCallSession());
}
@@ -2538,23 +2592,48 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
boolean isHandoverToWifi = srcAccessTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN
&& srcAccessTech != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
&& targetAccessTech == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
- if (isHandoverToWifi) {
- // If we handed over to wifi successfully, don't check for failure in the future.
- removeMessages(EVENT_CHECK_FOR_WIFI_HANDOVER);
- }
+ // Only consider it a handover from WIFI if the source and target radio tech is known.
+ boolean isHandoverFromWifi =
+ srcAccessTech == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
+ && targetAccessTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN
+ && targetAccessTech != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
ImsPhoneConnection conn = findConnection(imsCall);
if (conn != null) {
- // Only consider it a handover from WIFI if the source and target radio tech is known.
- boolean isHandoverFromWifi =
- srcAccessTech == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
- && targetAccessTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN
- && targetAccessTech != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
+ if (conn.getDisconnectCause() == DisconnectCause.NOT_DISCONNECTED) {
+ if (isHandoverToWifi) {
+ removeMessages(EVENT_CHECK_FOR_WIFI_HANDOVER);
+
+ if (mNotifyHandoverVideoFromLTEToWifi && mHasPerformedStartOfCallHandover) {
+ // This is a handover which happened mid-call (ie not the start of call
+ // handover from LTE to WIFI), so we'll notify the InCall UI.
+ conn.onConnectionEvent(
+ TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_LTE_TO_WIFI, null);
+ }
+
+ // We are on WIFI now so no need to get notified of network availability.
+ unregisterForConnectivityChanges();
+ } else if (isHandoverFromWifi && imsCall.isVideoCall()) {
+ // A video call just dropped from WIFI to LTE; we want to be informed if a
+ // new WIFI
+ // network comes into range.
+ registerForConnectivityChanges();
+ }
+ }
+
if (isHandoverFromWifi && imsCall.isVideoCall()) {
if (mNotifyHandoverVideoFromWifiToLTE && mIsDataEnabled) {
- log("onCallHandover :: notifying of WIFI to LTE handover.");
- conn.onConnectionEvent(
- TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE, null);
+ if (conn.getDisconnectCause() == DisconnectCause.NOT_DISCONNECTED) {
+ log("onCallHandover :: notifying of WIFI to LTE handover.");
+ conn.onConnectionEvent(
+ TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE, null);
+ } else {
+ // Call has already had a disconnect request issued by the user or is
+ // in the process of disconnecting; do not inform the UI of this as it
+ // is not relevant.
+ log("onCallHandover :: skip notify of WIFI to LTE handover for "
+ + "disconnected call.");
+ }
}
if (!mIsDataEnabled && mIsViLteDataMetered) {
@@ -2567,6 +2646,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
loge("onCallHandover :: connection null.");
}
+ if (!mHasPerformedStartOfCallHandover) {
+ mHasPerformedStartOfCallHandover = true;
+ }
mMetrics.writeOnImsCallHandoverEvent(mPhone.getPhoneId(),
TelephonyCallSession.Event.Type.IMS_CALL_HANDOVER, imsCall.getCallSession(),
srcAccessTech, targetAccessTech, reasonInfo);
@@ -2592,11 +2674,20 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
// If we know we failed to handover, don't check for failure in the future.
removeMessages(EVENT_CHECK_FOR_WIFI_HANDOVER);
+ if (imsCall.isVideoCall()
+ && conn.getDisconnectCause() == DisconnectCause.NOT_DISCONNECTED) {
+ // Start listening for a WIFI network to come into range for potential handover.
+ registerForConnectivityChanges();
+ }
+
if (mNotifyVtHandoverToWifiFail) {
// Only notify others if carrier config indicates to do so.
conn.onHandoverToWifiFailed();
}
}
+ if (!mHasPerformedStartOfCallHandover) {
+ mHasPerformedStartOfCallHandover = true;
+ }
}
@Override
@@ -2674,6 +2765,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
public void onCallTerminated(ImsCall imsCall, ImsReasonInfo reasonInfo) {
if (DBG) log("mImsUssdListener onCallTerminated reasonCode=" + reasonInfo.getCode());
removeMessages(EVENT_CHECK_FOR_WIFI_HANDOVER);
+ mHasPerformedStartOfCallHandover = false;
+ unregisterForConnectivityChanges();
if (imsCall == mUssdSession) {
mUssdSession = null;
@@ -2942,12 +3035,24 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
case EVENT_CHECK_FOR_WIFI_HANDOVER:
if (msg.obj instanceof ImsCall) {
ImsCall imsCall = (ImsCall) msg.obj;
+ if (imsCall != mForegroundCall.getImsCall()) {
+ Rlog.i(LOG_TAG, "handoverCheck: no longer FG; check skipped.");
+ unregisterForConnectivityChanges();
+ // Handover check and its not the foreground call any more.
+ return;
+ }
if (!imsCall.isWifiCall()) {
// Call did not handover to wifi, notify of handover failure.
ImsPhoneConnection conn = findConnection(imsCall);
if (conn != null) {
+ Rlog.i(LOG_TAG, "handoverCheck: handover failed.");
conn.onHandoverToWifiFailed();
}
+
+ if (imsCall.isVideoCall()
+ && conn.getDisconnectCause() == DisconnectCause.NOT_DISCONNECTED) {
+ registerForConnectivityChanges();
+ }
}
}
break;
@@ -3559,12 +3664,75 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
}
/**
+ * Registers for changes to network connectivity. Specifically requests the availability of new
+ * WIFI networks which an IMS video call could potentially hand over to.
+ */
+ private void registerForConnectivityChanges() {
+ if (mIsMonitoringConnectivity || !mNotifyVtHandoverToWifiFail) {
+ return;
+ }
+ ConnectivityManager cm = (ConnectivityManager) mPhone.getContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (cm != null) {
+ Rlog.i(LOG_TAG, "registerForConnectivityChanges");
+ NetworkCapabilities capabilities = new NetworkCapabilities();
+ capabilities.addTransportType(NetworkCapabilities.TRANSPORT_WIFI);
+ NetworkRequest.Builder builder = new NetworkRequest.Builder();
+ builder.setCapabilities(capabilities);
+ cm.registerNetworkCallback(builder.build(), mNetworkCallback);
+ mIsMonitoringConnectivity = true;
+ }
+ }
+
+ /**
+ * Unregister for connectivity changes. Will be called when a call disconnects or if the call
+ * ends up handing over to WIFI.
+ */
+ private void unregisterForConnectivityChanges() {
+ if (!mIsMonitoringConnectivity || !mNotifyVtHandoverToWifiFail) {
+ return;
+ }
+ ConnectivityManager cm = (ConnectivityManager) mPhone.getContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (cm != null) {
+ Rlog.i(LOG_TAG, "unregisterForConnectivityChanges");
+ cm.unregisterNetworkCallback(mNetworkCallback);
+ mIsMonitoringConnectivity = false;
+ }
+ }
+
+ /**
+ * If the foreground call is a video call, schedule a handover check if one is not already
+ * scheduled. This method is intended ONLY for use when scheduling to watch for mid-call
+ * handovers.
+ */
+ private void scheduleHandoverCheck() {
+ ImsCall fgCall = mForegroundCall.getImsCall();
+ ImsPhoneConnection conn = mForegroundCall.getFirstConnection();
+ if (!mNotifyVtHandoverToWifiFail || fgCall == null || !fgCall.isVideoCall() || conn == null
+ || conn.getDisconnectCause() != DisconnectCause.NOT_DISCONNECTED) {
+ return;
+ }
+
+ if (!hasMessages(EVENT_CHECK_FOR_WIFI_HANDOVER)) {
+ Rlog.i(LOG_TAG, "scheduleHandoverCheck: schedule");
+ sendMessageDelayed(obtainMessage(EVENT_CHECK_FOR_WIFI_HANDOVER, fgCall),
+ HANDOVER_TO_WIFI_TIMEOUT_MS);
+ }
+ }
+
+ /**
* @return {@code true} if downgrading of a video call to audio is supported.
*/
public boolean isCarrierDowngradeOfVtCallSupported() {
return mSupportDowngradeVtToAudio;
}
+ @VisibleForTesting
+ public void setDataEnabled(boolean isDataEnabled) {
+ mIsDataEnabled = isDataEnabled;
+ }
+
private void handleFeatureCapabilityChanged(int serviceClass,
int[] enabledFeatures, int[] disabledFeatures) {
if (serviceClass == ImsServiceClass.MMTEL) {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
index 02758ac397..6e14acada1 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
@@ -47,6 +47,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Telephony;
import android.support.test.filters.FlakyTest;
+import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest;
import android.test.mock.MockContentResolver;
@@ -785,7 +786,7 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest {
@FlakyTest
@Ignore
@Test
- @MediumTest
+ @LargeTest
public void testWaitingStateTimeout() throws Exception {
transitionFromStartupToIdle();
diff --git a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java
index 989cd64c32..71f4cc4f2e 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.isNull;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -42,10 +43,14 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
+import android.os.PersistableBundle;
import android.support.test.filters.FlakyTest;
import android.telecom.VideoProfile;
+import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
+import android.telephony.ServiceState;
+import android.telephony.TelephonyManager;
import android.telephony.ims.feature.ImsFeature;
import android.test.suitebuilder.annotation.SmallTest;
@@ -88,6 +93,8 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
private ImsCallSession mImsCallSession;
@Mock
private SharedPreferences mSharedPreferences;
+ @Mock
+ private ImsPhoneConnection.Listener mImsPhoneConnectionListener;
private Handler mCTHander;
private class ImsCTHandlerThread extends HandlerThread {
@@ -103,6 +110,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
ImsReasonInfo.CODE_ANSWERED_ELSEWHERE);
mCTUT.addReasonCodeRemapping(510, "Call answered elsewhere.",
ImsReasonInfo.CODE_ANSWERED_ELSEWHERE);
+ mCTUT.setDataEnabled(true);
mCTHander = new Handler(mCTUT.getLooper());
setReady(true);
}
@@ -156,7 +164,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
}
}).when(mImsCall).hold();
- doReturn(mImsCallSession).when(mImsCall).getCallSession();
+ mImsCall.attachSession(mImsCallSession);
}
@Before
@@ -167,6 +175,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
mImsManagerInstances.put(mImsPhone.getPhoneId(), mImsManager);
mImsCall = spy(new ImsCall(mContext, mImsCallProfile));
mSecondImsCall = spy(new ImsCall(mContext, mImsCallProfile));
+ mImsPhoneConnectionListener = mock(ImsPhoneConnection.Listener.class);
imsCallMocking(mImsCall);
imsCallMocking(mSecondImsCall);
doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceStatus();
@@ -189,6 +198,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
public ImsCall answer(InvocationOnMock invocation) throws Throwable {
mImsCallListener =
(ImsCall.Listener) invocation.getArguments()[2];
+ mImsCall.setListener(mImsCallListener);
return mImsCall;
}
}).when(mImsManager).takeCall(eq(mServiceId), (Intent) any(), (ImsCall.Listener) any());
@@ -198,6 +208,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
public ImsCall answer(InvocationOnMock invocation) throws Throwable {
mImsCallListener =
(ImsCall.Listener) invocation.getArguments()[3];
+ mSecondImsCall.setListener(mImsCallListener);
return mSecondImsCall;
}
}).when(mImsManager).makeCall(eq(mServiceId), eq(mImsCallProfile), (String []) any(),
@@ -262,6 +273,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
assertEquals(PhoneConstants.State.RINGING, mCTUT.getState());
assertTrue(mCTUT.mRingingCall.isRinging());
assertEquals(1, mCTUT.mRingingCall.getConnections().size());
+ ImsPhoneConnection connection =
+ (ImsPhoneConnection) mCTUT.mRingingCall.getConnections().get(0);
+ connection.addListener(mImsPhoneConnectionListener);
}
@Test
@@ -570,6 +584,55 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
nullable(ImsConnectionStateListener.class));
}
+ /**
+ * Test notification of handover from LTE to WIFI and WIFI to LTE and ensure that the expected
+ * connection events are sent.
+ */
+ @Test
+ @SmallTest
+ public void testNotifyHandovers() {
+ setupCarrierConfig();
+
+ //establish a MT call
+ testImsMTCallAccept();
+ ImsPhoneConnection connection =
+ (ImsPhoneConnection) mCTUT.mForegroundCall.getConnections().get(0);
+ ImsCall call = connection.getImsCall();
+ // Needs to be a video call to see this signalling.
+ doReturn(true).when(mImsCallProfile).isVideoCall();
+
+ // First handover from LTE to WIFI; this takes us into a mid-call state.
+ call.getImsCallSessionListenerProxy().callSessionHandover(call.getCallSession(),
+ ServiceState.RIL_RADIO_TECHNOLOGY_LTE, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN,
+ new ImsReasonInfo());
+ // Handover back to LTE.
+ call.getImsCallSessionListenerProxy().callSessionHandover(call.getCallSession(),
+ ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN, ServiceState.RIL_RADIO_TECHNOLOGY_LTE,
+ new ImsReasonInfo());
+ verify(mImsPhoneConnectionListener).onConnectionEvent(eq(
+ TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE), isNull());
+
+ // Finally hand back to WIFI
+ call.getImsCallSessionListenerProxy().callSessionHandover(call.getCallSession(),
+ ServiceState.RIL_RADIO_TECHNOLOGY_LTE, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN,
+ new ImsReasonInfo());
+ verify(mImsPhoneConnectionListener).onConnectionEvent(eq(
+ TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_LTE_TO_WIFI), isNull());
+ }
+
+ /**
+ * Configure carrier config options relevant to the unit test.
+ */
+ public void setupCarrierConfig() {
+ PersistableBundle bundle = new PersistableBundle();
+ bundle.putBoolean(CarrierConfigManager.KEY_NOTIFY_HANDOVER_VIDEO_FROM_LTE_TO_WIFI_BOOL,
+ true);
+ bundle.putBoolean(CarrierConfigManager.KEY_NOTIFY_HANDOVER_VIDEO_FROM_WIFI_TO_LTE_BOOL,
+ true);
+ bundle.putBoolean(CarrierConfigManager.KEY_NOTIFY_VT_HANDOVER_TO_WIFI_FAILURE_BOOL, true);
+ mCTUT.updateCarrierConfigCache(bundle);
+ }
+
@Test
@SmallTest
public void testLowBatteryDisconnectMidCall() {