use of com.android.internal.telephony.InboundSmsTracker in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testMultipartSmsFromBlockedEmail_noBroadcastsSent.
@Test
@MediumTest
public void testMultipartSmsFromBlockedEmail_noBroadcastsSent() {
mFakeBlockedNumberContentProvider.mBlockedNumbers.add("1234567890@test.com");
transitionFromStartupToIdle();
// prepare SMS part 1 and part 2
prepareMultiPartSms(false);
// only the first SMS is configured with the display originating email address
mInboundSmsTrackerPart1 = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
-1, /* destPort */
false, /* is3gpp2 */
"1234567890", /* address */
"1234567890@test.com", /* displayAddress */
1, /* referenceNumber */
1, /* sequenceNumber */
2, /* messageCount */
false, /* is3gpp2WapPdu */
mMessageBodyPart1, /* messageBody */
false, /* isClass0 */
mSubId0);
mSmsHeader.concatRef = new SmsHeader.ConcatRef();
doReturn(mSmsHeader).when(mGsmSmsMessage).getUserDataHeader();
doReturn(mInboundSmsTrackerPart1).when(mTelephonyComponentFactory).makeInboundSmsTracker(any(Context.class), nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), nullable(String.class), nullable(String.class), anyInt(), anyInt(), anyInt(), anyBoolean(), nullable(String.class), anyBoolean(), anyInt());
sendNewSms();
// State machine should go back to idle and wait for second part
assertEquals("IdleState", getCurrentState().getName());
doReturn(mInboundSmsTrackerPart2).when(mTelephonyComponentFactory).makeInboundSmsTracker(any(Context.class), nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), nullable(String.class), nullable(String.class), anyInt(), anyInt(), anyInt(), anyBoolean(), nullable(String.class), anyBoolean(), anyInt());
sendNewSms();
verify(mContext, never()).sendBroadcast(any(Intent.class));
assertEquals("IdleState", getCurrentState().getName());
// Filter should still be invoked.
verifySmsFiltersInvoked(times(1));
}
use of com.android.internal.telephony.InboundSmsTracker in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp("GsmInboundSmsHandlerTest");
doReturn(true).when(mTelephonyManager).getSmsReceiveCapableForPhone(anyInt(), anyBoolean());
doReturn(true).when(mSmsStorageMonitor).isStorageAvailable();
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
doReturn(true).when(userManager).isUserUnlocked();
doReturn(true).when(userManager).isUserRunning(any(UserHandle.class));
List<UserHandle> userHandles = new ArrayList();
userHandles.add(UserHandle.SYSTEM);
doReturn(userHandles).when(userManager).getUserHandles(anyBoolean());
mSmsMessage.mWrappedSmsMessage = mGsmSmsMessage;
mInboundSmsTracker = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
-1, /* destPort */
false, /* is3gpp2 */
false, /* is3gpp2WapPdu */
"1234567890", /* address */
"1234567890", /* displayAddress */
mMessageBody, /* messageBody */
false, /* isClass0 */
mSubId0);
doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory).makeInboundSmsTracker(any(Context.class), nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), anyBoolean(), nullable(String.class), nullable(String.class), nullable(String.class), anyBoolean(), anyInt());
createMockInboundSmsTracker();
mContentProvider = new FakeSmsContentProvider();
((MockContentResolver) mContext.getContentResolver()).addProvider(Telephony.Sms.CONTENT_URI.getAuthority(), mContentProvider);
mGsmInboundSmsHandler = GsmInboundSmsHandler.makeInboundSmsHandler(mContext, mSmsStorageMonitor, mPhone);
mSmsFilters = new ArrayList<>();
mSmsFilters.add(mSmsFilter);
mSmsFilters.add(mSmsFilter2);
mGsmInboundSmsHandler.setSmsFiltersForTesting(mSmsFilters);
monitorTestableLooper(new TestableLooper(mGsmInboundSmsHandler.getHandler().getLooper()));
processAllMessages();
}
use of com.android.internal.telephony.InboundSmsTracker in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testClass0Sms.
@Test
@MediumTest
public void testClass0Sms() {
transitionFromStartupToIdle();
mInboundSmsTracker = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
-1, /* destPort */
false, /* is3gpp2 */
false, /* is3gpp2WapPdu */
"1234567890", /* address */
"1234567890", /* displayAddress */
mMessageBody, /* messageBody */
true, /* isClass0 */
mSubId0);
doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory).makeInboundSmsTracker(any(Context.class), nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), anyBoolean(), nullable(String.class), nullable(String.class), nullable(String.class), anyBoolean(), anyInt());
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_BROADCAST_SMS, mInboundSmsTracker);
processAllMessages();
verifySmsIntentBroadcasts(0, true);
verifySmsFiltersInvoked(times(1));
}
use of com.android.internal.telephony.InboundSmsTracker in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method prepareMultiPartSms.
private void prepareMultiPartSms(boolean is3gpp2WapPush) {
// Part 1
mInboundSmsTrackerPart1 = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
-1, /* destPort */
is3gpp2WapPush, /* is3gpp2 */
"1234567890", /* address */
"1234567890", /* displayAddress */
1, /* referenceNumber */
1, /* sequenceNumber */
2, /* messageCount */
is3gpp2WapPush, /* is3gpp2WapPdu */
mMessageBodyPart1, /* messageBody */
false, /* isClass0 */
mSubId0);
// Part 2
mInboundSmsTrackerPart2 = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
-1, /* destPort */
is3gpp2WapPush, /* is3gpp2 */
"1234567890", /* address */
"1234567890", /* displayAddress */
1, /* referenceNumber */
2, /* sequenceNumber */
2, /* messageCount */
is3gpp2WapPush, /* is3gpp2WapPdu */
mMessageBodyPart2, /* messageBody */
false, /* isClass0 */
mSubId0);
}
use of com.android.internal.telephony.InboundSmsTracker in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testBroadcastUndeliveredDeleted.
@Test
@MediumTest
public void testBroadcastUndeliveredDeleted() throws Exception {
replaceInstance(SmsBroadcastUndelivered.class, "instance", null, null);
SmsBroadcastUndelivered.initialize(mContext, mGsmInboundSmsHandler, mCdmaInboundSmsHandler);
mInboundSmsTracker = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
0, /* destPort */
false, /* is3gpp2 */
false, /* is3gpp2WapPdu */
"1234567890", /* address */
"1234567890", /* displayAddress */
mMessageBody, /* messageBody */
false, /* isClass0 */
mSubId0);
doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory).makeInboundSmsTracker(any(Context.class), nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), anyBoolean(), nullable(String.class), nullable(String.class), nullable(String.class), anyBoolean(), anyInt());
// add a fake entry to db
ContentValues rawSms = new ContentValues();
rawSms.put("deleted", 1);
mContentProvider.insert(sRawUri, rawSms);
// when user unlocks the device, broadcast should not be sent for new message
mContext.sendBroadcast(new Intent(Intent.ACTION_USER_UNLOCKED));
// wait for ScanRawTableThread
waitForMs(100);
processAllMessages();
verify(mContext, times(1)).sendBroadcast(any(Intent.class));
assertEquals("IdleState", getCurrentState().getName());
verifySmsFiltersInvoked(never());
}
Aggregations