Build slice from indexed data in SliceProvider

Connect the SliceIndexing data to the SliceProvider,
such that a query to SliceProvider can build a Slice
via the indexed data from SlicesIndexingManager.

We take the key from the Uri supplied to the SettingSliceProvider
and find a potential matching row in the indexed data. The
matched data is then used to Build a slice for the caller.

Bug: 67996923
Test: robotests
Change-Id: If51bfd1a05c3f3817ae720554f95a98fc7b002e1
This commit is contained in:
Matthew Fritze
2017-12-15 10:48:40 -08:00
parent 87f7a1be1e
commit 8c96843fe3
15 changed files with 858 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import com.android.settings.dashboard.DashboardFragment;
@@ -36,7 +37,7 @@ import java.util.List;
*/
class SlicesIndexer implements Runnable {
private static final String TAG = "SlicesIndexingManager";
private static final String TAG = "SlicesIndexer";
private Context mContext;
@@ -48,18 +49,27 @@ class SlicesIndexer implements Runnable {
}
/**
* Synchronously takes data obtained from {@link SliceDataConverter} and indexes it into a
* SQLite database.
* Asynchronously index slice data from {@link #indexSliceData()}.
*/
@Override
public void run() {
indexSliceData();
}
/**
* Synchronously takes data obtained from {@link SliceDataConverter} and indexes it into a
* SQLite database
*/
protected void indexSliceData() {
if (mHelper.isSliceDataIndexed()) {
Log.d(TAG, "Slices already indexed - returning.");
return;
}
SQLiteDatabase database = mHelper.getWritableDatabase();
try {
long startTime = System.currentTimeMillis();
database.beginTransaction();
mHelper.reconstruct(mHelper.getWritableDatabase());
@@ -67,6 +77,10 @@ class SlicesIndexer implements Runnable {
insertSliceData(database, indexData);
mHelper.setIndexedState();
// TODO (b/71503044) Log indexing time.
Log.d(TAG,
"Indexing slices database took: " + (System.currentTimeMillis() - startTime));
database.setTransactionSuccessful();
} finally {
database.endTransaction();