From 29a90d6b4b93fdd13dd322d0beada80e8ac09548 Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Thu, 7 Mar 2019 15:47:38 -0800 Subject: [PATCH] Make Resources#getAttributeSetSourceResId public Turns out this method is generaly useful outside of View construction. Test: added CTS test Bug: 127855851 Change-Id: Ia2a5a3a9dc5eac5a1da51e7df6989bb09b141141 --- api/current.txt | 1 + core/java/android/content/res/Resources.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 6de1383a2e053..3cfa0fb77f77e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -12274,6 +12274,7 @@ package android.content.res { method public final void flushLayoutCache(); method @NonNull public android.content.res.XmlResourceParser getAnimation(@AnimatorRes @AnimRes int) throws android.content.res.Resources.NotFoundException; method public final android.content.res.AssetManager getAssets(); + method @AnyRes public static int getAttributeSetSourceResId(@Nullable android.util.AttributeSet); method public boolean getBoolean(@BoolRes int) throws android.content.res.Resources.NotFoundException; method @Deprecated @ColorInt public int getColor(@ColorRes int) throws android.content.res.Resources.NotFoundException; method @ColorInt public int getColor(@ColorRes int, @Nullable android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException; diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index a2ae994f7b0f1..554e5854764e5 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -1396,9 +1396,11 @@ public class Resources { /** + * Returns the resource ID of the resource that was used to create this AttributeSet. + * * @param set AttributeSet for which we want to find the source. - * @return The resource id for the source that is backing the given AttributeSet - * @hide + * @return The resource ID for the source that is backing the given AttributeSet or + * {@link Resources#ID_NULL} if the AttributeSet is {@code null}. */ @AnyRes public static int getAttributeSetSourceResId(@Nullable AttributeSet set) {