Merge "Add public intent filters to indexing" into oc-dr1-dev am: 50535da16d
am: 01ee9b3cc7
Change-Id: I2a5063324b21e2a77ba10d9e4be9dcbc4aadd2c9
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
@@ -858,7 +860,8 @@ public class DatabaseIndexingManager {
|
||||
List<String> nonIndexableKeys) {
|
||||
|
||||
final String className = sir.className;
|
||||
final int rank = sir.rank;
|
||||
final String intentAction = sir.intentAction;
|
||||
final String intentTargetPackage = sir.intentTargetPackage;
|
||||
|
||||
if (provider == null) {
|
||||
Log.w(LOG_TAG, "Cannot find provider: " + className);
|
||||
@@ -886,7 +889,6 @@ public class DatabaseIndexingManager {
|
||||
.setClassName(className)
|
||||
.setScreenTitle(raw.screenTitle)
|
||||
.setIconResId(raw.iconResId)
|
||||
.setRank(rank)
|
||||
.setIntentAction(raw.intentAction)
|
||||
.setIntentTargetPackage(raw.intentTargetPackage)
|
||||
.setIntentTargetClass(raw.intentTargetClass)
|
||||
@@ -911,7 +913,15 @@ public class DatabaseIndexingManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
item.className = (TextUtils.isEmpty(item.className)) ? className : item.className;
|
||||
item.className = TextUtils.isEmpty(item.className)
|
||||
? className
|
||||
: item.className;
|
||||
item.intentAction = TextUtils.isEmpty(item.intentAction)
|
||||
? intentAction
|
||||
: item.intentAction;
|
||||
item.intentTargetPackage = TextUtils.isEmpty(item.intentTargetPackage)
|
||||
? intentTargetPackage
|
||||
: item.intentTargetPackage;
|
||||
|
||||
indexFromResource(database, localeStr, item, nonIndexableKeys);
|
||||
}
|
||||
@@ -1245,7 +1255,11 @@ public class DatabaseIndexingManager {
|
||||
private Intent buildIntent(Context context) {
|
||||
final Intent intent;
|
||||
|
||||
if (TextUtils.isEmpty(mIntentAction)) {
|
||||
boolean isEmptyIntentAction = TextUtils.isEmpty(mIntentAction);
|
||||
// No intent action is set, or the intent action is for a subsetting.
|
||||
if (isEmptyIntentAction
|
||||
|| (!isEmptyIntentAction && TextUtils.equals(mIntentTargetPackage,
|
||||
SearchIndexableResources.SUBSETTING_TARGET_PACKAGE))) {
|
||||
// Action is null, we will launch it as a sub-setting
|
||||
intent = DatabaseIndexingUtils.buildSubsettingIntent(context, mClassName, mKey,
|
||||
mScreenTitle);
|
||||
|
@@ -21,6 +21,7 @@ import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.annotation.XmlRes;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.android.settings.DateTimeSettings;
|
||||
import com.android.settings.DeviceInfoSettings;
|
||||
import com.android.settings.DisplaySettings;
|
||||
@@ -92,6 +93,12 @@ import java.util.HashMap;
|
||||
|
||||
public final class SearchIndexableResources {
|
||||
|
||||
/**
|
||||
* Identifies subsettings which have an {@link SearchIndexableResource#intentAction} but
|
||||
* whose intents should still be treated as subsettings inside of Settings.
|
||||
*/
|
||||
public static final String SUBSETTING_TARGET_PACKAGE = "subsetting_target_package";
|
||||
|
||||
@XmlRes
|
||||
public static final int NO_DATA_RES_ID = 0;
|
||||
|
||||
@@ -101,8 +108,22 @@ public final class SearchIndexableResources {
|
||||
@VisibleForTesting
|
||||
static void addIndex(Class<?> indexClass, @XmlRes int xmlResId,
|
||||
@DrawableRes int iconResId) {
|
||||
addIndex(indexClass, xmlResId, iconResId, null /* targetAction */);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static void addIndex(Class<?> indexClass, @XmlRes int xmlResId,
|
||||
@DrawableRes int iconResId, String targetAction) {
|
||||
String className = indexClass.getName();
|
||||
sResMap.put(className, new SearchIndexableResource(0, xmlResId, className, iconResId));
|
||||
SearchIndexableResource resource =
|
||||
new SearchIndexableResource(0, xmlResId, className, iconResId);
|
||||
|
||||
if (!TextUtils.isEmpty(targetAction)) {
|
||||
resource.intentAction = targetAction;
|
||||
resource.intentTargetPackage = SUBSETTING_TARGET_PACKAGE;
|
||||
}
|
||||
|
||||
sResMap.put(className, resource);
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -117,14 +138,16 @@ public final class SearchIndexableResources {
|
||||
addIndex(DataUsageSummary.class, NO_DATA_RES_ID, R.drawable.ic_settings_data_usage);
|
||||
addIndex(DataUsageMeteredSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_data_usage);
|
||||
addIndex(ScreenZoomSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
|
||||
addIndex(DisplaySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
|
||||
addIndex(DisplaySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display,
|
||||
"android.settings.DISPLAY_SETTINGS");
|
||||
addIndex(AmbientDisplaySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
|
||||
addIndex(WallpaperTypeSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
|
||||
addIndex(ConfigureNotificationSettings.class,
|
||||
R.xml.configure_notification_settings, R.drawable.ic_settings_notifications);
|
||||
addIndex(AppAndNotificationDashboardFragment.class, NO_DATA_RES_ID,
|
||||
R.drawable.ic_settings_applications);
|
||||
addIndex(SoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound);
|
||||
addIndex(SoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound,
|
||||
"android.settings.SOUND_SETTINGS");
|
||||
addIndex(ZenModeSettings.class,
|
||||
R.xml.zen_mode_settings, R.drawable.ic_settings_notifications);
|
||||
addIndex(ZenModePrioritySettings.class,
|
||||
|
@@ -58,8 +58,8 @@ public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
|
||||
ref[COLUMN_INDEX_XML_RES_RESID] = val.xmlResId;
|
||||
ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = val.className;
|
||||
ref[COLUMN_INDEX_XML_RES_ICON_RESID] = val.iconResId;
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = null; // intent action
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = null; // intent target package
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = val.intentAction;
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = val.intentTargetPackage;
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = null; // intent target class
|
||||
cursor.addRow(ref);
|
||||
}
|
||||
|
@@ -587,7 +587,7 @@ public class DatabaseIndexingManagerTest {
|
||||
// Locale
|
||||
assertThat(cursor.getString(0)).isEqualTo(localeStr);
|
||||
// Data Rank
|
||||
assertThat(cursor.getInt(1)).isEqualTo(rank);
|
||||
assertThat(cursor.getInt(1)).isEqualTo(0);
|
||||
// Data Title
|
||||
assertThat(cursor.getString(2)).isEqualTo("Display size");
|
||||
// Normalized Title
|
||||
@@ -644,7 +644,7 @@ public class DatabaseIndexingManagerTest {
|
||||
|
||||
@Test
|
||||
public void testResourceProvider_resourceRowMatches() {
|
||||
SearchIndexableResource resource = getFakeResource(0);
|
||||
SearchIndexableResource resource = getFakeResource(0 /* xml */);
|
||||
resource.className = "com.android.settings.display.ScreenZoomSettings";
|
||||
|
||||
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, new HashMap<>());
|
||||
@@ -654,7 +654,7 @@ public class DatabaseIndexingManagerTest {
|
||||
// Locale
|
||||
assertThat(cursor.getString(0)).isEqualTo(localeStr);
|
||||
// Data Rank
|
||||
assertThat(cursor.getInt(1)).isEqualTo(rank);
|
||||
assertThat(cursor.getInt(1)).isEqualTo(0);
|
||||
// Data Title
|
||||
assertThat(cursor.getString(2)).isEqualTo("Display size");
|
||||
// Normalized Title
|
||||
@@ -702,7 +702,7 @@ public class DatabaseIndexingManagerTest {
|
||||
|
||||
@Test
|
||||
public void testResourceProvider_disabledResource_rowsInserted() {
|
||||
SearchIndexableResource resource = getFakeResource(0);
|
||||
SearchIndexableResource resource = getFakeResource(0 /* xml */);
|
||||
resource.className = "com.android.settings.LegalSettings";
|
||||
|
||||
mManager.indexOneSearchIndexableData(mDb, localeStr, resource,
|
||||
@@ -724,6 +724,25 @@ public class DatabaseIndexingManagerTest {
|
||||
assertThat(cursor.getCount()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResourceProvider_nonSubsettingIntent() {
|
||||
SearchIndexableResource resource = getFakeResource(0 /* xml */);
|
||||
String fakeAction = "fake_action";
|
||||
resource.className = "com.android.settings.LegalSettings";
|
||||
resource.intentAction = fakeAction;
|
||||
resource.intentTargetPackage = SearchIndexableResources.SUBSETTING_TARGET_PACKAGE;
|
||||
|
||||
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, new HashMap<>());
|
||||
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
|
||||
cursor.moveToPosition(0);
|
||||
|
||||
// Intent Action
|
||||
assertThat(cursor.getString(13)).isEqualTo(fakeAction);
|
||||
// Target Package
|
||||
assertThat(cursor.getString(14))
|
||||
.isEqualTo(SearchIndexableResources.SUBSETTING_TARGET_PACKAGE);
|
||||
}
|
||||
|
||||
// Test new public indexing flow
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user