bug 2384418: fix bug in mms contact lookup.

- a portion of the mms contact lookup wasn't protected by the synchronization block, and that portion used a member variable 'mSelectionArgs[]', which contains the number to be looked up. If this code is accessed by different threads at the same time, mSelectionArgs[] could be overridden by a wrong number, causing the resulting contact info be bad. With the bad contact cache, future lookups by phone number would result in the wrong contact.

While I didn't reproduce this with release builds, I was able to write a test that looks up a bunch of numbers in thread 1, and another bunch in thread 2. I observed thread #2 overwritting mSelectionArgs[] for thread 1, causing contact lookup to create bad contact cache. I believe in practice this can happen as the MMS code does look up and create contact cache entries from different threads.

This problem should be in builds before ERE19. In ERE19, Dmitri added an optimization in the ContactInfoCache's contact lookup, which should result in contact lookup to fail (zero cursor) when mSelectionArgs[] is overwritten by a bad phone number. It'd be nice to confirm that, but bug 2384418 doesn't contain a bug report, and we don't know for sure which build it was found in.

In any case, this fix is straight forward and should fix the contact lookup.

Change-Id: I516ff7039bec47c1b7bdc7dd5e52347c004a5a13
1 file changed