Remove a bunch of unused things from Tile.
Bug: 77600770 Test: rebuild Change-Id: I6e1bd6db80ea974e64b34cc80af9a409104c7092
This commit is contained in:
@@ -17,12 +17,13 @@ package com.android.settingslib.drawer;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settingslib.applications.InterestingConfigChanges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -32,10 +33,10 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||
|
||||
public class CategoryManager {
|
||||
|
||||
public static final String SETTING_PKG = "com.android.settings";
|
||||
|
||||
private static final String TAG = "CategoryManager";
|
||||
|
||||
private static CategoryManager sInstance;
|
||||
@@ -70,22 +71,13 @@ public class CategoryManager {
|
||||
}
|
||||
|
||||
public synchronized DashboardCategory getTilesByCategory(Context context, String categoryKey) {
|
||||
return getTilesByCategory(context, categoryKey, TileUtils.SETTING_PKG);
|
||||
}
|
||||
|
||||
public synchronized DashboardCategory getTilesByCategory(Context context, String categoryKey,
|
||||
String settingPkg) {
|
||||
tryInitCategories(context, settingPkg);
|
||||
tryInitCategories(context, SETTING_PKG);
|
||||
|
||||
return mCategoryByKeyMap.get(categoryKey);
|
||||
}
|
||||
|
||||
public synchronized List<DashboardCategory> getCategories(Context context) {
|
||||
return getCategories(context, TileUtils.SETTING_PKG);
|
||||
}
|
||||
|
||||
public synchronized List<DashboardCategory> getCategories(Context context, String settingPkg) {
|
||||
tryInitCategories(context, settingPkg);
|
||||
tryInitCategories(context, SETTING_PKG);
|
||||
return mCategories;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,11 +95,6 @@ public class Tile implements Parcelable {
|
||||
*/
|
||||
public String key;
|
||||
|
||||
/**
|
||||
* Optional remote view which will be displayed instead of the regular title-summary item.
|
||||
*/
|
||||
public RemoteViews remoteViews;
|
||||
|
||||
public Tile() {
|
||||
// Empty
|
||||
}
|
||||
@@ -135,7 +130,6 @@ public class Tile implements Parcelable {
|
||||
dest.writeInt(priority);
|
||||
dest.writeBundle(metaData);
|
||||
dest.writeString(key);
|
||||
dest.writeParcelable(remoteViews, flags);
|
||||
dest.writeBoolean(isIconTintable);
|
||||
}
|
||||
|
||||
@@ -157,7 +151,6 @@ public class Tile implements Parcelable {
|
||||
priority = in.readInt();
|
||||
metaData = in.readBundle();
|
||||
key = in.readString();
|
||||
remoteViews = in.readParcelable(RemoteViews.class.getClassLoader());
|
||||
isIconTintable = in.readBoolean();
|
||||
}
|
||||
|
||||
|
||||
@@ -166,8 +166,6 @@ public class TileUtils {
|
||||
public static final String META_DATA_PREFERENCE_SUMMARY_URI =
|
||||
"com.android.settings.summary_uri";
|
||||
|
||||
public static final String SETTING_PKG = "com.android.settings";
|
||||
|
||||
/**
|
||||
* Value for {@link #META_DATA_KEY_PROFILE}. When the device has a managed profile,
|
||||
* the app will always be run in the primary profile.
|
||||
@@ -280,15 +278,6 @@ public class TileUtils {
|
||||
Context context, UserHandle user, Intent intent,
|
||||
Map<Pair<String, String>, Tile> addedCache, String defaultCategory, List<Tile> outTiles,
|
||||
boolean usePriority, boolean checkCategory, boolean forceTintExternalIcon) {
|
||||
getTilesForIntent(context, user, intent, addedCache, defaultCategory, outTiles,
|
||||
usePriority, checkCategory, forceTintExternalIcon, false /* shouldUpdateTiles */);
|
||||
}
|
||||
|
||||
public static void getTilesForIntent(
|
||||
Context context, UserHandle user, Intent intent,
|
||||
Map<Pair<String, String>, Tile> addedCache, String defaultCategory, List<Tile> outTiles,
|
||||
boolean usePriority, boolean checkCategory, boolean forceTintExternalIcon,
|
||||
boolean shouldUpdateTiles) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<ResolveInfo> results = pm.queryIntentActivitiesAsUser(intent,
|
||||
PackageManager.GET_META_DATA, user.getIdentifier());
|
||||
@@ -313,8 +302,7 @@ public class TileUtils {
|
||||
categoryKey = metaData.getString(EXTRA_CATEGORY_KEY);
|
||||
}
|
||||
|
||||
Pair<String, String> key = new Pair<String, String>(activityInfo.packageName,
|
||||
activityInfo.name);
|
||||
Pair<String, String> key = new Pair<>(activityInfo.packageName, activityInfo.name);
|
||||
Tile tile = addedCache.get(key);
|
||||
if (tile == null) {
|
||||
tile = new Tile();
|
||||
@@ -327,8 +315,6 @@ public class TileUtils {
|
||||
pm, providerMap, forceTintExternalIcon);
|
||||
if (DEBUG) Log.d(LOG_TAG, "Adding tile " + tile.title);
|
||||
addedCache.put(key, tile);
|
||||
} else if (shouldUpdateTiles) {
|
||||
updateSummaryAndTitle(context, providerMap, tile);
|
||||
}
|
||||
|
||||
if (!tile.userHandle.contains(user)) {
|
||||
@@ -435,26 +421,6 @@ public class TileUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void updateSummaryAndTitle(
|
||||
Context context, Map<String, IContentProvider> providerMap, Tile tile) {
|
||||
if (tile == null || tile.metaData == null
|
||||
|| !tile.metaData.containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String uriString = tile.metaData.getString(META_DATA_PREFERENCE_SUMMARY_URI);
|
||||
Bundle bundle = getBundleFromUri(context, uriString, providerMap);
|
||||
String overrideSummary = getString(bundle, META_DATA_PREFERENCE_SUMMARY);
|
||||
String overrideTitle = getString(bundle, META_DATA_PREFERENCE_TITLE);
|
||||
if (overrideSummary != null) {
|
||||
tile.remoteViews.setTextViewText(android.R.id.summary, overrideSummary);
|
||||
}
|
||||
|
||||
if (overrideTitle != null) {
|
||||
tile.remoteViews.setTextViewText(android.R.id.title, overrideTitle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon package name and resource id from content provider.
|
||||
* @param context context
|
||||
|
||||
@@ -20,13 +20,15 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.util.ArraySet;
|
||||
|
||||
import com.android.settingslib.SettingsLibRobolectricTestRunner;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@RunWith(SettingsLibRobolectricTestRunner.class)
|
||||
public class CategoryKeyTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -7,12 +7,15 @@ import static com.android.settingslib.drawer.TileUtils.PROFILE_ALL;
|
||||
import static com.android.settingslib.drawer.TileUtils.PROFILE_PRIMARY;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settingslib.SettingsLibRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.junit.Test;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@RunWith(SettingsLibRobolectricTestRunner.class)
|
||||
public class TileTest {
|
||||
|
||||
private Tile mTile;
|
||||
|
||||
@@ -178,7 +178,7 @@ public class TileUtilsTest {
|
||||
.thenReturn(info);
|
||||
|
||||
List<DashboardCategory> categoryList = TileUtils.getCategories(
|
||||
mContext, cache, testAction, TileUtils.SETTING_PKG);
|
||||
mContext, cache, testAction, CategoryManager.SETTING_PKG);
|
||||
assertThat(categoryList.get(0).getTile(0).category).isEqualTo(testCategory);
|
||||
}
|
||||
|
||||
@@ -193,12 +193,12 @@ public class TileUtilsTest {
|
||||
userHandleList.add(new UserHandle(ActivityManager.getCurrentUser()));
|
||||
when(mUserManager.getUserProfiles()).thenReturn(userHandleList);
|
||||
|
||||
TileUtils.getCategories(mContext, cache, null /* action */, TileUtils.SETTING_PKG);
|
||||
TileUtils.getCategories(mContext, cache, null /* action */, CategoryManager.SETTING_PKG);
|
||||
verify(mPackageManager, atLeastOnce()).queryIntentActivitiesAsUser(
|
||||
intentCaptor.capture(), anyInt(), anyInt());
|
||||
|
||||
assertThat(intentCaptor.getAllValues().get(0).getPackage())
|
||||
.isEqualTo(TileUtils.SETTING_PKG);
|
||||
.isEqualTo(CategoryManager.SETTING_PKG);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user