summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortnmy-cyngn <tlnu@cyngn.com>2016-04-25 19:19:17 +0530
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-04-26 03:36:20 -0700
commit01868a1210fc38e7483fdc8d84b7b5ef96159576 (patch)
tree6baa02db1561b75051acdef1c05eb1b5b97c445a /src
parent4052475dd64ecd5445c2f60edb6b644e47315a79 (diff)
downloadandroid_packages_apps_Messaging-01868a1210fc38e7483fdc8d84b7b5ef96159576.tar.gz
android_packages_apps_Messaging-01868a1210fc38e7483fdc8d84b7b5ef96159576.tar.bz2
android_packages_apps_Messaging-01868a1210fc38e7483fdc8d84b7b5ef96159576.zip
Fixed the cutoff timestamp for MMS deletion by limit.
Also null check for query selection arguments. Bug: PAELLA-195 Change-Id: I7a2caba894c9a371dbdd7ddb38e17406b5df1818
Diffstat (limited to 'src')
-rw-r--r--src/com/android/messaging/datamodel/action/MessageRecyclerAction.java4
-rw-r--r--src/com/android/messaging/sms/MmsUtils.java15
2 files changed, 11 insertions, 8 deletions
diff --git a/src/com/android/messaging/datamodel/action/MessageRecyclerAction.java b/src/com/android/messaging/datamodel/action/MessageRecyclerAction.java
index 86da6aa..5e1424d 100644
--- a/src/com/android/messaging/datamodel/action/MessageRecyclerAction.java
+++ b/src/com/android/messaging/datamodel/action/MessageRecyclerAction.java
@@ -41,13 +41,13 @@ public class MessageRecyclerAction extends Action implements Parcelable {
public static void deleteMessagesOverLimit(final String conversationId, int protocol) {
if (!PrefsUtils.isAutoDeleteEnabled() || (protocol != MessageData.PROTOCOL_SMS
- && protocol != MessageData.PROTOCOL_MMS)) {
+ && protocol != MessageData.PROTOCOL_MMS) || conversationId == null) {
return;
}
int cutOffLimit = PrefsUtils.getMessagesPerThreadLimitByProtocol(protocol);
long cutOffTimeStampFromLimit = BugleDatabaseOperations.
- getCutOffTimeStampFromLimit(conversationId, cutOffLimit, MessageData.PROTOCOL_SMS);
+ getCutOffTimeStampFromLimit(conversationId, cutOffLimit, protocol);
if (cutOffTimeStampFromLimit > Long.MIN_VALUE) {
deleteMessages(conversationId, protocol, cutOffTimeStampFromLimit);
diff --git a/src/com/android/messaging/sms/MmsUtils.java b/src/com/android/messaging/sms/MmsUtils.java
index 1fd811f..4f5d223 100644
--- a/src/com/android/messaging/sms/MmsUtils.java
+++ b/src/com/android/messaging/sms/MmsUtils.java
@@ -1391,29 +1391,32 @@ public class MmsUtils {
Uri uri;
String selectionSql;
String dateField;
+ long cutOffTimeStamp = Long.MIN_VALUE;
switch (protocol) {
case MessageData.PROTOCOL_SMS:
uri = Sms.CONTENT_URI;
selectionSql = getSmsTypeSelectionSql();
+ cutOffTimeStamp = cutOffTimestampInMillis;
dateField = Sms.DATE;
break;
case MessageData.PROTOCOL_MMS:
uri = Mms.CONTENT_URI;
selectionSql = getMmsTypeSelectionSql();
+ cutOffTimeStamp = cutOffTimestampInMillis / 1000L;
dateField = Mms.DATE;
break;
default:
return 0;
}
final ContentResolver resolver =
- Factory.get().getApplicationContext().getContentResolver();
+ Factory.get().getApplicationContext().getContentResolver();
final String selection = String.format(
- Locale.US,
- "%s AND (%s<=%d)",
- selectionSql,
- dateField,
- cutOffTimestampInMillis);
+ Locale.US,
+ "%s AND (%s<=%d)",
+ selectionSql,
+ dateField,
+ cutOffTimeStamp);
int deleted = resolver.delete(uri, selection, null);
return deleted;