Add public intent filters to indexing

Adds a public intent action to the index so that intents
can be created for callers outside of settings.

Change-Id: I9f87263f213b6de40542e8735c931ee1f0d82094
Fixes: 63136008
Test: make RunSettingsRoboTests
This commit is contained in:
Matthew Fritze
2017-06-29 09:54:20 -07:00
parent 3a9734261d
commit 473b6b45de
4 changed files with 69 additions and 13 deletions

View File

@@ -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;
@@ -93,6 +94,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;
@@ -102,8 +109,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 {
@@ -118,14 +139,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,