Invalidate all thumbnails when UUID mismatched.

When storing thumbnails on a storage device, we use BaseColumns._ID
as the filename.  However, when a user manually clears data on the
MediaProvider package, or when the SQLite database becomes corrupted,
it will scan files with drastically different _ID values, which means
we can no longer use cached thumbnails.

We already store a UUID in the SQLite database to help both internal
and external developers detect these conditions, so this change
extends that strategy to write the UUID into a new ".database_uuid"
file in the ".thumbnails" directory on disk.  Then, when we mount a
storage volume in the future, if the UUID value disagree, we
treat all thumbnails on that device as stale as delete them.

Bring back IdleServiceTest, and extend it to validate that stale
thumbnails are wiped when the UUID changes.

Bug: 148429200
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: Ia89f925e151a2f7c9d27ba8ce025c43875f603ed
5 files changed