Index Data to build Slices in Settings
The indexing is done by taking the indexable fragments from search, grabbing their XML via SearchIndexableResources, and then looking for controllers defined in preferences. For each controller found, we take the combination of the fragment providing the XML and the Preference info to create an indexable row. Buiding a Slice will be handled in a subsquent CL, but a prototype can be found here: ag/3324435 Test: robotests Bug: 67996923 Change-Id: I48668618079bcc3da55ab77b7323ee8e467073af
This commit is contained in:
@@ -19,12 +19,33 @@ package com.android.settings.testutils;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.search.IndexDatabaseHelper;
|
||||
import com.android.settings.slices.SlicesDatabaseHelper;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class DatabaseTestUtils {
|
||||
|
||||
public static void clearDb(Context context) {
|
||||
clearSearchDb(context);
|
||||
clearSlicesDb(context);
|
||||
}
|
||||
|
||||
private static void clearSlicesDb(Context context) {
|
||||
SlicesDatabaseHelper helper = SlicesDatabaseHelper.getInstance(context);
|
||||
helper.close();
|
||||
|
||||
Field instance;
|
||||
Class clazz = SlicesDatabaseHelper.class;
|
||||
try {
|
||||
instance = clazz.getDeclaredField("sSingleton");
|
||||
instance.setAccessible(true);
|
||||
instance.set(null, null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
private static void clearSearchDb(Context context) {
|
||||
IndexDatabaseHelper helper = IndexDatabaseHelper.getInstance(context);
|
||||
helper.close();
|
||||
|
||||
|
Reference in New Issue
Block a user