diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2020-01-17 10:05:50 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2020-01-21 16:17:49 -0800 |
commit | 77a2416924c1a58945bd29c272efa336ee1274f7 (patch) | |
tree | fb15934ca567523b6e38ce4fcd973fa70de5b8b0 /graphics | |
parent | d26218b6d7ffb01b177642c1463ef77cd588f4ef (diff) |
Adding API to check if an icon returned by PackageManager
is a fallback icon
Bug: 141588119
Test: atest PackageManagerTest
Change-Id: I9ae5a74dd0b0c0c49a078d46914986ecb0d27a94
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java b/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java index fab96a1e9fbd..928e607abbbe 100644 --- a/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java +++ b/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java @@ -16,6 +16,7 @@ package android.graphics.drawable; +import android.annotation.DrawableRes; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; @@ -223,6 +224,7 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback final int deviceDensity = Drawable.resolveDensity(r, 0); state.setDensity(deviceDensity); state.mSrcDensityOverride = mSrcDensityOverride; + state.mSourceDrawableId = Resources.getAttributeSetSourceResId(attrs); final ChildDrawable[] array = state.mChildren; for (int i = 0; i < state.mChildren.length; i++) { @@ -446,6 +448,17 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback } /** + * If the drawable was inflated from XML, this returns the resource ID for the drawable + * + * @hide + */ + @DrawableRes + public int getSourceDrawableResId() { + final LayerState state = mLayerState; + return state == null ? Resources.ID_NULL : state.mSourceDrawableId; + } + + /** * Inflates child layers using the specified parser. */ private void inflateLayers(@NonNull Resources r, @NonNull XmlPullParser parser, @@ -944,6 +957,8 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback @Config int mChangingConfigurations; @Config int mChildrenChangingConfigurations; + @DrawableRes int mSourceDrawableId = Resources.ID_NULL; + private boolean mCheckedOpacity; private int mOpacity; |