Don't throw security exception if file was already deleted via filePath

Apps sometimes delete the file via filePath and then try to delete the
db row using MediaProvider#delete. Since we would have already deleted
the db row during the filePath operation, the latter will result in a
security exception. Apps which don't expect an exception will break
here. Since we have already deleted the db row, we can silently return
zero as deleted count.

Changed MediaProvider#delete method to check for deleted row IDs and
return without deleting any content if the rowId pointed by given uri is
already deleted via filePath.

Bug: 157975902
Test: atest CtsScopedStorageHostTest#testDeleteAlreadyUnlinkedFile
Change-Id: I68a1d114537d0131161f954f14969693e4fef1d1
2 files changed