summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-07-30 14:49:32 -0700
committerYorke Lee <yorkelee@google.com>2014-07-30 14:49:32 -0700
commit4a47775ab4008165328ddab97f5151ddd94d9ab8 (patch)
tree9b265076ed190537f2267bf169912ba1806b0029 /src
parent7f4ce37bd099d8dbad3177a2b9ebe341811a5ce2 (diff)
downloadpackages_providers_ContactsProvider-4a47775ab4008165328ddab97f5151ddd94d9ab8.zip
packages_providers_ContactsProvider-4a47775ab4008165328ddab97f5151ddd94d9ab8.tar.gz
packages_providers_ContactsProvider-4a47775ab4008165328ddab97f5151ddd94d9ab8.tar.bz2
Fix broken aggregation behavior for pinned contacts and tests
Update the value of some pre-defined constants in tests Make sure that aggregation correctly sets pinned positions for aggregated contacts - the lowest pinned position of all constituent raw contacts, and 0 if none of them are pinned. Bug: 16628573 Change-Id: I3e072baf7ff933a6eef861ed394f3fc817aee48b
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/contacts/aggregation/ContactAggregator.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/com/android/providers/contacts/aggregation/ContactAggregator.java b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
index 88369f9..390871c 100644
--- a/src/com/android/providers/contacts/aggregation/ContactAggregator.java
+++ b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
@@ -337,10 +337,11 @@ public class ContactAggregator {
+ RawContacts.STARRED + "=1)" + " WHERE " + Contacts._ID + "=?");
mPinnedUpdate = db.compileStatement("UPDATE " + Tables.CONTACTS + " SET "
- + Contacts.PINNED + "=(SELECT MIN(" + RawContacts.PINNED + ") FROM "
+ + Contacts.PINNED + " = IFNULL((SELECT MIN(" + RawContacts.PINNED + ") FROM "
+ Tables.RAW_CONTACTS + " WHERE " + RawContacts.CONTACT_ID + "="
+ ContactsColumns.CONCRETE_ID + " AND " + RawContacts.PINNED + ">"
- + PinnedPositions.DEMOTED + ") WHERE " + Contacts._ID + "=?");
+ + PinnedPositions.UNPINNED + ")," + PinnedPositions.UNPINNED + ") "
+ + "WHERE " + Contacts._ID + "=?");
mContactIdAndMarkAggregatedUpdate = db.compileStatement(
"UPDATE " + Tables.RAW_CONTACTS +
@@ -1857,7 +1858,7 @@ public class ContactAggregator {
long contactLastTimeContacted = 0;
int contactTimesContacted = 0;
int contactStarred = 0;
- int contactPinned = PinnedPositions.UNPINNED;
+ int contactPinned = Integer.MAX_VALUE;
int hasPhoneNumber = 0;
StringBuilder lookupKey = new StringBuilder();
@@ -1917,7 +1918,7 @@ public class ContactAggregator {
// contactPinned should be the lowest value of its constituent raw contacts,
// excluding negative integers
final int rawContactPinned = c.getInt(RawContactsQuery.PINNED);
- if (rawContactPinned >= 0) {
+ if (rawContactPinned > PinnedPositions.UNPINNED) {
contactPinned = Math.min(contactPinned, rawContactPinned);
}
@@ -1961,6 +1962,10 @@ public class ContactAggregator {
c.close();
}
+ if (contactPinned == Integer.MAX_VALUE) {
+ contactPinned = PinnedPositions.UNPINNED;
+ }
+
statement.bindLong(ContactReplaceSqlStatement.NAME_RAW_CONTACT_ID,
mDisplayNameCandidate.rawContactId);