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

Commit ce685fa4 authored by Jason Chiu's avatar Jason Chiu
Browse files

[Injection] Stop using the component icon as a fallback option

Settings displays the component icon as a fallback option if the
metadata doesn't contain icon and icon_uri. Some injections that don't
need an icon have set a transpatrnt color to skip the fallback option.

However, the new Settings requires that an item without an icon should
align with the border. The transparent icon makes the item unaligned.

Therefore, we remove the hidden fallback option, and also filter out
the transparent color icon for backward compatibility.

Bug: 186801104
Test: robotest
Change-Id: I9221bba896e4785901ad617aa8ee58e6028ecc72
parent b04a005c
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.settingslib.drawer;
import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_ORDER;
import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_PROFILE;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON_URI;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_KEYHINT;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY_URI;
@@ -301,16 +300,8 @@ public abstract class Tile implements Parcelable {
        }

        int iconResId = mMetaData.getInt(META_DATA_PREFERENCE_ICON);
        // Set the icon
        if (iconResId == 0) {
            // Only fallback to componentInfo.icon if metadata does not contain ICON_URI.
            // ICON_URI should be loaded in app UI when need the icon object. Handling IPC at this
            // level is too complex because we don't have a strong threading contract for this class
            if (!mMetaData.containsKey(META_DATA_PREFERENCE_ICON_URI)) {
                iconResId = getComponentIcon(componentInfo);
            }
        }
        if (iconResId != 0) {
        // Set the icon. Skip the transparent color for backward compatibility since Android S.
        if (iconResId != 0 && iconResId != android.R.color.transparent) {
            final Icon icon = Icon.createWithResource(componentInfo.packageName, iconResId);
            if (isIconTintable(context)) {
                final TypedArray a = context.obtainStyledAttributes(new int[]{
+3 −4
Original line number Diff line number Diff line
@@ -105,11 +105,10 @@ public class ActivityTileTest {
    }

    @Test
    public void getIcon_noIconMetadata_returnActivityIcon() {
        mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON, 0);
    public void getIcon_transparentColorInMetadata_returnNull() {
        mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON, android.R.color.transparent);

        assertThat(mTile.getIcon(RuntimeEnvironment.application).getResId())
                .isEqualTo(mActivityInfo.icon);
        assertThat(mTile.getIcon(RuntimeEnvironment.application)).isNull();
    }

    @Test