Fix "UNIQUE constraint failed: mimetypes.mimetype"
With the old code there was a chance of two threads trying to write the same
mimetype simultaneously, ending up getting "UNIQUE constraint failed".
One possible way to fix it is just to add locks, but doing so *might* cause
deadlocks due to implicit locks in SQLiteDatabase. So in this CL, we just retry
when we detect a conflict.
Unfortunately we can't use a transaction here because this method is called
from onCommitTransaction() too.
Also refactored the code to unify getPackageId() and getMimeTypeId().
Bug 16574964
Change-Id: I66274dfd080ae808795a4d59d30978b1ca1c06c0
3 files changed