import android.widget.Button;
import android.widget.Toolbar;
+import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceManager;
+
import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.applications.manageapplications.ManageApplications;
import java.util.ArrayList;
import java.util.List;
-import androidx.annotation.Nullable;
-import androidx.annotation.VisibleForTesting;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceFragmentCompat;
-import androidx.preference.PreferenceManager;
-
public class SettingsActivity extends SettingsBaseActivity
implements PreferenceManager.OnPreferenceTreeClickListener,
if (mAccountType == null) {
return false;
}
- final Bundle metadata = tile.metaData;
+ final Bundle metadata = tile.getMetaData();
if (metadata == null) {
return false;
}
boolean useNewKey = false;
boolean useOldKey = false;
for (Tile tile : tiles) {
- if (CategoryKey.KEY_COMPAT_MAP.containsKey(tile.category)) {
+ if (CategoryKey.KEY_COMPAT_MAP.containsKey(tile.getCategory())) {
useOldKey = true;
} else {
useNewKey = true;
// Uses only old key, map them to new keys one by one.
if (useOldKey && !useNewKey) {
for (Tile tile : tiles) {
- final String newCategoryKey = CategoryKey.KEY_COMPAT_MAP.get(tile.category);
- tile.category = newCategoryKey;
+ final String newCategoryKey =
+ CategoryKey.KEY_COMPAT_MAP.get(tile.getCategory());
+ tile.setCategory(newCategoryKey);
// move tile to new category.
DashboardCategory newCategory = categoryByKeyMap.get(newCategoryKey);
if (newCategory == null) {
- newCategory = new DashboardCategory();
+ newCategory = new DashboardCategory(newCategoryKey);
categoryByKeyMap.put(newCategoryKey, newCategory);
}
newCategory.addTile(tile);
&& !(icon instanceof RoundedHomepageIcon)) {
icon = new RoundedHomepageIcon(mContext, icon);
try {
- if (tile.metaData != null) {
- final int colorRes = tile.metaData.getInt(
+ final Bundle metaData = tile.getMetaData();
+ if (metaData != null) {
+ final int colorRes = metaData.getInt(
TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_HINT, 0 /* default */);
if (colorRes != 0) {
final int bgColor = mContext.getPackageManager()
}
bindSummary(pref, tile);
bindIcon(pref, tile);
- final Bundle metadata = tile.metaData;
+ final Bundle metadata = tile.getMetaData();
String clsName = null;
String action = null;
Integer order = null;
private void bindSummary(Preference preference, Tile tile) {
if (tile.summary != null) {
preference.setSummary(tile.summary);
- } else if (tile.metaData != null
- && tile.metaData.containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
+ } else if (tile.getMetaData() != null
+ && tile.getMetaData().containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
// Set a placeholder summary before starting to fetch real summary, this is necessary
// to avoid preference height change.
preference.setSummary(R.string.summary_placeholder);
ThreadUtils.postOnBackgroundThread(() -> {
final Map<String, IContentProvider> providerMap = new ArrayMap<>();
- final String uri = tile.metaData.getString(META_DATA_PREFERENCE_SUMMARY_URI);
+ final String uri = tile.getMetaData().getString(META_DATA_PREFERENCE_SUMMARY_URI);
final String summary = TileUtils.getTextFromUri(
mContext, uri, providerMap, META_DATA_PREFERENCE_SUMMARY);
ThreadUtils.postOnMainThread(() -> preference.setSummary(summary));
final Icon tileIcon = tile.getIcon(mContext);
if (tileIcon != null) {
preference.setIcon(tileIcon.loadDrawable(preference.getContext()));
- } else if (tile.metaData != null
- && tile.metaData.containsKey(META_DATA_PREFERENCE_ICON_URI)) {
+ } else if (tile.getMetaData() != null
+ && tile.getMetaData().containsKey(META_DATA_PREFERENCE_ICON_URI)) {
ThreadUtils.postOnBackgroundThread(() -> {
String packageName = null;
if (tile.intent != null) {
}
}
final Map<String, IContentProvider> providerMap = new ArrayMap<>();
- final String uri = tile.metaData.getString(META_DATA_PREFERENCE_ICON_URI);
+ final String uri = tile.getMetaData().getString(META_DATA_PREFERENCE_ICON_URI);
final Pair<String, Integer> iconInfo = TileUtils.getIconFromUri(
mContext, packageName, uri, providerMap);
if (iconInfo == null) {
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.ArrayMap;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.drawer.TileUtils;
import java.util.ArrayList;
import java.util.Collection;
return true;
}
- @VisibleForTesting
- boolean tintTileIcon(Tile tile) {
- final Context context = getContext();
- if (tile.getIcon(context) == null) {
- return false;
- }
- // First check if the tile has set the icon tintable metadata.
- final Bundle metadata = tile.metaData;
- if (metadata != null
- && metadata.containsKey(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE)) {
- return metadata.getBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE);
- }
- final String pkgName = context.getPackageName();
- // If this drawable is coming from outside Settings, tint it to match the color.
- return pkgName != null && tile.intent != null
- && !pkgName.equals(tile.intent.getComponent().getPackageName());
- }
-
/**
* Displays resource based tiles.
*/
if (!displayTile(tile)) {
continue;
}
- if (tintTileIcon(tile)) {
- tile.getIcon(context).setTint(tintColor);
+ if (tile.isIconTintable(context)) {
+ final Icon icon = tile.getIcon(context);
+ if (icon != null) {
+ icon.setTint(tintColor);
+ }
}
if (mDashboardTilePrefKeys.contains(key)) {
// Have the key already, will rebind.
import android.util.ArraySet;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
+
import com.android.settings.SettingsActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.drawer.DashboardCategory;
import java.lang.reflect.Field;
import java.util.List;
-import androidx.annotation.VisibleForTesting;
-
public class SummaryLoader {
private static final boolean DEBUG = DashboardSummary.DEBUG;
private static final String TAG = "SummaryLoader";
// TODO: Load summary indirectly.
return null;
}
- Bundle metaData = getMetaData(tile);
+ final Bundle metaData = tile.getMetaData();
if (metaData == null) {
if (DEBUG) Log.d(TAG, "No metadata specified for " + tile.intent.getComponent());
return null;
return null;
}
- private Bundle getMetaData(Tile tile) {
- return tile.metaData;
- }
-
/**
* Registers a receiver and automatically unregisters it when the activity is stopping.
* This ensures that the receivers are unregistered immediately, since most summary loader
// Build parent-child class pairs for all children listed under this key.
for (Tile tile : category.getTiles()) {
String childClass = null;
- if (tile.metaData != null) {
- childClass = tile.metaData.getString(
+ if (tile.getMetaData() != null) {
+ childClass = tile.getMetaData().getString(
SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS);
}
if (childClass == null) {
private AccountDetailDashboardFragment mFragment;
private Context mContext;
+ private ActivityInfo mActivityInfo;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
+ mActivityInfo = new ActivityInfo();
+ mActivityInfo.metaData = new Bundle();
final Bundle args = new Bundle();
args.putParcelable(METADATA_USER_HANDLE, UserHandle.CURRENT);
@Test
public void refreshDashboardTiles_HasAccountType_shouldDisplay() {
- final Tile tile = new Tile(new ActivityInfo());
- final Bundle metaData = new Bundle();
- metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
- metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
- tile.metaData = metaData;
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
+ mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
+ mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
assertThat(mFragment.displayTile(tile)).isTrue();
}
@Test
public void refreshDashboardTiles_NoAccountType_shouldNotDisplay() {
- final Tile tile = new Tile(new ActivityInfo());
- final Bundle metaData = new Bundle();
- metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
- tile.metaData = metaData;
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
+ mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
assertThat(mFragment.displayTile(tile)).isFalse();
}
@Test
public void refreshDashboardTiles_OtherAccountType_shouldNotDisplay() {
- final Tile tile = new Tile(new ActivityInfo());
- final Bundle metaData = new Bundle();
- metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
- metaData.putString(METADATA_ACCOUNT_TYPE, "com.other");
- tile.metaData = metaData;
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
+ mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
+ mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.other");
assertThat(mFragment.displayTile(tile)).isFalse();
}
when(packageManager.resolveActivity(any(Intent.class), anyInt()))
.thenReturn(mock(ResolveInfo.class));
- final Tile tile = new Tile(new ActivityInfo());
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
tile.key = "key";
- tile.metaData = new Bundle();
- tile.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
- tile.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
- tile.metaData.putString("com.android.settings.intent.action", Intent.ACTION_ASSIST);
+ mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
+ mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
+ mActivityInfo.metaData.putString("com.android.settings.intent.action",
+ Intent.ACTION_ASSIST);
tile.intent = new Intent();
tile.userHandle = null;
mFragment.displayTile(tile);
package com.android.settings.dashboard;
+import static com.android.settingslib.drawer.CategoryKey.CATEGORY_HOMEPAGE;
+
import static com.google.common.truth.Truth.assertThat;
import android.content.ComponentName;
@Test
public void backwardCompatCleanupForCategory_shouldNotChangeCategoryForNewKeys() {
- final Tile tile1 = new Tile(mActivityInfo);
- final Tile tile2 = new Tile(mActivityInfo);
- tile1.category = CategoryKey.CATEGORY_ACCOUNT;
- tile2.category = CategoryKey.CATEGORY_ACCOUNT;
- final DashboardCategory category = new DashboardCategory();
+ final Tile tile1 = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT);
+ final Tile tile2 = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT);
+ final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_ACCOUNT);
category.addTile(tile1);
category.addTile(tile2);
mCategoryByKeyMap.put(CategoryKey.CATEGORY_ACCOUNT, category);
@Test
public void backwardCompatCleanupForCategory_shouldNotChangeCategoryForMixedKeys() {
- final Tile tile1 = new Tile(mActivityInfo);
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile1 = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT);
final String oldCategory = "com.android.settings.category.wireless";
- tile1.category = CategoryKey.CATEGORY_ACCOUNT;
- tile2.category = oldCategory;
- final DashboardCategory category1 = new DashboardCategory();
+ final Tile tile2 = new Tile(mActivityInfo, oldCategory);
+ final DashboardCategory category1 = new DashboardCategory(CategoryKey.CATEGORY_ACCOUNT);
category1.addTile(tile1);
- final DashboardCategory category2 = new DashboardCategory();
+ final DashboardCategory category2 = new DashboardCategory(oldCategory);
category2.addTile(tile2);
mCategoryByKeyMap.put(CategoryKey.CATEGORY_ACCOUNT, category1);
mCategoryByKeyMap.put(oldCategory, category2);
@Test
public void backwardCompatCleanupForCategory_shouldChangeCategoryForOldKeys() {
- final Tile tile1 = new Tile(mActivityInfo);
final String oldCategory = "com.android.settings.category.wireless";
- tile1.category = oldCategory;
- final DashboardCategory category1 = new DashboardCategory();
+ final Tile tile1 = new Tile(mActivityInfo, oldCategory);
+ tile1.setCategory(oldCategory);
+ final DashboardCategory category1 = new DashboardCategory(oldCategory);
category1.addTile(tile1);
mCategoryByKeyMap.put(oldCategory, category1);
mTileByComponentCache.put(new Pair<>("PACKAGE", "CLASS1"), tile1);
public void sortCategories_singlePackage_shouldReorderBasedOnPriority() {
// Create some fake tiles that are not sorted.
final String testPackage = "com.android.test";
- final DashboardCategory category = new DashboardCategory();
- final Tile tile1 = new Tile(mActivityInfo);
+ final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
+ final Tile tile1 = new Tile(mActivityInfo, category.key);
tile1.intent =
new Intent().setComponent(new ComponentName(testPackage, "class1"));
tile1.priority = 100;
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile2 = new Tile(mActivityInfo, category.key);
tile2.intent =
new Intent().setComponent(new ComponentName(testPackage, "class2"));
tile2.priority = 50;
- final Tile tile3 = new Tile(mActivityInfo);
+ final Tile tile3 = new Tile(mActivityInfo, category.key);
tile3.intent =
new Intent().setComponent(new ComponentName(testPackage, "class3"));
tile3.priority = 200;
category.addTile(tile1);
category.addTile(tile2);
category.addTile(tile3);
- mCategoryByKeyMap.put(CategoryKey.CATEGORY_HOMEPAGE, category);
+ mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
// Sort their priorities
mCategoryManager.sortCategories(ShadowApplication.getInstance().getApplicationContext(),
// Create some fake tiles that are not sorted.
final String testPackage1 = "com.android.test1";
final String testPackage2 = "com.android.test2";
- final DashboardCategory category = new DashboardCategory();
- final Tile tile1 = new Tile(mActivityInfo);
+ final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
+ final Tile tile1 = new Tile(mActivityInfo, category.key);
tile1.intent =
new Intent().setComponent(new ComponentName(testPackage2, "class1"));
tile1.priority = 100;
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile2 = new Tile(mActivityInfo, category.key);
tile2.intent =
new Intent().setComponent(new ComponentName(testPackage1, "class2"));
tile2.priority = 100;
- final Tile tile3 = new Tile(mActivityInfo);
+ final Tile tile3 = new Tile(mActivityInfo, category.key);
tile3.intent =
new Intent().setComponent(new ComponentName(testPackage1, "class3"));
tile3.priority = 50;
category.addTile(tile1);
category.addTile(tile2);
category.addTile(tile3);
- mCategoryByKeyMap.put(CategoryKey.CATEGORY_HOMEPAGE, category);
+ mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
// Sort their priorities
mCategoryManager.sortCategories(mContext, mCategoryByKeyMap);
public void sortCategories_internalPackageTiles_shouldSkipTileForInternalPackage() {
// Create some fake tiles that are not sorted.
final String testPackage = mContext.getPackageName();
- final DashboardCategory category = new DashboardCategory();
- final Tile tile1 = new Tile(mActivityInfo);
+ final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
+ final Tile tile1 = new Tile(mActivityInfo, category.key);
tile1.intent =
new Intent().setComponent(new ComponentName(testPackage, "class1"));
tile1.priority = 100;
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile2 = new Tile(mActivityInfo, category.key);
tile2.intent =
new Intent().setComponent(new ComponentName(testPackage, "class2"));
tile2.priority = 100;
- final Tile tile3 = new Tile(mActivityInfo);
+ final Tile tile3 = new Tile(mActivityInfo, category.key);
tile3.intent =
new Intent().setComponent(new ComponentName(testPackage, "class3"));
tile3.priority = 50;
category.addTile(tile1);
category.addTile(tile2);
category.addTile(tile3);
- mCategoryByKeyMap.put(CategoryKey.CATEGORY_HOMEPAGE, category);
+ mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
// Sort their priorities
mCategoryManager.sortCategories(mContext, mCategoryByKeyMap);
// Inject one external tile among internal tiles.
final String testPackage = mContext.getPackageName();
final String testPackage2 = "com.google.test2";
- final DashboardCategory category = new DashboardCategory();
- final Tile tile1 = new Tile(mActivityInfo);
+ final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
+ final Tile tile1 = new Tile(mActivityInfo, category.key);
tile1.intent = new Intent().setComponent(new ComponentName(testPackage, "class1"));
tile1.priority = 2;
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile2 = new Tile(mActivityInfo, category.key);
tile2.intent = new Intent().setComponent(new ComponentName(testPackage, "class2"));
tile2.priority = 1;
- final Tile tile3 = new Tile(mActivityInfo);
+ final Tile tile3 = new Tile(mActivityInfo, category.key);
tile3.intent = new Intent().setComponent(new ComponentName(testPackage2, "class0"));
tile3.priority = 0;
- final Tile tile4 = new Tile(mActivityInfo);
+ final Tile tile4 = new Tile(mActivityInfo, category.key);
tile4.intent = new Intent().setComponent(new ComponentName(testPackage, "class3"));
tile4.priority = -1;
category.addTile(tile1);
category.addTile(tile2);
category.addTile(tile3);
category.addTile(tile4);
- mCategoryByKeyMap.put(CategoryKey.CATEGORY_HOMEPAGE, category);
+ mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
// Sort their priorities
mCategoryManager.sortCategories(mContext, mCategoryByKeyMap);
final String testPackage = mContext.getPackageName();
final String testPackage2 = "com.google.test2";
final String testPackage3 = "com.abcde.test3";
- final DashboardCategory category = new DashboardCategory();
- final Tile tile1 = new Tile(mActivityInfo);
+ final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
+ final Tile tile1 = new Tile(mActivityInfo, category.key);
tile1.intent = new Intent().setComponent(new ComponentName(testPackage2, "class1"));
tile1.priority = 1;
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile2 = new Tile(mActivityInfo, category.key);
tile2.intent = new Intent().setComponent(new ComponentName(testPackage, "class2"));
tile2.priority = 1;
- final Tile tile3 = new Tile(mActivityInfo);
+ final Tile tile3 = new Tile(mActivityInfo, category.key);
tile3.intent = new Intent().setComponent(new ComponentName(testPackage3, "class3"));
tile3.priority = 1;
category.addTile(tile1);
category.addTile(tile2);
category.addTile(tile3);
- mCategoryByKeyMap.put(CategoryKey.CATEGORY_HOMEPAGE, category);
+ mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
// Sort their priorities
mCategoryManager.sortCategories(mContext, mCategoryByKeyMap);
public void filterTiles_noDuplicate_noChange() {
// Create some unique tiles
final String testPackage = mContext.getPackageName();
- final DashboardCategory category = new DashboardCategory();
- final Tile tile1 = new Tile(mActivityInfo);
+ final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
+ final Tile tile1 = new Tile(mActivityInfo, category.key);
tile1.intent =
new Intent().setComponent(new ComponentName(testPackage, "class1"));
tile1.priority = 100;
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile2 = new Tile(mActivityInfo, category.key);
tile2.intent =
new Intent().setComponent(new ComponentName(testPackage, "class2"));
tile2.priority = 100;
- final Tile tile3 = new Tile(mActivityInfo);
+ final Tile tile3 = new Tile(mActivityInfo, category.key);
tile3.intent =
new Intent().setComponent(new ComponentName(testPackage, "class3"));
tile3.priority = 50;
category.addTile(tile1);
category.addTile(tile2);
category.addTile(tile3);
- mCategoryByKeyMap.put(CategoryKey.CATEGORY_HOMEPAGE, category);
+ mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
mCategoryManager.filterDuplicateTiles(mCategoryByKeyMap);
public void filterTiles_hasDuplicate_shouldOnlyKeepUniqueTiles() {
// Create tiles pointing to same intent.
final String testPackage = mContext.getPackageName();
- final DashboardCategory category = new DashboardCategory();
- final Tile tile1 = new Tile(mActivityInfo);
+ final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
+ final Tile tile1 = new Tile(mActivityInfo, category.key);
tile1.intent =
new Intent().setComponent(new ComponentName(testPackage, "class1"));
tile1.priority = 100;
- final Tile tile2 = new Tile(mActivityInfo);
+ final Tile tile2 = new Tile(mActivityInfo, category.key);
tile2.intent =
new Intent().setComponent(new ComponentName(testPackage, "class1"));
tile2.priority = 100;
- final Tile tile3 = new Tile(mActivityInfo);
+ final Tile tile3 = new Tile(mActivityInfo, category.key);
tile3.intent =
new Intent().setComponent(new ComponentName(testPackage, "class1"));
tile3.priority = 50;
category.addTile(tile1);
category.addTile(tile2);
category.addTile(tile3);
- mCategoryByKeyMap.put(CategoryKey.CATEGORY_HOMEPAGE, category);
+ mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
mCategoryManager.filterDuplicateTiles(mCategoryByKeyMap);
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.drawer.TileUtils;
import com.android.settingslib.utils.IconCache;
MockitoAnnotations.initMocks(this);
mFactory = FakeFeatureFactory.setupForTest();
mActivityInfo = new ActivityInfo();
+ mActivityInfo.metaData = new Bundle();
when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
when(mContext.getSystemService(Context.WINDOW_SERVICE)).thenReturn(mWindowManager);
final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
final DashboardAdapter.DashboardItemHolder holder =
new DashboardAdapter.DashboardItemHolder(view);
- final Tile tile = spy(new Tile(mActivityInfo));
+ final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
doReturn(Icon.createWithResource(context, R.drawable.ic_settings))
.when(tile).getIcon(context);
final IconCache iconCache = mock(IconCache.class);
final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
final DashboardAdapter.DashboardItemHolder holder =
new DashboardAdapter.DashboardItemHolder(view);
- final Tile tile = spy(new Tile(mActivityInfo));
+ final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
final Icon icon = Icon.createWithResource(context, R.drawable.ic_settings);
doReturn(icon).when(tile).getIcon(context);
final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
final DashboardAdapter.DashboardItemHolder holder =
new DashboardAdapter.DashboardItemHolder(view);
- final Tile tile = spy(new Tile(mActivityInfo));
- tile.metaData = new Bundle();
- tile.metaData.putInt(TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
+ final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
+ tile.getMetaData().putInt(TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
R.color.memory_critical);
doReturn(Icon.createWithResource(context, R.drawable.ic_settings))
.when(tile).getIcon(context);
final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
final DashboardAdapter.DashboardItemHolder holder =
new DashboardAdapter.DashboardItemHolder(view);
- final Tile tile = spy(new Tile(mActivityInfo));
+ final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
doReturn(mock(Icon.class)).when(tile).getIcon(context);
when(tile.getIcon(context).getResPackage()).thenReturn("another.package");
import com.android.settings.dashboard.conditional.AirplaneModeCondition;
import com.android.settings.dashboard.conditional.Condition;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
public void SetUp() {
MockitoAnnotations.initMocks(this);
- mDashboardCategory = new DashboardCategory();
+ mDashboardCategory = new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE);
// Build suggestions
final List<Suggestion> suggestions = new ArrayList<>();
/**
* Test when using the
* {@link com.android.settings.dashboard.DashboardData.ItemsDataDiffCallback}
- * to transfer List from {@paramref baseDashboardData} to {@paramref diffDashboardData}, whether
+ * to transfer List from {@paramref baseDashboardData} to {@paramref diffDashboardData},
+ * whether
* the transform data result is equals to {@paramref testResultData}
* <p>
* The steps are described below:
* 1. Calculate a {@link androidx.recyclerview.widget.DiffUtil.DiffResult} from
* {@paramref baseDashboardData} to {@paramref diffDashboardData}
* <p>
- * 2. Dispatch the {@link androidx.recyclerview.widget.DiffUtil.DiffResult} calculated from step 1
+ * 2. Dispatch the {@link androidx.recyclerview.widget.DiffUtil.DiffResult} calculated from step
+ * 1
* into {@link ListUpdateResult}
* <p>
* 3. Get result data(a.k.a. baseResultData) from {@link ListUpdateResult} and compare it to
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mActivityInfo = new ActivityInfo();
+ mActivityInfo.metaData = new Bundle();
doReturn(mPackageManager).when(mContext).getPackageManager();
when(mPackageManager.resolveActivity(any(Intent.class), anyInt()))
.thenReturn(new ResolveInfo());
@Test
public void bindPreference_shouldBindAllData() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = spy(new Tile(mActivityInfo));
+ final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
tile.title = "title";
tile.summary = "summary";
doReturn(Icon.createWithBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565)))
.when(tile).getIcon(any(Context.class));
- tile.metaData = new Bundle();
- tile.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI");
+ mActivityInfo.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI");
tile.priority = 10;
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getTitle()).isEqualTo(tile.title);
assertThat(preference.getSummary()).isEqualTo(tile.summary);
assertThat(preference.getIcon()).isNotNull();
- assertThat(preference.getFragment())
- .isEqualTo(tile.metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS));
+ assertThat(preference.getFragment()).isEqualTo(
+ mActivityInfo.metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS));
assertThat(preference.getOrder()).isEqualTo(-tile.priority);
}
@Test
public void bindPreference_noFragmentMetadata_shouldBindIntent() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.priority = 10;
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
@Test
public void bindPreference_noFragmentMetadata_shouldBindToProfileSelector() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
tile.userHandle.add(mock(UserHandle.class));
@Test
public void bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
tile.intent = new Intent();
@Test
public void bindPreference_toInternalSettingActivity_shouldBindToDirectLaunchIntentAndNotLog() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
tile.intent = new Intent();
@Test
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
@Test
public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
@Test
public void bindPreference_hasSummary_shouldSetSummary() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.summary = "test";
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
@Config(shadows = {ShadowTileUtils.class, ShadowThreadUtils.class})
public void bindPreference_hasSummaryUri_shouldLoadSummaryFromContentProvider() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
- tile.metaData = new Bundle();
- tile.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI,
+ mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI,
"content://com.android.settings/tile_summary");
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
@Test
public void bindPreference_withNullKeyTileKey_shouldUseTileKey() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.key = "key";
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
@Config(shadows = {ShadowTileUtils.class, ShadowThreadUtils.class})
public void bindPreference_withIconUri_shouldLoadIconFromContentProvider() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.key = "key";
tile.intent = new Intent();
tile.intent.setComponent(
new ComponentName(RuntimeEnvironment.application.getPackageName(), "class"));
- tile.metaData = new Bundle();
- tile.metaData.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI,
+ mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI,
"content://com.android.settings/tile_icon");
mImpl.bindIcon(preference, tile);
public void bindPreference_withBaseOrder_shouldOffsetPriority() {
final int baseOrder = 100;
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.priority = 10;
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
preference, tile, "123", baseOrder);
public void bindPreference_withOrderMetadata_shouldUseOrderInMetadata() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final int testOrder = -30;
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
- tile.metaData.putInt(mImpl.META_DATA_KEY_ORDER, testOrder);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
+ mActivityInfo.metaData.putInt(mImpl.META_DATA_KEY_ORDER, testOrder);
tile.priority = 10;
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
preference, tile, "123", Preference.DEFAULT_ORDER);
@Test
public void bindPreference_invalidOrderMetadata_shouldIgnore() {
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
- tile.metaData.putString(mImpl.META_DATA_KEY_ORDER, "hello");
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
+ mActivityInfo.metaData.putString(mImpl.META_DATA_KEY_ORDER, "hello");
tile.priority = 10;
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
preference, tile, "123", Preference.DEFAULT_ORDER);
public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() {
Activity activity = Robolectric.buildActivity(Activity.class).get();
final Preference preference = new Preference(RuntimeEnvironment.application);
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.key = "key";
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
- tile.metaData = new Bundle();
- tile.metaData.putString("com.android.settings.intent.action", "TestAction");
+ mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
Activity activity = Robolectric.buildActivity(Activity.class).get();
final ShadowApplication application = ShadowApplication.getInstance();
final Preference preference = new Preference(application.getApplicationContext());
- final Tile tile = new Tile(mActivityInfo);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.key = "key";
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
- tile.metaData = new Bundle();
- tile.metaData.putString("com.android.settings.intent.action", "TestAction");
+ mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
mImpl = new DashboardFeatureProviderImpl(mActivity);
ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
- .thenReturn(new DashboardCategory());
+ .thenReturn(new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE));
assertThat(mImpl.getPreferencesForCategory(null, null,
MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
public void getPreferences_hasTileForCategory_shouldReturnPrefList() {
mImpl = new DashboardFeatureProviderImpl(mActivity);
ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
- final DashboardCategory category = new DashboardCategory();
- category.addTile(new Tile(mActivityInfo));
+ final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE);
+ category.addTile(new Tile(mActivityInfo, category.key));
when(mCategoryManager
.getTilesByCategory(any(Context.class), eq(CategoryKey.CATEGORY_HOMEPAGE)))
.thenReturn(category);
@Test
public void openTileIntent_profileSelectionDialog_shouldShow() {
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
final ArrayList<UserHandle> handles = new ArrayList<>();
@Test
public void openTileIntent_profileSelectionDialog_explicitMetadataShouldShow() {
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
- tile.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
+ mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
final ArrayList<UserHandle> handles = new ArrayList<>();
@Test
public void openTileIntent_profileSelectionDialog_shouldNotShow() {
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
- tile.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
+ mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
+ final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
final ArrayList<UserHandle> handles = new ArrayList<>();
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
import android.content.pm.ActivityInfo;
-import android.graphics.drawable.Icon;
import android.os.Bundle;
import androidx.preference.Preference;
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.drawer.TileUtils;
import org.junit.Before;
import org.junit.Test;
mContext = spy(RuntimeEnvironment.application);
mActivityInfo = new ActivityInfo();
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
- mDashboardCategory = new DashboardCategory();
- mDashboardCategory.addTile(new Tile(mActivityInfo));
+ mDashboardCategory = new DashboardCategory("key");
+ mDashboardCategory.addTile(new Tile(mActivityInfo, mDashboardCategory.key));
mTestFragment = new TestFragment(RuntimeEnvironment.application);
when(mFakeFeatureFactory.dashboardFeatureProvider
.getTilesForCategory(nullable(String.class)))
verify(mockController2).getPreferenceKey();
}
- @Test
- public void tintTileIcon_hasMetadata_shouldReturnIconTintableMetadata() {
- final Tile tile = spy(new Tile(mActivityInfo));
- doReturn(mock(Icon.class)).when(tile).getIcon(any(Context.class));
- final Bundle metaData = new Bundle();
- tile.metaData = metaData;
-
- metaData.putBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE, false);
- assertThat(mTestFragment.tintTileIcon(tile)).isFalse();
-
- metaData.putBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE, true);
- assertThat(mTestFragment.tintTileIcon(tile)).isTrue();
- }
-
- @Test
- public void tintTileIcon_noIcon_shouldReturnFalse() {
- final Tile tile = new Tile(mActivityInfo);
- tile.metaData = new Bundle();
-
- assertThat(mTestFragment.tintTileIcon(tile)).isFalse();
- }
-
- @Test
- public void tintTileIcon_noMetadata_shouldReturnPackageNameCheck() {
- final Tile tile = spy(new Tile(mActivityInfo));
- doReturn(mock(Icon.class)).when(tile).getIcon(any(Context.class));
- final Intent intent = new Intent();
- tile.intent = intent;
- intent.setComponent(
- new ComponentName(RuntimeEnvironment.application.getPackageName(), "TestClass"));
- assertThat(mTestFragment.tintTileIcon(tile)).isFalse();
-
- intent.setComponent(new ComponentName("OtherPackage", "TestClass"));
- assertThat(mTestFragment.tintTileIcon(tile)).isTrue();
- }
-
public static class TestPreferenceController extends AbstractPreferenceController
implements PreferenceControllerMixin {
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
import org.junit.Before;
public void SetUp() {
mDashboardItemAnimator = new DashboardItemAnimator();
mViewHolder = new ViewHolder(new TextView(RuntimeEnvironment.application));
- mViewHolder.itemView.setTag(new Tile(new ActivityInfo()));
+ mViewHolder.itemView.setTag(new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE));
}
@Test
MockitoAnnotations.initMocks(this);
mFeatureFactory = FakeFeatureFactory.setupForTest();
- mTile = new Tile(new ActivityInfo());
+ mTile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
mTile.summary = SUMMARY_1;
mCallbackInvoked = false;
@Test
public void testUpdateSummaryToCache_hasCache_shouldUpdate() {
final String testSummary = "test_summary";
- final DashboardCategory category = new DashboardCategory();
- final Tile tile = new Tile(new ActivityInfo());
+ final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE);
+ final Tile tile = new Tile(new ActivityInfo(), category.key);
tile.key = "123";
tile.intent = new Intent();
category.addTile(tile);
import android.os.UserManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
import org.junit.Before;
@Test
public void updateUserHandlesIfNeeded_Normal() {
- final Tile tile = new Tile(new ActivityInfo());
+ final Tile tile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.userHandle.add(NORMAL_USER);
@Test
public void updateUserHandlesIfNeeded_Remove() {
- final Tile tile = new Tile(new ActivityInfo());
+ final Tile tile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
tile.intent = new Intent();
tile.userHandle.add(REMOVED_USER);
tile.userHandle.add(NORMAL_USER);
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowSecureSettings;
+import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.suggestions.SuggestionControllerMixinCompat;
@Test
public void filterExclusiveSuggestions_shouldOnlyKeepFirst3() {
final List<Tile> suggestions = new ArrayList<>();
- suggestions.add(new Tile(mActivityInfo));
- suggestions.add(new Tile(mActivityInfo));
- suggestions.add(new Tile(mActivityInfo));
- suggestions.add(new Tile(mActivityInfo));
- suggestions.add(new Tile(mActivityInfo));
- suggestions.add(new Tile(mActivityInfo));
- suggestions.add(new Tile(mActivityInfo));
+ suggestions.add(new Tile(mActivityInfo, CategoryKey.CATEGORY_APPS));
+ suggestions.add(new Tile(mActivityInfo, CategoryKey.CATEGORY_APPS));
+ suggestions.add(new Tile(mActivityInfo, CategoryKey.CATEGORY_APPS));
+ suggestions.add(new Tile(mActivityInfo, CategoryKey.CATEGORY_APPS));
+ suggestions.add(new Tile(mActivityInfo, CategoryKey.CATEGORY_APPS));
+ suggestions.add(new Tile(mActivityInfo, CategoryKey.CATEGORY_APPS));
+ suggestions.add(new Tile(mActivityInfo, CategoryKey.CATEGORY_APPS));
mProvider.filterExclusiveSuggestions(suggestions);