Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +13 −25 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ public class DataConnection extends StateMachine { private DcTesterFailBringUpAll mDcTesterFailBringUpAll; // Whether or not the data connection should allocate its own pdu session id private final boolean mDoAllocatePduSessionId; private boolean mDoAllocatePduSessionId; private static AtomicInteger mInstanceNumber = new AtomicInteger(0); private AsyncChannel mAc; Loading Loading @@ -466,15 +466,14 @@ public class DataConnection extends StateMachine { public static DataConnection makeDataConnection(Phone phone, int id, DcTracker dct, DataServiceManager dataServiceManager, DcTesterFailBringUpAll failBringUpAll, DcController dcc, boolean doAllocatePduSessionId) { DcController dcc) { String transportType = (dataServiceManager.getTransportType() == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) ? "C" // Cellular : "I"; // IWLAN DataConnection dc = new DataConnection(phone, transportType + "-" + mInstanceNumber.incrementAndGet(), id, dct, dataServiceManager, failBringUpAll, dcc, doAllocatePduSessionId); dcc); dc.start(); if (DBG) dc.log("Made " + dc.getName()); return dc; Loading Loading @@ -759,8 +758,7 @@ public class DataConnection extends StateMachine { //***** Constructor (NOTE: uses dcc.getHandler() as its Handler) private DataConnection(Phone phone, String tagSuffix, int id, DcTracker dct, DataServiceManager dataServiceManager, DcTesterFailBringUpAll failBringUpAll, DcController dcc, boolean doAllocatePduSessionId) { DcTesterFailBringUpAll failBringUpAll, DcController dcc) { super("DC-" + tagSuffix, dcc); mTagSuffix = tagSuffix; setLogRecSize(300); Loading @@ -779,7 +777,7 @@ public class DataConnection extends StateMachine { mDataRegState = mPhone.getServiceState().getDataRegistrationState(); mIsSuspended = false; mDataCallSessionStats = new DataCallSessionStats(mPhone); mDoAllocatePduSessionId = doAllocatePduSessionId; mDoAllocatePduSessionId = false; int networkType = getNetworkType(); mRilRat = ServiceState.networkTypeToRilRadioTechnology(networkType); Loading Loading @@ -971,6 +969,7 @@ public class DataConnection extends StateMachine { } // setup data call for REQUEST_TYPE_NORMAL mDoAllocatePduSessionId = mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN; allocatePduSessionId(psi -> { this.setPduSessionId(psi); mDataServiceManager.setupDataCall( Loading @@ -992,7 +991,7 @@ public class DataConnection extends StateMachine { } private void allocatePduSessionId(Consumer<Integer> allocateCallback) { if (getDoAllocatePduSessionId()) { if (mDoAllocatePduSessionId) { Message msg = this.obtainMessage(EVENT_ALLOCATE_PDU_SESSION_ID); msg.obj = allocateCallback; mPhone.mCi.allocatePduSessionId(msg); Loading Loading @@ -1182,8 +1181,10 @@ public class DataConnection extends StateMachine { } private void releasePduSessionId(Runnable releaseCallback) { // If we are not in the middle of a handover and have a real pdu session id, then we release if (mHandoverState != HANDOVER_STATE_BEING_TRANSFERRED // If the transport is IWLAN, and there is a valid PDU session id, also the data connection // is not being handovered, we should release the pdu session id. if (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN && mHandoverState == HANDOVER_STATE_IDLE && this.getPduSessionId() != PDU_SESSION_ID_NOT_SET) { Message msg = this.obtainMessage(EVENT_RELEASE_PDU_SESSION_ID); msg.obj = releaseCallback; Loading Loading @@ -1353,6 +1354,7 @@ public class DataConnection extends StateMachine { mHandoverFailureMode = DataCallResponse.HANDOVER_FAILURE_MODE_UNKNOWN; mSliceInfo = null; mDefaultQos = null; mDoAllocatePduSessionId = false; mQosBearerSessions.clear(); mTrafficDescriptors.clear(); } Loading Loading @@ -1407,17 +1409,7 @@ public class DataConnection extends StateMachine { } else { if (DBG) log("onSetupConnectionCompleted received successful DataCallResponse"); mCid = response.getId(); if (response.getPduSessionId() != getPduSessionId()) { if (getDoAllocatePduSessionId()) { loge("The pdu session id on DataCallResponse is different than the one " + "allocated. response psi=" + response.getPduSessionId() + ", allocated psi=" + getPduSessionId()); } else { setPduSessionId(response.getPduSessionId()); } } updatePcscfAddr(response); updateResponseFields(response); result = updateLinkProperty(response).setupResult; Loading Loading @@ -2158,10 +2150,6 @@ public class DataConnection extends StateMachine { return result; } private boolean getDoAllocatePduSessionId() { return mDoAllocatePduSessionId; } /** * Initialize connection, this will fail if the * apnSettings are not compatible. Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +1 −3 Original line number Diff line number Diff line Loading @@ -3624,10 +3624,8 @@ public class DcTracker extends Handler { if (DBG) log("createDataConnection E"); int id = mUniqueIdGenerator.getAndIncrement(); boolean doAllocatePduSessionId = mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN; DataConnection dataConnection = DataConnection.makeDataConnection(mPhone, id, this, mDataServiceManager, mDcTesterFailBringUpAll, mDcc, doAllocatePduSessionId); mDataServiceManager, mDcTesterFailBringUpAll, mDcc); mDataConnections.put(id, dataConnection); if (DBG) log("createDataConnection() X id=" + id + " dc=" + dataConnection); return dataConnection; Loading tests/telephonytests/src/com/android/internal/telephony/SignalStrengthUpdateRequestTest.java +58 −10 Original line number Diff line number Diff line Loading @@ -34,36 +34,59 @@ import java.util.List; public class SignalStrengthUpdateRequestTest extends TestCase { private SignalThresholdInfo mRssiInfo = new SignalThresholdInfo.Builder() private SignalThresholdInfo mRssiInfoOnGERAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI) .setThresholds(new int[]{-109, -103, -97, -89}) .build(); private SignalThresholdInfo mRscpInfo = new SignalThresholdInfo.Builder() private SignalThresholdInfo mRssiInfoOnGERAN2 = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI) .setThresholds(new int[]{-108, -102, -96, -88}) .build(); private SignalThresholdInfo mRssiInfoOnCDMA2000 = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.CDMA2000) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI) .setThresholds(new int[]{-109, -103, -97, -89}) .build(); private SignalThresholdInfo mRscpInfoOnUTRAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP) .setThresholds(new int[]{-115, -105, -95, -85}) .build(); private SignalThresholdInfo mRsrpInfoOnEUTRAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP) .setThresholds(new int[]{-115, -105, -95, -85}) .build(); private SignalThresholdInfo mRsrqInfoEUTRAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ) .setThresholds(new int[]{-30, -20, -10, -1}) .build(); @Test @SmallTest public void testPublicConstructorWithInvalidParam() { // null Collection validateBuilderWithInvalidParam(null); // duplication of SignalMeasurementType in Collection validateBuilderWithInvalidParam(List.of(mRssiInfo, mRssiInfo)); // duplication of SignalMeasurementType for the same RAN in Collection validateBuilderWithInvalidParam(List.of(mRssiInfoOnGERAN, mRssiInfoOnGERAN2)); // The following two cases can not turn on until the implement is ready: // empty Collections // validateBuilderWithInvalidParam(List.of()); validateBuilderWithInvalidParam(List.of()); } @Test @SmallTest public void testPublicConstructorWithValidParam() { Collection<SignalThresholdInfo> infos = List.of(mRssiInfo, mRscpInfo); Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRscpInfoOnUTRAN); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).setReportingRequestedWhileIdle(false).build(); assertFalse(request.isReportingRequestedWhileIdle()); Loading @@ -74,7 +97,7 @@ public class SignalStrengthUpdateRequestTest extends TestCase { @Test @SmallTest public void testParcel() { Collection<SignalThresholdInfo> infos = List.of(mRssiInfo, mRscpInfo); Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRscpInfoOnUTRAN); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).setReportingRequestedWhileIdle(true).build(); Loading @@ -90,14 +113,14 @@ public class SignalStrengthUpdateRequestTest extends TestCase { @Test @SmallTest public void testEquals() { Collection<SignalThresholdInfo> infos1 = List.of(mRssiInfo, mRscpInfo); Collection<SignalThresholdInfo> infos1 = List.of(mRssiInfoOnGERAN, mRssiInfoOnCDMA2000); SignalStrengthUpdateRequest request1 = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos1).setReportingRequestedWhileIdle(false).build(); assertTrue(request1.equals(request1)); // Ordering does not matter Collection<SignalThresholdInfo> infos2 = List.of(mRscpInfo, mRssiInfo); Collection<SignalThresholdInfo> infos2 = List.of(mRssiInfoOnCDMA2000, mRssiInfoOnGERAN); SignalStrengthUpdateRequest request2 = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos2).setReportingRequestedWhileIdle(false).build(); assertTrue(request1.equals(request2)); Loading @@ -109,11 +132,36 @@ public class SignalStrengthUpdateRequestTest extends TestCase { SignalStrengthUpdateRequest request4 = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos1).setReportingRequestedWhileIdle(false) .setSystemThresholdReportingRequestedWhileIdle(true).build(); assertFalse(request1.equals(request4)); // return false if the object is not SignalStrengthUpdateRequest assertFalse(request1.equals("test")); } @Test @SmallTest public void testMultipleSignalMeasurementTypeOnSameRan() { Collection<SignalThresholdInfo> infos = List.of(mRsrpInfoOnEUTRAN, mRsrqInfoEUTRAN); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).build(); assertFalse(request.isReportingRequestedWhileIdle()); assertFalse(request.isSystemThresholdReportingRequestedWhileIdle()); assertEquals(infos, request.getSignalThresholdInfos()); } @Test @SmallTest public void testSameSignalMeasurementTypeOnDifferentRan() { Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRssiInfoOnCDMA2000); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).build(); assertFalse(request.isReportingRequestedWhileIdle()); assertFalse(request.isSystemThresholdReportingRequestedWhileIdle()); assertEquals(infos, request.getSignalThresholdInfos()); } private void validateBuilderWithInvalidParam(Collection<SignalThresholdInfo> infos) { try { new SignalStrengthUpdateRequest.Builder() Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +81 −2 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public class DataConnectionTest extends TelephonyTest { Handler h = new Handler(); mDcc = DcController.makeDcc(mPhone, mDcTracker, mDataServiceManager, h.getLooper(), ""); mDc = DataConnection.makeDataConnection(mPhone, 0, mDcTracker, mDataServiceManager, mDcTesterFailBringUpAll, mDcc, true); mDcTesterFailBringUpAll, mDcc); } } Loading Loading @@ -482,6 +482,63 @@ public class DataConnectionTest extends TelephonyTest { eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), anyInt(), any(), tdCaptor.capture(), anyBoolean(), any(Message.class)); verify(mSimulatedCommandsVerifier, times(0)) .allocatePduSessionId(any()); assertEquals("spmode.ne.jp", dpCaptor.getValue().getApn()); if (tdCaptor.getValue() != null) { if (mApnContext.getApnTypeBitmask() == ApnSetting.TYPE_ENTERPRISE) { assertEquals(null, tdCaptor.getValue().getDataNetworkName()); assertTrue(Arrays.equals(DataConnection.getEnterpriseOsAppId(), tdCaptor.getValue().getOsAppId())); } else { assertEquals("spmode.ne.jp", tdCaptor.getValue().getDataNetworkName()); assertEquals(null, tdCaptor.getValue().getOsAppId()); } } assertTrue(mDc.isActive()); assertEquals(1, mDc.getPduSessionId()); assertEquals(3, mDc.getPcscfAddresses().length); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c305:1d::8"::equals)); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c202:1d::7"::equals)); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c305:1d::5"::equals)); } @Test @SmallTest public void testConnectOnIwlan() throws Exception { assertTrue(mDc.isInactive()); Field field = DataConnection.class.getDeclaredField("mTransportType"); field.setAccessible(true); field.setInt(mDc, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); connectEvent(true); verify(mCT, times(1)).registerForVoiceCallStarted(any(Handler.class), eq(DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_STARTED), eq(null)); verify(mCT, times(1)).registerForVoiceCallEnded(any(Handler.class), eq(DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_ENDED), eq(null)); verify(mSimulatedCommandsVerifier, times(0)) .registerForNattKeepaliveStatus(any(Handler.class), eq(DataConnection.EVENT_KEEPALIVE_STATUS), eq(null)); verify(mSimulatedCommandsVerifier, times(0)) .registerForLceInfo(any(Handler.class), eq(DataConnection.EVENT_LINK_CAPACITY_CHANGED), eq(null)); verify(mVcnManager, atLeastOnce()) .applyVcnNetworkPolicy( argThat(caps -> caps.hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED)), any()); ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class); ArgumentCaptor<TrafficDescriptor> tdCaptor = ArgumentCaptor.forClass(TrafficDescriptor.class); verify(mDataServiceManager, times(1)).setupDataCall( eq(AccessNetworkType.UTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), anyInt(), any(), tdCaptor.capture(), anyBoolean(), any(Message.class)); verify(mSimulatedCommandsVerifier, times(1)) .allocatePduSessionId(any()); Loading @@ -498,7 +555,7 @@ public class DataConnectionTest extends TelephonyTest { } assertTrue(mDc.isActive()); assertEquals(mDc.getPduSessionId(), 1); assertEquals(1, mDc.getPduSessionId()); assertEquals(3, mDc.getPcscfAddresses().length); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c305:1d::8"::equals)); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c202:1d::7"::equals)); Loading Loading @@ -575,6 +632,28 @@ public class DataConnectionTest extends TelephonyTest { .unregisterForNattKeepaliveStatus(any(Handler.class)); verify(mDataServiceManager, times(1)).deactivateDataCall(eq(DEFAULT_DC_CID), eq(DataService.REQUEST_REASON_NORMAL), any(Message.class)); verify(mSimulatedCommandsVerifier, times(0)) .releasePduSessionId(any(), eq(5)); assertTrue(mDc.isInactive()); } @Test @SmallTest public void testDisconnectOnIwlan() throws Exception { testConnectEvent(); Field field = DataConnection.class.getDeclaredField("mTransportType"); field.setAccessible(true); field.setInt(mDc, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); mDc.setPduSessionId(5); disconnectEvent(); verify(mSimulatedCommandsVerifier, times(0)).unregisterForLceInfo(any(Handler.class)); verify(mSimulatedCommandsVerifier, times(0)) .unregisterForNattKeepaliveStatus(any(Handler.class)); verify(mDataServiceManager, times(1)).deactivateDataCall(eq(DEFAULT_DC_CID), eq(DataService.REQUEST_REASON_NORMAL), any(Message.class)); verify(mSimulatedCommandsVerifier, times(1)) .releasePduSessionId(any(), eq(5)); Loading Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +13 −25 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ public class DataConnection extends StateMachine { private DcTesterFailBringUpAll mDcTesterFailBringUpAll; // Whether or not the data connection should allocate its own pdu session id private final boolean mDoAllocatePduSessionId; private boolean mDoAllocatePduSessionId; private static AtomicInteger mInstanceNumber = new AtomicInteger(0); private AsyncChannel mAc; Loading Loading @@ -466,15 +466,14 @@ public class DataConnection extends StateMachine { public static DataConnection makeDataConnection(Phone phone, int id, DcTracker dct, DataServiceManager dataServiceManager, DcTesterFailBringUpAll failBringUpAll, DcController dcc, boolean doAllocatePduSessionId) { DcController dcc) { String transportType = (dataServiceManager.getTransportType() == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) ? "C" // Cellular : "I"; // IWLAN DataConnection dc = new DataConnection(phone, transportType + "-" + mInstanceNumber.incrementAndGet(), id, dct, dataServiceManager, failBringUpAll, dcc, doAllocatePduSessionId); dcc); dc.start(); if (DBG) dc.log("Made " + dc.getName()); return dc; Loading Loading @@ -759,8 +758,7 @@ public class DataConnection extends StateMachine { //***** Constructor (NOTE: uses dcc.getHandler() as its Handler) private DataConnection(Phone phone, String tagSuffix, int id, DcTracker dct, DataServiceManager dataServiceManager, DcTesterFailBringUpAll failBringUpAll, DcController dcc, boolean doAllocatePduSessionId) { DcTesterFailBringUpAll failBringUpAll, DcController dcc) { super("DC-" + tagSuffix, dcc); mTagSuffix = tagSuffix; setLogRecSize(300); Loading @@ -779,7 +777,7 @@ public class DataConnection extends StateMachine { mDataRegState = mPhone.getServiceState().getDataRegistrationState(); mIsSuspended = false; mDataCallSessionStats = new DataCallSessionStats(mPhone); mDoAllocatePduSessionId = doAllocatePduSessionId; mDoAllocatePduSessionId = false; int networkType = getNetworkType(); mRilRat = ServiceState.networkTypeToRilRadioTechnology(networkType); Loading Loading @@ -971,6 +969,7 @@ public class DataConnection extends StateMachine { } // setup data call for REQUEST_TYPE_NORMAL mDoAllocatePduSessionId = mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN; allocatePduSessionId(psi -> { this.setPduSessionId(psi); mDataServiceManager.setupDataCall( Loading @@ -992,7 +991,7 @@ public class DataConnection extends StateMachine { } private void allocatePduSessionId(Consumer<Integer> allocateCallback) { if (getDoAllocatePduSessionId()) { if (mDoAllocatePduSessionId) { Message msg = this.obtainMessage(EVENT_ALLOCATE_PDU_SESSION_ID); msg.obj = allocateCallback; mPhone.mCi.allocatePduSessionId(msg); Loading Loading @@ -1182,8 +1181,10 @@ public class DataConnection extends StateMachine { } private void releasePduSessionId(Runnable releaseCallback) { // If we are not in the middle of a handover and have a real pdu session id, then we release if (mHandoverState != HANDOVER_STATE_BEING_TRANSFERRED // If the transport is IWLAN, and there is a valid PDU session id, also the data connection // is not being handovered, we should release the pdu session id. if (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN && mHandoverState == HANDOVER_STATE_IDLE && this.getPduSessionId() != PDU_SESSION_ID_NOT_SET) { Message msg = this.obtainMessage(EVENT_RELEASE_PDU_SESSION_ID); msg.obj = releaseCallback; Loading Loading @@ -1353,6 +1354,7 @@ public class DataConnection extends StateMachine { mHandoverFailureMode = DataCallResponse.HANDOVER_FAILURE_MODE_UNKNOWN; mSliceInfo = null; mDefaultQos = null; mDoAllocatePduSessionId = false; mQosBearerSessions.clear(); mTrafficDescriptors.clear(); } Loading Loading @@ -1407,17 +1409,7 @@ public class DataConnection extends StateMachine { } else { if (DBG) log("onSetupConnectionCompleted received successful DataCallResponse"); mCid = response.getId(); if (response.getPduSessionId() != getPduSessionId()) { if (getDoAllocatePduSessionId()) { loge("The pdu session id on DataCallResponse is different than the one " + "allocated. response psi=" + response.getPduSessionId() + ", allocated psi=" + getPduSessionId()); } else { setPduSessionId(response.getPduSessionId()); } } updatePcscfAddr(response); updateResponseFields(response); result = updateLinkProperty(response).setupResult; Loading Loading @@ -2158,10 +2150,6 @@ public class DataConnection extends StateMachine { return result; } private boolean getDoAllocatePduSessionId() { return mDoAllocatePduSessionId; } /** * Initialize connection, this will fail if the * apnSettings are not compatible. Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +1 −3 Original line number Diff line number Diff line Loading @@ -3624,10 +3624,8 @@ public class DcTracker extends Handler { if (DBG) log("createDataConnection E"); int id = mUniqueIdGenerator.getAndIncrement(); boolean doAllocatePduSessionId = mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN; DataConnection dataConnection = DataConnection.makeDataConnection(mPhone, id, this, mDataServiceManager, mDcTesterFailBringUpAll, mDcc, doAllocatePduSessionId); mDataServiceManager, mDcTesterFailBringUpAll, mDcc); mDataConnections.put(id, dataConnection); if (DBG) log("createDataConnection() X id=" + id + " dc=" + dataConnection); return dataConnection; Loading
tests/telephonytests/src/com/android/internal/telephony/SignalStrengthUpdateRequestTest.java +58 −10 Original line number Diff line number Diff line Loading @@ -34,36 +34,59 @@ import java.util.List; public class SignalStrengthUpdateRequestTest extends TestCase { private SignalThresholdInfo mRssiInfo = new SignalThresholdInfo.Builder() private SignalThresholdInfo mRssiInfoOnGERAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI) .setThresholds(new int[]{-109, -103, -97, -89}) .build(); private SignalThresholdInfo mRscpInfo = new SignalThresholdInfo.Builder() private SignalThresholdInfo mRssiInfoOnGERAN2 = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI) .setThresholds(new int[]{-108, -102, -96, -88}) .build(); private SignalThresholdInfo mRssiInfoOnCDMA2000 = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.CDMA2000) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI) .setThresholds(new int[]{-109, -103, -97, -89}) .build(); private SignalThresholdInfo mRscpInfoOnUTRAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP) .setThresholds(new int[]{-115, -105, -95, -85}) .build(); private SignalThresholdInfo mRsrpInfoOnEUTRAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP) .setThresholds(new int[]{-115, -105, -95, -85}) .build(); private SignalThresholdInfo mRsrqInfoEUTRAN = new SignalThresholdInfo.Builder() .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN) .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ) .setThresholds(new int[]{-30, -20, -10, -1}) .build(); @Test @SmallTest public void testPublicConstructorWithInvalidParam() { // null Collection validateBuilderWithInvalidParam(null); // duplication of SignalMeasurementType in Collection validateBuilderWithInvalidParam(List.of(mRssiInfo, mRssiInfo)); // duplication of SignalMeasurementType for the same RAN in Collection validateBuilderWithInvalidParam(List.of(mRssiInfoOnGERAN, mRssiInfoOnGERAN2)); // The following two cases can not turn on until the implement is ready: // empty Collections // validateBuilderWithInvalidParam(List.of()); validateBuilderWithInvalidParam(List.of()); } @Test @SmallTest public void testPublicConstructorWithValidParam() { Collection<SignalThresholdInfo> infos = List.of(mRssiInfo, mRscpInfo); Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRscpInfoOnUTRAN); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).setReportingRequestedWhileIdle(false).build(); assertFalse(request.isReportingRequestedWhileIdle()); Loading @@ -74,7 +97,7 @@ public class SignalStrengthUpdateRequestTest extends TestCase { @Test @SmallTest public void testParcel() { Collection<SignalThresholdInfo> infos = List.of(mRssiInfo, mRscpInfo); Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRscpInfoOnUTRAN); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).setReportingRequestedWhileIdle(true).build(); Loading @@ -90,14 +113,14 @@ public class SignalStrengthUpdateRequestTest extends TestCase { @Test @SmallTest public void testEquals() { Collection<SignalThresholdInfo> infos1 = List.of(mRssiInfo, mRscpInfo); Collection<SignalThresholdInfo> infos1 = List.of(mRssiInfoOnGERAN, mRssiInfoOnCDMA2000); SignalStrengthUpdateRequest request1 = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos1).setReportingRequestedWhileIdle(false).build(); assertTrue(request1.equals(request1)); // Ordering does not matter Collection<SignalThresholdInfo> infos2 = List.of(mRscpInfo, mRssiInfo); Collection<SignalThresholdInfo> infos2 = List.of(mRssiInfoOnCDMA2000, mRssiInfoOnGERAN); SignalStrengthUpdateRequest request2 = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos2).setReportingRequestedWhileIdle(false).build(); assertTrue(request1.equals(request2)); Loading @@ -109,11 +132,36 @@ public class SignalStrengthUpdateRequestTest extends TestCase { SignalStrengthUpdateRequest request4 = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos1).setReportingRequestedWhileIdle(false) .setSystemThresholdReportingRequestedWhileIdle(true).build(); assertFalse(request1.equals(request4)); // return false if the object is not SignalStrengthUpdateRequest assertFalse(request1.equals("test")); } @Test @SmallTest public void testMultipleSignalMeasurementTypeOnSameRan() { Collection<SignalThresholdInfo> infos = List.of(mRsrpInfoOnEUTRAN, mRsrqInfoEUTRAN); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).build(); assertFalse(request.isReportingRequestedWhileIdle()); assertFalse(request.isSystemThresholdReportingRequestedWhileIdle()); assertEquals(infos, request.getSignalThresholdInfos()); } @Test @SmallTest public void testSameSignalMeasurementTypeOnDifferentRan() { Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRssiInfoOnCDMA2000); SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder() .setSignalThresholdInfos(infos).build(); assertFalse(request.isReportingRequestedWhileIdle()); assertFalse(request.isSystemThresholdReportingRequestedWhileIdle()); assertEquals(infos, request.getSignalThresholdInfos()); } private void validateBuilderWithInvalidParam(Collection<SignalThresholdInfo> infos) { try { new SignalStrengthUpdateRequest.Builder() Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +81 −2 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public class DataConnectionTest extends TelephonyTest { Handler h = new Handler(); mDcc = DcController.makeDcc(mPhone, mDcTracker, mDataServiceManager, h.getLooper(), ""); mDc = DataConnection.makeDataConnection(mPhone, 0, mDcTracker, mDataServiceManager, mDcTesterFailBringUpAll, mDcc, true); mDcTesterFailBringUpAll, mDcc); } } Loading Loading @@ -482,6 +482,63 @@ public class DataConnectionTest extends TelephonyTest { eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), anyInt(), any(), tdCaptor.capture(), anyBoolean(), any(Message.class)); verify(mSimulatedCommandsVerifier, times(0)) .allocatePduSessionId(any()); assertEquals("spmode.ne.jp", dpCaptor.getValue().getApn()); if (tdCaptor.getValue() != null) { if (mApnContext.getApnTypeBitmask() == ApnSetting.TYPE_ENTERPRISE) { assertEquals(null, tdCaptor.getValue().getDataNetworkName()); assertTrue(Arrays.equals(DataConnection.getEnterpriseOsAppId(), tdCaptor.getValue().getOsAppId())); } else { assertEquals("spmode.ne.jp", tdCaptor.getValue().getDataNetworkName()); assertEquals(null, tdCaptor.getValue().getOsAppId()); } } assertTrue(mDc.isActive()); assertEquals(1, mDc.getPduSessionId()); assertEquals(3, mDc.getPcscfAddresses().length); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c305:1d::8"::equals)); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c202:1d::7"::equals)); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c305:1d::5"::equals)); } @Test @SmallTest public void testConnectOnIwlan() throws Exception { assertTrue(mDc.isInactive()); Field field = DataConnection.class.getDeclaredField("mTransportType"); field.setAccessible(true); field.setInt(mDc, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); connectEvent(true); verify(mCT, times(1)).registerForVoiceCallStarted(any(Handler.class), eq(DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_STARTED), eq(null)); verify(mCT, times(1)).registerForVoiceCallEnded(any(Handler.class), eq(DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_ENDED), eq(null)); verify(mSimulatedCommandsVerifier, times(0)) .registerForNattKeepaliveStatus(any(Handler.class), eq(DataConnection.EVENT_KEEPALIVE_STATUS), eq(null)); verify(mSimulatedCommandsVerifier, times(0)) .registerForLceInfo(any(Handler.class), eq(DataConnection.EVENT_LINK_CAPACITY_CHANGED), eq(null)); verify(mVcnManager, atLeastOnce()) .applyVcnNetworkPolicy( argThat(caps -> caps.hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED)), any()); ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class); ArgumentCaptor<TrafficDescriptor> tdCaptor = ArgumentCaptor.forClass(TrafficDescriptor.class); verify(mDataServiceManager, times(1)).setupDataCall( eq(AccessNetworkType.UTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), anyInt(), any(), tdCaptor.capture(), anyBoolean(), any(Message.class)); verify(mSimulatedCommandsVerifier, times(1)) .allocatePduSessionId(any()); Loading @@ -498,7 +555,7 @@ public class DataConnectionTest extends TelephonyTest { } assertTrue(mDc.isActive()); assertEquals(mDc.getPduSessionId(), 1); assertEquals(1, mDc.getPduSessionId()); assertEquals(3, mDc.getPcscfAddresses().length); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c305:1d::8"::equals)); assertTrue(Arrays.stream(mDc.getPcscfAddresses()).anyMatch("fd00:976a:c202:1d::7"::equals)); Loading Loading @@ -575,6 +632,28 @@ public class DataConnectionTest extends TelephonyTest { .unregisterForNattKeepaliveStatus(any(Handler.class)); verify(mDataServiceManager, times(1)).deactivateDataCall(eq(DEFAULT_DC_CID), eq(DataService.REQUEST_REASON_NORMAL), any(Message.class)); verify(mSimulatedCommandsVerifier, times(0)) .releasePduSessionId(any(), eq(5)); assertTrue(mDc.isInactive()); } @Test @SmallTest public void testDisconnectOnIwlan() throws Exception { testConnectEvent(); Field field = DataConnection.class.getDeclaredField("mTransportType"); field.setAccessible(true); field.setInt(mDc, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); mDc.setPduSessionId(5); disconnectEvent(); verify(mSimulatedCommandsVerifier, times(0)).unregisterForLceInfo(any(Handler.class)); verify(mSimulatedCommandsVerifier, times(0)) .unregisterForNattKeepaliveStatus(any(Handler.class)); verify(mDataServiceManager, times(1)).deactivateDataCall(eq(DEFAULT_DC_CID), eq(DataService.REQUEST_REASON_NORMAL), any(Message.class)); verify(mSimulatedCommandsVerifier, times(1)) .releasePduSessionId(any(), eq(5)); Loading