Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +7 −8 Original line number Diff line number Diff line Loading @@ -87,7 +87,6 @@ import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.RIL; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.RetryManager; import com.android.internal.telephony.ServiceStateTracker; import com.android.internal.telephony.TelephonyStatsLog; import com.android.internal.telephony.dataconnection.DcTracker.ReleaseNetworkType; import com.android.internal.telephony.dataconnection.DcTracker.RequestNetworkType; Loading Loading @@ -488,10 +487,6 @@ public class DataConnection extends StateMachine { return new LinkProperties(mLinkProperties); } boolean isInactive() { return getCurrentState() == mInactiveState; } boolean isSuspended() { // Data can only be (temporarily) suspended while data is in active state if (getCurrentState() != mActiveState) return false; Loading @@ -502,13 +497,12 @@ public class DataConnection extends StateMachine { } // if we are not in-service change to SUSPENDED final ServiceStateTracker sst = mPhone.getServiceStateTracker(); if (sst.getCurrentDataConnectionState() != ServiceState.STATE_IN_SERVICE) { if (mDataRegState != ServiceState.STATE_IN_SERVICE) { return true; } // check for voice call and concurrency issues if (!sst.isConcurrentVoiceAndDataAllowed()) { if (!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) { return mPhone.getCallTracker().getState() != PhoneConstants.State.IDLE; } Loading @@ -525,6 +519,11 @@ public class DataConnection extends StateMachine { return getCurrentState() == mActiveState; } @VisibleForTesting public boolean isInactive() { return getCurrentState() == mInactiveState; } boolean isActivating() { return getCurrentState() == mActivatingState; } Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +83 −25 Original line number Diff line number Diff line Loading @@ -66,14 +66,13 @@ import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.R; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.RetryManager; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.dataconnection.DataConnection.ConnectionParams; import com.android.internal.telephony.dataconnection.DataConnection.DisconnectParams; import com.android.internal.telephony.dataconnection.DataConnection.SetupResult; import com.android.internal.telephony.metrics.DataCallSessionStats; import com.android.internal.util.IState; import com.android.internal.util.StateMachine; import org.junit.After; import org.junit.Before; Loading Loading @@ -166,7 +165,7 @@ public class DataConnectionTest extends TelephonyTest { ""); // mnvo_match_data private ApnSetting mApn3 = ApnSetting.makeApnSetting( 2164, // id 2165, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn Loading Loading @@ -196,7 +195,7 @@ public class DataConnectionTest extends TelephonyTest { 1); // skip_464xlat private ApnSetting mApn4 = ApnSetting.makeApnSetting( 2164, // id 2166, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn Loading @@ -223,7 +222,7 @@ public class DataConnectionTest extends TelephonyTest { ""); // mnvo_match_data private ApnSetting mApn5 = ApnSetting.makeApnSetting( 2164, // id 2167, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn Loading Loading @@ -252,6 +251,33 @@ public class DataConnectionTest extends TelephonyTest { -1, // carrier_id 0); // skip_464xlat private ApnSetting mApn6 = ApnSetting.makeApnSetting( 2168, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn null, // proxy -1, // port null, // mmsc null, // mmsproxy -1, // mmsport "", // user "", // password -1, // authtype ApnSetting.TYPE_EMERGENCY, // types ApnSetting.PROTOCOL_IP, // protocol ApnSetting.PROTOCOL_IP, // roaming_protocol true, // carrier_enabled 0, // networktype_bitmask 0, // profile_id false, // modem_cognitive 0, // max_conns 0, // wait_time 0, // max_conns_time 0, // mtu -1, // mvno_type ""); // mnvo_match_data private class DataConnectionTestHandler extends HandlerThread { private DataConnectionTestHandler(String name) { Loading Loading @@ -340,12 +366,6 @@ public class DataConnectionTest extends TelephonyTest { super.tearDown(); } private IState getCurrentState() throws Exception { Method method = StateMachine.class.getDeclaredMethod("getCurrentState"); method.setAccessible(true); return (IState) method.invoke(mDc); } private long getSuggestedRetryDelay(DataCallResponse response) throws Exception { Class[] cArgs = new Class[1]; cArgs[0] = DataCallResponse.class; Loading @@ -366,6 +386,12 @@ public class DataConnectionTest extends TelephonyTest { return (boolean) method.invoke(mDc); } private boolean isSuspended() throws Exception { Method method = DataConnection.class.getDeclaredMethod("isSuspended"); method.setAccessible(true); return (boolean) method.invoke(mDc); } private SetupResult setLinkProperties(DataCallResponse response, LinkProperties linkProperties) throws Exception { Class[] cArgs = new Class[2]; Loading @@ -378,14 +404,8 @@ public class DataConnectionTest extends TelephonyTest { @Test @SmallTest public void testSanity() throws Exception { assertEquals("DcInactiveState", getCurrentState().getName()); } @Test @SmallTest public void testConnectEvent() throws Exception { testSanity(); public void testConnectEvent() { assertTrue(mDc.isInactive()); connectEvent(true); verify(mCT, times(1)).registerForVoiceCallStarted(any(Handler.class), Loading Loading @@ -463,7 +483,7 @@ public class DataConnectionTest extends TelephonyTest { // Verify that ENTERPRISE wasn't set up connectEvent(false); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); // Change the CID result.cid = DEFAULT_DC_CID + 1; Loading @@ -487,7 +507,7 @@ public class DataConnectionTest extends TelephonyTest { // Verify that ENTERPRISE wasn't set up connectEvent(false); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); // Set up default data replaceInstance(ConnectionParams.class, "mApnContext", mCp, mApnContext); Loading @@ -511,7 +531,7 @@ public class DataConnectionTest extends TelephonyTest { @Test @SmallTest public void testDisconnectEvent() throws Exception { public void testDisconnectEvent() { testConnectEvent(); mDc.setPduSessionId(5); Loading @@ -525,7 +545,7 @@ public class DataConnectionTest extends TelephonyTest { verify(mSimulatedCommandsVerifier, times(1)) .releasePduSessionId(any(), eq(5)); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); } @Test Loading Loading @@ -874,10 +894,10 @@ public class DataConnectionTest extends TelephonyTest { } } private void disconnectEvent() throws Exception { private void disconnectEvent() { mDc.sendMessage(DataConnection.EVENT_DISCONNECT, mDcp); waitForMs(100); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); } @Test Loading Loading @@ -1217,4 +1237,42 @@ public class DataConnectionTest extends TelephonyTest { assertEquals(ApnSetting.TYPE_MMS | ApnSetting.TYPE_SUPL | ApnSetting.TYPE_FOTA, getDisallowedApnTypes()); } @Test public void testIsSuspended() throws Exception { // Return false if not active state assertTrue(mDc.isInactive()); assertFalse(isSuspended()); // Return false for emergency APN doReturn(mApn6).when(mApnContext).getApnSetting(); doReturn(ApnSetting.TYPE_EMERGENCY).when(mApnContext).getApnTypeBitmask(); connectEvent(true); assertFalse(isSuspended()); // Back to DEFAULT APN disconnectEvent(); assertTrue(mDc.isInactive()); doReturn(mApn1).when(mApnContext).getApnSetting(); doReturn(ApnSetting.TYPE_DEFAULT).when(mApnContext).getApnTypeBitmask(); connectEvent(true); // Return true if combined reg state is not in service doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getDataRegistrationState(); assertTrue(isSuspended()); // Return false if in service and concurrent voice and data is allowed doReturn(ServiceState.STATE_IN_SERVICE).when(mServiceState).getDataRegistrationState(); doReturn(true).when(mSST).isConcurrentVoiceAndDataAllowed(); assertFalse(isSuspended()); // Return false if in service and concurrent voice/data not allowed but call state is idle doReturn(false).when(mSST).isConcurrentVoiceAndDataAllowed(); doReturn(PhoneConstants.State.IDLE).when(mCT).getState(); assertFalse(isSuspended()); // Return true if in service, concurrent voice/data not allowed, and call state not idle doReturn(PhoneConstants.State.RINGING).when(mCT).getState(); assertTrue(isSuspended()); } } Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +7 −8 Original line number Diff line number Diff line Loading @@ -87,7 +87,6 @@ import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.RIL; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.RetryManager; import com.android.internal.telephony.ServiceStateTracker; import com.android.internal.telephony.TelephonyStatsLog; import com.android.internal.telephony.dataconnection.DcTracker.ReleaseNetworkType; import com.android.internal.telephony.dataconnection.DcTracker.RequestNetworkType; Loading Loading @@ -488,10 +487,6 @@ public class DataConnection extends StateMachine { return new LinkProperties(mLinkProperties); } boolean isInactive() { return getCurrentState() == mInactiveState; } boolean isSuspended() { // Data can only be (temporarily) suspended while data is in active state if (getCurrentState() != mActiveState) return false; Loading @@ -502,13 +497,12 @@ public class DataConnection extends StateMachine { } // if we are not in-service change to SUSPENDED final ServiceStateTracker sst = mPhone.getServiceStateTracker(); if (sst.getCurrentDataConnectionState() != ServiceState.STATE_IN_SERVICE) { if (mDataRegState != ServiceState.STATE_IN_SERVICE) { return true; } // check for voice call and concurrency issues if (!sst.isConcurrentVoiceAndDataAllowed()) { if (!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) { return mPhone.getCallTracker().getState() != PhoneConstants.State.IDLE; } Loading @@ -525,6 +519,11 @@ public class DataConnection extends StateMachine { return getCurrentState() == mActiveState; } @VisibleForTesting public boolean isInactive() { return getCurrentState() == mInactiveState; } boolean isActivating() { return getCurrentState() == mActivatingState; } Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +83 −25 Original line number Diff line number Diff line Loading @@ -66,14 +66,13 @@ import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.R; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.RetryManager; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.dataconnection.DataConnection.ConnectionParams; import com.android.internal.telephony.dataconnection.DataConnection.DisconnectParams; import com.android.internal.telephony.dataconnection.DataConnection.SetupResult; import com.android.internal.telephony.metrics.DataCallSessionStats; import com.android.internal.util.IState; import com.android.internal.util.StateMachine; import org.junit.After; import org.junit.Before; Loading Loading @@ -166,7 +165,7 @@ public class DataConnectionTest extends TelephonyTest { ""); // mnvo_match_data private ApnSetting mApn3 = ApnSetting.makeApnSetting( 2164, // id 2165, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn Loading Loading @@ -196,7 +195,7 @@ public class DataConnectionTest extends TelephonyTest { 1); // skip_464xlat private ApnSetting mApn4 = ApnSetting.makeApnSetting( 2164, // id 2166, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn Loading @@ -223,7 +222,7 @@ public class DataConnectionTest extends TelephonyTest { ""); // mnvo_match_data private ApnSetting mApn5 = ApnSetting.makeApnSetting( 2164, // id 2167, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn Loading Loading @@ -252,6 +251,33 @@ public class DataConnectionTest extends TelephonyTest { -1, // carrier_id 0); // skip_464xlat private ApnSetting mApn6 = ApnSetting.makeApnSetting( 2168, // id "44010", // numeric "sp-mode", // name "spmode.ne.jp", // apn null, // proxy -1, // port null, // mmsc null, // mmsproxy -1, // mmsport "", // user "", // password -1, // authtype ApnSetting.TYPE_EMERGENCY, // types ApnSetting.PROTOCOL_IP, // protocol ApnSetting.PROTOCOL_IP, // roaming_protocol true, // carrier_enabled 0, // networktype_bitmask 0, // profile_id false, // modem_cognitive 0, // max_conns 0, // wait_time 0, // max_conns_time 0, // mtu -1, // mvno_type ""); // mnvo_match_data private class DataConnectionTestHandler extends HandlerThread { private DataConnectionTestHandler(String name) { Loading Loading @@ -340,12 +366,6 @@ public class DataConnectionTest extends TelephonyTest { super.tearDown(); } private IState getCurrentState() throws Exception { Method method = StateMachine.class.getDeclaredMethod("getCurrentState"); method.setAccessible(true); return (IState) method.invoke(mDc); } private long getSuggestedRetryDelay(DataCallResponse response) throws Exception { Class[] cArgs = new Class[1]; cArgs[0] = DataCallResponse.class; Loading @@ -366,6 +386,12 @@ public class DataConnectionTest extends TelephonyTest { return (boolean) method.invoke(mDc); } private boolean isSuspended() throws Exception { Method method = DataConnection.class.getDeclaredMethod("isSuspended"); method.setAccessible(true); return (boolean) method.invoke(mDc); } private SetupResult setLinkProperties(DataCallResponse response, LinkProperties linkProperties) throws Exception { Class[] cArgs = new Class[2]; Loading @@ -378,14 +404,8 @@ public class DataConnectionTest extends TelephonyTest { @Test @SmallTest public void testSanity() throws Exception { assertEquals("DcInactiveState", getCurrentState().getName()); } @Test @SmallTest public void testConnectEvent() throws Exception { testSanity(); public void testConnectEvent() { assertTrue(mDc.isInactive()); connectEvent(true); verify(mCT, times(1)).registerForVoiceCallStarted(any(Handler.class), Loading Loading @@ -463,7 +483,7 @@ public class DataConnectionTest extends TelephonyTest { // Verify that ENTERPRISE wasn't set up connectEvent(false); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); // Change the CID result.cid = DEFAULT_DC_CID + 1; Loading @@ -487,7 +507,7 @@ public class DataConnectionTest extends TelephonyTest { // Verify that ENTERPRISE wasn't set up connectEvent(false); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); // Set up default data replaceInstance(ConnectionParams.class, "mApnContext", mCp, mApnContext); Loading @@ -511,7 +531,7 @@ public class DataConnectionTest extends TelephonyTest { @Test @SmallTest public void testDisconnectEvent() throws Exception { public void testDisconnectEvent() { testConnectEvent(); mDc.setPduSessionId(5); Loading @@ -525,7 +545,7 @@ public class DataConnectionTest extends TelephonyTest { verify(mSimulatedCommandsVerifier, times(1)) .releasePduSessionId(any(), eq(5)); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); } @Test Loading Loading @@ -874,10 +894,10 @@ public class DataConnectionTest extends TelephonyTest { } } private void disconnectEvent() throws Exception { private void disconnectEvent() { mDc.sendMessage(DataConnection.EVENT_DISCONNECT, mDcp); waitForMs(100); assertEquals("DcInactiveState", getCurrentState().getName()); assertTrue(mDc.isInactive()); } @Test Loading Loading @@ -1217,4 +1237,42 @@ public class DataConnectionTest extends TelephonyTest { assertEquals(ApnSetting.TYPE_MMS | ApnSetting.TYPE_SUPL | ApnSetting.TYPE_FOTA, getDisallowedApnTypes()); } @Test public void testIsSuspended() throws Exception { // Return false if not active state assertTrue(mDc.isInactive()); assertFalse(isSuspended()); // Return false for emergency APN doReturn(mApn6).when(mApnContext).getApnSetting(); doReturn(ApnSetting.TYPE_EMERGENCY).when(mApnContext).getApnTypeBitmask(); connectEvent(true); assertFalse(isSuspended()); // Back to DEFAULT APN disconnectEvent(); assertTrue(mDc.isInactive()); doReturn(mApn1).when(mApnContext).getApnSetting(); doReturn(ApnSetting.TYPE_DEFAULT).when(mApnContext).getApnTypeBitmask(); connectEvent(true); // Return true if combined reg state is not in service doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getDataRegistrationState(); assertTrue(isSuspended()); // Return false if in service and concurrent voice and data is allowed doReturn(ServiceState.STATE_IN_SERVICE).when(mServiceState).getDataRegistrationState(); doReturn(true).when(mSST).isConcurrentVoiceAndDataAllowed(); assertFalse(isSuspended()); // Return false if in service and concurrent voice/data not allowed but call state is idle doReturn(false).when(mSST).isConcurrentVoiceAndDataAllowed(); doReturn(PhoneConstants.State.IDLE).when(mCT).getState(); assertFalse(isSuspended()); // Return true if in service, concurrent voice/data not allowed, and call state not idle doReturn(PhoneConstants.State.RINGING).when(mCT).getState(); assertTrue(isSuspended()); } }