Remove ContentProvider queries in updateTileData.
The ContentProvider queries in updateTileData are not being used, and adds extra latency. Queries are performed later in Settings to get the freshest data. Bug: 35708630 Test: make RunSettingsLibRoboTests Change-Id: I3798af0a89ed7261cfa4ebec4fada077495034ed
This commit is contained in:
@@ -33,7 +33,6 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings.Global;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
@@ -353,10 +352,7 @@ public class TileUtils {
|
||||
CharSequence title = null;
|
||||
String summary = null;
|
||||
String keyHint = null;
|
||||
String uriString = null;
|
||||
Uri uri = null;
|
||||
// Several resources can be using the same provider. Only acquire a single provider.
|
||||
Map<String, IContentProvider> providerMap = new ArrayMap<>();
|
||||
|
||||
// Get the activity's meta-data
|
||||
try {
|
||||
@@ -365,11 +361,7 @@ public class TileUtils {
|
||||
Bundle metaData = activityInfo.metaData;
|
||||
|
||||
if (res != null && metaData != null) {
|
||||
if (metaData.containsKey(META_DATA_PREFERENCE_ICON_URI)) {
|
||||
iconFromUri = getIconFromUri(context, activityInfo.packageName,
|
||||
metaData.getString(META_DATA_PREFERENCE_ICON_URI), providerMap);
|
||||
}
|
||||
if (iconFromUri == null && metaData.containsKey(META_DATA_PREFERENCE_ICON)) {
|
||||
if (metaData.containsKey(META_DATA_PREFERENCE_ICON)) {
|
||||
icon = metaData.getInt(META_DATA_PREFERENCE_ICON);
|
||||
}
|
||||
if (metaData.containsKey(META_DATA_PREFERENCE_TITLE)) {
|
||||
@@ -379,13 +371,7 @@ public class TileUtils {
|
||||
title = metaData.getString(META_DATA_PREFERENCE_TITLE);
|
||||
}
|
||||
}
|
||||
if (metaData.containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
|
||||
summary = getTextFromUri(context,
|
||||
metaData.getString(META_DATA_PREFERENCE_SUMMARY_URI), providerMap,
|
||||
META_DATA_PREFERENCE_SUMMARY);
|
||||
}
|
||||
if (TextUtils.isEmpty(summary)
|
||||
&& metaData.containsKey(META_DATA_PREFERENCE_SUMMARY)) {
|
||||
if (metaData.containsKey(META_DATA_PREFERENCE_SUMMARY)) {
|
||||
if (metaData.get(META_DATA_PREFERENCE_SUMMARY) instanceof Integer) {
|
||||
summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
|
||||
} else {
|
||||
|
||||
@@ -282,26 +282,11 @@ public class TileUtilsTest {
|
||||
when(mPackageManager.queryIntentActivitiesAsUser(eq(intent), anyInt(), anyInt()))
|
||||
.thenReturn(info);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("com.android.settings.icon", 161803);
|
||||
bundle.putString("com.android.settings.icon_package", "abc");
|
||||
bundle.putString("com.android.settings.summary", "dynamic-summary");
|
||||
when(mIContentProvider.call(anyString(),
|
||||
eq(TileUtils.getMethodFromUri(Uri.parse(URI_GET_ICON))), eq(URI_GET_ICON), any()))
|
||||
.thenReturn(bundle);
|
||||
when(mIContentProvider.call(anyString(),
|
||||
eq(TileUtils.getMethodFromUri(Uri.parse(URI_GET_SUMMARY))), eq(URI_GET_SUMMARY),
|
||||
any())).thenReturn(bundle);
|
||||
when(mContentResolver.acquireProvider(anyString())).thenReturn(mIContentProvider);
|
||||
when(mContentResolver.acquireProvider(any(Uri.class))).thenReturn(mIContentProvider);
|
||||
|
||||
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
|
||||
null /* defaultCategory */, outTiles, false /* usePriority */,
|
||||
false /* checkCategory */);
|
||||
|
||||
assertThat(outTiles.size()).isEqualTo(1);
|
||||
assertThat(outTiles.get(0).icon.getResId()).isEqualTo(161803);
|
||||
assertThat(outTiles.get(0).summary).isEqualTo("dynamic-summary");
|
||||
}
|
||||
|
||||
public static ResolveInfo newInfo(boolean systemApp, String category) {
|
||||
|
||||
Reference in New Issue
Block a user