Search in sources :

Example 1 with DeliveryInd

use of com.google.android.mms.pdu.DeliveryInd 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;
}
Also used : DeliveryInd(com.google.android.mms.pdu.DeliveryInd) ReadOrigInd(com.google.android.mms.pdu.ReadOrigInd) Cursor(android.database.Cursor)

Example 2 with DeliveryInd

use of com.google.android.mms.pdu.DeliveryInd 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;
}
Also used : DeliveryInd(com.google.android.mms.pdu.DeliveryInd) ReadOrigInd(com.google.android.mms.pdu.ReadOrigInd) Cursor(android.database.Cursor) SQLiteException(android.database.sqlite.SQLiteException) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Aggregations

Cursor (android.database.Cursor)2 DeliveryInd (com.google.android.mms.pdu.DeliveryInd)2 ReadOrigInd (com.google.android.mms.pdu.ReadOrigInd)2 UnsupportedAppUsage (android.compat.annotation.UnsupportedAppUsage)1 SQLiteException (android.database.sqlite.SQLiteException)1