Delete rows for ejected filesystem in a transaction

Wrap the update/delete commands in an sql transaction so
they both either succeeds or fails. The problem adressed
here is that the MediaProvider may be interrupted while
handling the ACTION_MEDIA_EJECT intent and only the
update may have happened. This leads to numerous weird
problems later when _data contains unexpected null posts
causing crashes with stacks like:

  java.lang.NullPointerException: Attempt to invo\
  ke virtual method 'char[] java.lang.String.toCh\
  arArray()' on a null object reference
	at java.io.File.fixSlashes(File.java:185)
 	at java.io.File.<init>(File.java:134)
 	at com.android.providers.media.MediaProvider.\
    getCompressedAlbumArt(MediaProvider.java:4836)
 	at com.android.providers.media.MediaProvider.\
    makeThumbInternal(MediaProvider.java:5005)
 	at com.android.providers.media.MediaProvider.\
    getThumb(MediaProvider.java:5001)
 	at com.android.providers.media.MediaProvider.\
    openFile(MediaProvider.java:4591)
 	at android.content.ContentProvider.openAssetF\
    ile(ContentProvider.java:1322)

The problem can be reproduced on a device with external
SDCard by inserting a Thread.sleep(10000) between update
and delete and then just power of the device normally.

Change-Id: I2c104958dbe4e300aa80abedc4d44e0d77495180
1 file changed