diff options
author | Vasu Nori <vnori@google.com> | 2009-12-11 14:01:22 -0800 |
---|---|---|
committer | Vasu Nori <vnori@google.com> | 2009-12-11 14:07:20 -0800 |
commit | 6e38acbd1e72c62a6f8917297aed97e35c0c4697 (patch) | |
tree | 6acc865c89bb5f79d7b370cdf5e573c1bf32d55d /src/com/android/providers/contacts/LegacyApiSupport.java | |
parent | 9b1bd62417ef1764829398a61c3d5df93a924106 (diff) | |
download | packages_providers_ContactsProvider-6e38acbd1e72c62a6f8917297aed97e35c0c4697.tar.gz packages_providers_ContactsProvider-6e38acbd1e72c62a6f8917297aed97e35c0c4697.tar.bz2 packages_providers_ContactsProvider-6e38acbd1e72c62a6f8917297aed97e35c0c4697.zip |
Update times_contacted manually since triggers to do that are gone.
This is fallout from CL # 35440. this change seems to effect only the unittests
Diffstat (limited to 'src/com/android/providers/contacts/LegacyApiSupport.java')
-rw-r--r-- | src/com/android/providers/contacts/LegacyApiSupport.java | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/com/android/providers/contacts/LegacyApiSupport.java b/src/com/android/providers/contacts/LegacyApiSupport.java index 703230d0..8d7da998 100644 --- a/src/com/android/providers/contacts/LegacyApiSupport.java +++ b/src/com/android/providers/contacts/LegacyApiSupport.java @@ -45,6 +45,7 @@ import android.provider.ContactsContract; import android.provider.Contacts.ContactMethods; import android.provider.Contacts.Extensions; import android.provider.Contacts.People; +import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.Groups; import android.provider.ContactsContract.RawContacts; @@ -188,6 +189,18 @@ public class LegacyApiSupport { private static final Uri LIVE_FOLDERS_CONTACTS_FAVORITES_URI = Uri.withAppendedPath( ContactsContract.AUTHORITY_URI, "live_folders/favorites"); + private static final String CONTACTS_UPDATE_LASTTIMECONTACTED = + "UPDATE " + Tables.CONTACTS + + " SET " + Contacts.LAST_TIME_CONTACTED + "=? " + + "WHERE " + Contacts._ID + "=?"; + private static final String RAWCONTACTS_UPDATE_LASTTIMECONTACTED = + "UPDATE " + Tables.RAW_CONTACTS + " SET " + + RawContacts.LAST_TIME_CONTACTED + "=? WHERE " + + RawContacts._ID + "=?"; + + private String[] mSelectionArgs1 = new String[1]; + private String[] mSelectionArgs2 = new String[2]; + public interface LegacyTables { public static final String PEOPLE = "view_v1_people"; public static final String PEOPLE_JOIN_PRESENCE = "view_v1_people people " + PRESENCE_JOINS; @@ -484,8 +497,6 @@ public class LegacyApiSupport { private final NameSplitter mPhoneticNameSplitter; private final GlobalSearchSupport mGlobalSearchSupport; - /** Precompiled sql statement for incrementing times contacted for a contact */ - private final SQLiteStatement mLastTimeContactedUpdate; private final SQLiteStatement mDataMimetypeQuery; private final SQLiteStatement mDataRawContactIdQuery; @@ -512,10 +523,6 @@ public class LegacyApiSupport { .getDefault()); SQLiteDatabase db = mDbHelper.getReadableDatabase(); - mLastTimeContactedUpdate = db.compileStatement("UPDATE " + Tables.RAW_CONTACTS + " SET " - + RawContacts.LAST_TIME_CONTACTED + "=? WHERE " - + RawContacts._ID + "=?"); - mDataMimetypeQuery = db.compileStatement( "SELECT " + DataColumns.MIMETYPE_ID + " FROM " + Tables.DATA + @@ -1144,14 +1151,20 @@ public class LegacyApiSupport { long rawContactId = Long.parseLong(uri.getPathSegments().get(1)); long contactId = mDbHelper.getContactId(rawContactId); + SQLiteDatabase mDb = mDbHelper.getWritableDatabase(); + mSelectionArgs2[0] = String.valueOf(lastTimeContacted); if (contactId != 0) { - mContactsProvider.updateContactLastContactedTime(contactId, lastTimeContacted); + mSelectionArgs2[1] = String.valueOf(contactId); + mDb.execSQL(CONTACTS_UPDATE_LASTTIMECONTACTED, mSelectionArgs2); + // increment times_contacted column + mSelectionArgs1[0] = String.valueOf(contactId); + mDb.execSQL(ContactsProvider2.UPDATE_TIMES_CONTACTED_CONTACTS_TABLE, mSelectionArgs1); } - - mLastTimeContactedUpdate.bindLong(1, lastTimeContacted); - mLastTimeContactedUpdate.bindLong(2, rawContactId); - mLastTimeContactedUpdate.execute(); - + mSelectionArgs2[1] = String.valueOf(rawContactId); + mDb.execSQL(RAWCONTACTS_UPDATE_LASTTIMECONTACTED, mSelectionArgs2); + // increment times_contacted column + mSelectionArgs1[0] = String.valueOf(contactId); + mDb.execSQL(ContactsProvider2.UPDATE_TIMES_CONTACTED_RAWCONTACTS_TABLE, mSelectionArgs1); return 1; } |