PushReceiverpublic class PushReceiver extends android.content.BroadcastReceiver Receives Intent.WAP_PUSH_RECEIVED_ACTION intents and starts the
TransactionService by passing the push-data to it. |
Fields Summary |
---|
private static final String | TAG | private static final boolean | DEBUG | private static final boolean | LOCAL_LOGV |
Methods Summary |
---|
private static long | findThreadId(android.content.Context context, com.google.android.mms.pdu.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;
| private static boolean | isDuplicateNotification(android.content.Context context, com.google.android.mms.pdu.NotificationInd nInd)
byte[] rawLocation = nInd.getContentLocation();
if (rawLocation != null) {
String location = new String(rawLocation);
String selection = Mms.CONTENT_LOCATION + " = ?";
String[] selectionArgs = new String[] { location };
Cursor cursor = SqliteWrapper.query(
context, context.getContentResolver(),
Mms.CONTENT_URI, new String[] { Mms._ID },
selection, selectionArgs, null);
if (cursor != null) {
try {
if (cursor.getCount() > 0) {
// We already received the same notification before.
return true;
}
} finally {
cursor.close();
}
}
}
return false;
| public void | onReceive(android.content.Context context, android.content.Intent intent)
if (intent.getAction().equals(WAP_PUSH_RECEIVED_ACTION)
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
if (LOCAL_LOGV) {
Log.v(TAG, "Received PUSH Intent: " + intent);
}
// Hold a wake lock for 5 seconds, enough to give any
// services we start time to take their own wake locks.
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MMS PushReceiver");
wl.acquire(5000);
new ReceivePushTask(context).execute(intent);
}
|
|