Prevent SendJobs from sending already-sent messages.

This is to guard against behavior WorkManager has where it may
re-enqueue a job that has already been completed (if, for instance, it
was preempted).

Fixes #8268
This commit is contained in:
Greyson Parrelli
2018-11-14 11:39:23 -08:00
parent a7e15dc21e
commit d93bfbf693
7 changed files with 40 additions and 0 deletions

View File

@@ -1053,6 +1053,17 @@ public class MmsDatabase extends MessagingDatabase {
}
}
public boolean isSent(long messageId) {
SQLiteDatabase database = databaseHelper.getReadableDatabase();
try (Cursor cursor = database.query(TABLE_NAME, new String[] { MESSAGE_BOX }, ID + " = ?", new String[] { String.valueOf(messageId)}, null, null, null)) {
if (cursor != null && cursor.moveToNext()) {
long type = cursor.getLong(cursor.getColumnIndexOrThrow(MESSAGE_BOX));
return Types.isSentType(type);
}
}
return false;
}
/*package*/ void deleteThreads(Set<Long> threadIds) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
String where = "";

View File

@@ -117,6 +117,10 @@ public interface MmsSmsColumns {
(type & BASE_TYPE_MASK) == BASE_SENDING_TYPE;
}
public static boolean isSentType(long type) {
return (type & BASE_TYPE_MASK) == BASE_SENT_TYPE;
}
public static boolean isPendingSmsFallbackType(long type) {
return (type & BASE_TYPE_MASK) == BASE_PENDING_INSECURE_SMS_FALLBACK ||
(type & BASE_TYPE_MASK) == BASE_PENDING_SECURE_SMS_FALLBACK;