Skip to content

Commit

Permalink
Rewrite MediaStore thumbnail internals.
Browse files Browse the repository at this point in the history
Keeps existing public APIs intact, but rewrite the internal to pave
the way for storage changes coming in Q.  All thumbnail generation
and reading now happens in MediaProvider, since apps won't have
direct access to MiniThumbFile files in Q.

Instead, InternalThumbnails now uses openTypedAssetFileDescriptor()
to open the original Uri, but with an EXTRA_SIZE indicating that
it'd like a thumbnail of a specific size.  This uses best-practices
which allow apps obtaining a Uri permission grant to a specific
media Uri to request a thumbnail of that media without additional
permissions.  This also lets us use CancellationSignal to cancel
thumbnail requests that are no longer needed, and we start checking
this signal at each query() point internally.

Move internals to use ExecutorService pattern, which will let us
expand the thread pool in a future CL based on device capabilities.

Previous logic that asynchronously generated thumbnails after certain
actions is now replaced with simpler invalidation.  This paves the
way for us to move proactive thumbnail generation to be driven by an
idle maintenance service, to be better stewards of battery life.  We
continue to generate thumbnails on-demand when not yet cached.

ThumbnailUtils already handles extracting EXIF thumbnails, so we don't
need to duplicate that work locally.

Flag that enables dumping of all raw SQL for debugging purposes on
a per-process basis.

Bug: 111268862, 111890672
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: Ie17f904003d1c9d870dcdb7556b83f7cc1cedee2
  • Loading branch information
jsharkey committed Jul 30, 2018
1 parent e1b8d2d commit 2942111
Show file tree
Hide file tree
Showing 4 changed files with 382 additions and 548 deletions.
Loading

0 comments on commit 2942111

Please sign in to comment.