Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23830a09 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove ContentProvider queries in updateTileData."

parents 28a7194d 204af1cb
Loading
Loading
Loading
Loading
+2 −16
Original line number Diff line number Diff line
@@ -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 {
+0 −15
Original line number Diff line number Diff line
@@ -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) {