use of com.google.android.mms.pdu.ReadOrigInd in project android-aosp-mms by slvn.
the class PushReceiver method findThreadId.
private static long findThreadId(Context context, GenericPdu pdu, int type) {
String messageId;
if (type == MESSAGE_TYPE_DELIVERY_IND) {
messageId = new String(((DeliveryInd) pdu).getMessageId());
} else {
messageId = new String(((ReadOrigInd) pdu).getMessageId());
}
StringBuilder sb = new StringBuilder('(');
sb.append(Mms.MESSAGE_ID);
sb.append('=');
sb.append(DatabaseUtils.sqlEscapeString(messageId));
sb.append(" AND ");
sb.append(Mms.MESSAGE_TYPE);
sb.append('=');
sb.append(PduHeaders.MESSAGE_TYPE_SEND_REQ);
// TODO ContentResolver.query() appends closing ')' to the selection argument
// sb.append(')');
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), Mms.CONTENT_URI, new String[] { Mms.THREAD_ID }, sb.toString(), null, null);
if (cursor != null) {
try {
if ((cursor.getCount() == 1) && cursor.moveToFirst()) {
return cursor.getLong(0);
}
} finally {
cursor.close();
}
}
return -1;
}
use of com.google.android.mms.pdu.ReadOrigInd in project android_frameworks_opt_telephony by LineageOS.
the class WapPushOverSms method getDeliveryOrReadReportThreadId.
@UnsupportedAppUsage
private static long getDeliveryOrReadReportThreadId(Context context, GenericPdu pdu) {
String messageId;
if (pdu instanceof DeliveryInd) {
messageId = new String(((DeliveryInd) pdu).getMessageId());
} else if (pdu instanceof ReadOrigInd) {
messageId = new String(((ReadOrigInd) pdu).getMessageId());
} else {
Rlog.e(TAG, "WAP Push data is neither delivery or read report type: " + pdu.getClass().getCanonicalName());
return -1L;
}
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(Telephony.Mms.CONTENT_URI, new String[] { Telephony.Mms.THREAD_ID }, THREAD_ID_SELECTION, new String[] { DatabaseUtils.sqlEscapeString(messageId), Integer.toString(PduHeaders.MESSAGE_TYPE_SEND_REQ) }, null);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(0);
}
} catch (SQLiteException e) {
Rlog.e(TAG, "Failed to query delivery or read report thread id", e);
} finally {
if (cursor != null) {
cursor.close();
}
}
return -1L;
}
Aggregations