summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2017-06-01 14:12:54 -0700
committerTyler Gunn <tgunn@google.com>2017-08-09 09:53:00 -0700
commitc971bf1760b5858a0b5e4fbaf6e4269a577f2d11 (patch)
tree57e9628c0265cc45d62b5230225fbf13e02be137
parentc06dbc114f839112f1132e1e0edac8533b3f4c54 (diff)
downloadbase-c971bf1760b5858a0b5e4fbaf6e4269a577f2d11.tar.gz
Enforce call log length limit on a per PhoneAccount basis.
Performing the auto delete based on the PhoneAccount of the new entry. This ensures no one CS can cause the removal of entries by another. Test: Manual Bug: 38196259 Merged-In: I382cb62a1b2b7e482c49ece05f90fc982b797add Change-Id: I382cb62a1b2b7e482c49ece05f90fc982b797add
-rw-r--r--core/java/android/provider/CallLog.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index c7c6ceb5c16d..3ed335cfd0a6 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -849,10 +849,34 @@ public class CallLog {
}
try {
+ // When cleaning up the call log, try to delete older call long entries on a per
+ // PhoneAccount basis first. There can be multiple ConnectionServices causing
+ // the addition of entries in the call log. With the introduction of Self-Managed
+ // ConnectionServices, we want to ensure that a misbehaving self-managed CS cannot
+ // spam the call log with its own entries, causing entries from Telephony to be
+ // removed.
final Uri result = resolver.insert(uri, values);
- resolver.delete(uri, "_id IN " +
- "(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
- + " LIMIT -1 OFFSET 500)", null);
+ if (values.containsKey(PHONE_ACCOUNT_ID)
+ && !TextUtils.isEmpty(values.getAsString(PHONE_ACCOUNT_ID))
+ && values.containsKey(PHONE_ACCOUNT_COMPONENT_NAME)
+ && !TextUtils.isEmpty(values.getAsString(PHONE_ACCOUNT_COMPONENT_NAME))) {
+ // Only purge entries for the same phone account.
+ resolver.delete(uri, "_id IN " +
+ "(SELECT _id FROM calls"
+ + " WHERE " + PHONE_ACCOUNT_COMPONENT_NAME + " = ?"
+ + " AND " + PHONE_ACCOUNT_ID + " = ?"
+ + " ORDER BY " + DEFAULT_SORT_ORDER
+ + " LIMIT -1 OFFSET 500)", new String[] {
+ values.getAsString(PHONE_ACCOUNT_COMPONENT_NAME),
+ values.getAsString(PHONE_ACCOUNT_ID)
+ });
+ } else {
+ // No valid phone account specified, so default to the old behavior.
+ resolver.delete(uri, "_id IN " +
+ "(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
+ + " LIMIT -1 OFFSET 500)", null);
+ }
+
return result;
} catch (IllegalArgumentException e) {
Log.w(LOG_TAG, "Failed to insert calllog", e);