Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30b77bce authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Rewrite MediaStore thumbnail internals.

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: Ibcdbc564c8fee09ddd33ebccc470fa5cbdff97b4
parent 5d97dd31
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -34,10 +34,10 @@ import dalvik.system.CloseGuard;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;


/**
 * Represents a SQLite database connection.
 * Each connection wraps an instance of a native <code>sqlite3</code> object.
@@ -90,6 +90,8 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
    private static final String TAG = "SQLiteConnection";
    private static final boolean DEBUG = false;

    public static volatile boolean sLocalDebug = false;

    private static final String[] EMPTY_STRING_ARRAY = new String[0];
    private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];

@@ -991,6 +993,10 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
    }

    private void bindArguments(PreparedStatement statement, Object[] bindArgs) {
        if (sLocalDebug) {
            Log.v(TAG, statement.mSql + " with args " + Arrays.toString(bindArgs));
        }

        final int count = bindArgs != null ? bindArgs.length : 0;
        if (count != statement.mNumParameters) {
            throw new SQLiteBindOrColumnIndexOutOfRangeException(
+90 −231

File changed.

Preview size limit exceeded, changes collapsed.