use of com.android.internal.telephony.FakeSmsContentProvider in project android_frameworks_opt_telephony by LineageOS.
the class CdmaInboundSmsHandlerTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp("CdmaInboundSmsHandlerTest");
Field field = SmsMessage.class.getDeclaredField("mEnvelope");
field.setAccessible(true);
field.set(mCdmaSmsMessage, mSmsEnvelope);
UserManager userManager = (UserManager) mContextFixture.getTestDouble().getSystemService(Context.USER_SERVICE);
doReturn(true).when(userManager).isUserUnlocked();
try {
doReturn(new int[] { UserHandle.USER_SYSTEM }).when(mIActivityManager).getRunningUserIds();
} catch (RemoteException re) {
fail("Unexpected RemoteException: " + re.getStackTrace());
}
mSmsMessage.mWrappedSmsMessage = mCdmaSmsMessage;
doReturn(mSmsPdu).when(mCdmaSmsMessage).getPdu();
doReturn(true).when(mTelephonyManager).getSmsReceiveCapableForPhone(anyInt(), anyBoolean());
doReturn(true).when(mSmsStorageMonitor).isStorageAvailable();
mInboundSmsTracker = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
-1, /* destPort */
true, /* is3gpp2 */
false, /* is3gpp2WapPdu */
"1234567890", /* address */
"1234567890", /* displayAddress */
"This is the message body of a single-part message", /* 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());
doReturn(mInboundSmsTracker).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());
doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory).makeInboundSmsTracker(any(Context.class), nullable(Cursor.class), anyBoolean());
mContentProvider = new FakeSmsContentProvider();
((MockContentResolver) mContext.getContentResolver()).addProvider(Telephony.Sms.CONTENT_URI.getAuthority(), mContentProvider);
mCdmaInboundSmsHandler = CdmaInboundSmsHandler.makeInboundSmsHandler(mContext, mSmsStorageMonitor, mPhone, null);
monitorTestableLooper(new TestableLooper(mCdmaInboundSmsHandler.getHandler().getLooper()));
processAllMessages();
}
use of com.android.internal.telephony.FakeSmsContentProvider 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();
}
Aggregations