Loading src/java/com/android/internal/telephony/InboundSmsHandler.java +14 −10 Original line number Diff line number Diff line Loading @@ -781,6 +781,14 @@ public abstract class InboundSmsHandler extends StateMachine { } } // Do not process null pdu(s). Check for that and return false in that case. List<byte[]> pduList = Arrays.asList(pdus); if (pduList.size() == 0 || pduList.contains(null)) { loge("processMessagePart: returning false due to " + (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)")); return false; } if (!mUserManager.isUserUnlocked()) { return processMessagePartWithUserLocked(tracker, pdus, destPort); } Loading @@ -794,7 +802,12 @@ public abstract class InboundSmsHandler extends StateMachine { // 3GPP needs to extract the User Data from the PDU; 3GPP2 has already done this if (!tracker.is3gpp2()) { SmsMessage msg = SmsMessage.createFromPdu(pdu, SmsConstants.FORMAT_3GPP); if (msg != null) { pdu = msg.getUserData(); } else { loge("processMessagePart: SmsMessage.createFromPdu returned null"); return false; } } output.write(pdu, 0, pdu.length); } Loading Loading @@ -889,15 +902,6 @@ public abstract class InboundSmsHandler extends StateMachine { */ private boolean filterSmsWithCarrierOrSystemApp(byte[][] pdus, int destPort, InboundSmsTracker tracker, SmsBroadcastReceiver resultReceiver, boolean userUnlocked) { // Do not send null pdu(s) to CarrierSmsFilter. Check for that and return false in that case List<byte[]> pduList = Arrays.asList(pdus); if (pduList == null || pduList.size() == 0 || pduList.contains(null)) { loge("filterSmsWithCarrierOrSystemApp: Bypassing carrier/system sms filter due to " + (pduList == null ? "pduList == null" : (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)"))); return false; } List<String> carrierPackages = null; UiccCard card = UiccController.getInstance().getUiccCard(mPhone.getPhoneId()); if (card != null) { Loading tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java +40 −0 Original line number Diff line number Diff line Loading @@ -594,6 +594,46 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest { assertEquals("IdleState", getCurrentState().getName()); } @Test @MediumTest public void testMultiPartIncompleteSms() { /** * Test scenario: 2 messages are received with same address, ref number, count, and * seqNumber, with count = 2 and seqNumber = 1. We should not try to merge these. */ transitionFromStartupToIdle(); // prepare SMS part 1 and part 2 prepareMultiPartSms(); // change seqNumber in part 2 to 1 mInboundSmsTrackerCVPart2.put("sequence", 1); mSmsHeader.concatRef = new SmsHeader.ConcatRef(); doReturn(mSmsHeader).when(mGsmSmsMessage).getUserDataHeader(); doReturn(mInboundSmsTrackerPart1).when(mTelephonyComponentFactory) .makeInboundSmsTracker(any(byte[].class), anyLong(), anyInt(), anyBoolean(), anyString(), anyInt(), anyInt(), anyInt(), anyBoolean(), anyString()); mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null)); waitForMs(100); // State machine should go back to idle and wait for second part assertEquals("IdleState", getCurrentState().getName()); doReturn(mInboundSmsTrackerPart2).when(mTelephonyComponentFactory) .makeInboundSmsTracker(any(byte[].class), anyLong(), anyInt(), anyBoolean(), anyString(), anyInt(), anyInt(), anyInt(), anyBoolean(), anyString()); mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null)); waitForMs(100); // verify no broadcasts sent verify(mContext, never()).sendBroadcast(any(Intent.class)); // State machine should go back to idle assertEquals("IdleState", getCurrentState().getName()); } @Test @MediumTest public void testMultipartSmsFromBlockedNumber_noBroadcastsSent() { Loading Loading
src/java/com/android/internal/telephony/InboundSmsHandler.java +14 −10 Original line number Diff line number Diff line Loading @@ -781,6 +781,14 @@ public abstract class InboundSmsHandler extends StateMachine { } } // Do not process null pdu(s). Check for that and return false in that case. List<byte[]> pduList = Arrays.asList(pdus); if (pduList.size() == 0 || pduList.contains(null)) { loge("processMessagePart: returning false due to " + (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)")); return false; } if (!mUserManager.isUserUnlocked()) { return processMessagePartWithUserLocked(tracker, pdus, destPort); } Loading @@ -794,7 +802,12 @@ public abstract class InboundSmsHandler extends StateMachine { // 3GPP needs to extract the User Data from the PDU; 3GPP2 has already done this if (!tracker.is3gpp2()) { SmsMessage msg = SmsMessage.createFromPdu(pdu, SmsConstants.FORMAT_3GPP); if (msg != null) { pdu = msg.getUserData(); } else { loge("processMessagePart: SmsMessage.createFromPdu returned null"); return false; } } output.write(pdu, 0, pdu.length); } Loading Loading @@ -889,15 +902,6 @@ public abstract class InboundSmsHandler extends StateMachine { */ private boolean filterSmsWithCarrierOrSystemApp(byte[][] pdus, int destPort, InboundSmsTracker tracker, SmsBroadcastReceiver resultReceiver, boolean userUnlocked) { // Do not send null pdu(s) to CarrierSmsFilter. Check for that and return false in that case List<byte[]> pduList = Arrays.asList(pdus); if (pduList == null || pduList.size() == 0 || pduList.contains(null)) { loge("filterSmsWithCarrierOrSystemApp: Bypassing carrier/system sms filter due to " + (pduList == null ? "pduList == null" : (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)"))); return false; } List<String> carrierPackages = null; UiccCard card = UiccController.getInstance().getUiccCard(mPhone.getPhoneId()); if (card != null) { Loading
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java +40 −0 Original line number Diff line number Diff line Loading @@ -594,6 +594,46 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest { assertEquals("IdleState", getCurrentState().getName()); } @Test @MediumTest public void testMultiPartIncompleteSms() { /** * Test scenario: 2 messages are received with same address, ref number, count, and * seqNumber, with count = 2 and seqNumber = 1. We should not try to merge these. */ transitionFromStartupToIdle(); // prepare SMS part 1 and part 2 prepareMultiPartSms(); // change seqNumber in part 2 to 1 mInboundSmsTrackerCVPart2.put("sequence", 1); mSmsHeader.concatRef = new SmsHeader.ConcatRef(); doReturn(mSmsHeader).when(mGsmSmsMessage).getUserDataHeader(); doReturn(mInboundSmsTrackerPart1).when(mTelephonyComponentFactory) .makeInboundSmsTracker(any(byte[].class), anyLong(), anyInt(), anyBoolean(), anyString(), anyInt(), anyInt(), anyInt(), anyBoolean(), anyString()); mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null)); waitForMs(100); // State machine should go back to idle and wait for second part assertEquals("IdleState", getCurrentState().getName()); doReturn(mInboundSmsTrackerPart2).when(mTelephonyComponentFactory) .makeInboundSmsTracker(any(byte[].class), anyLong(), anyInt(), anyBoolean(), anyString(), anyInt(), anyInt(), anyInt(), anyBoolean(), anyString()); mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null)); waitForMs(100); // verify no broadcasts sent verify(mContext, never()).sendBroadcast(any(Intent.class)); // State machine should go back to idle assertEquals("IdleState", getCurrentState().getName()); } @Test @MediumTest public void testMultipartSmsFromBlockedNumber_noBroadcastsSent() { Loading