History log of /packages/providers/ContactsProvider/tests/src/com/android/providers/contacts/ContactsProvider2TransactionTest.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ae32283e7fc5b749df96523d8bb343b9068b65ba 09-May-2012 Makoto Onuki <omakoto@google.com> Fix transaction handling in the provider

Fixed issues that will happen when a batch operation for applyBatch()
contain operations for both the contacts db and the profile db.

- Make sure to set the right transaction listener when starting a transaction.
There were cases where we started a transaction on the contacts db but passsing
the profile provider as the listener, and vice versa.

- Make sure transaction callbacks operate on the correct DB.
There were cases where ContactsProvider2.onCommit() and its sbilings would
operate on the profile DB, not on the contacts db.

- Change the transaction finishing order.
When we start transactions on both the contacts and the profile DB, we do so
on the contacts db first, and then on the profile db. But when we clsoe them,
we did it in the same order, which could potentially cause a deadlock.
Now we close them in the reverse order; the profile db first, then the
contacts db.

- Remove mActiveDb.
This wasn't set in switchTo{Profile,Contact}Mode(), but was lazily initialized.
But I wasn't too sure if I always set the right db at the right timing.
Looks like I forgot to do so in a few cases. Let's just remove it and always
explicitly get the database from the current db helper.

Bug 6250673

Change-Id: Idd18fc173596c973d0ff8b6e1b2456715c0f14f8
/packages/providers/ContactsProvider/tests/src/com/android/providers/contacts/ContactsProvider2TransactionTest.java