diff --git a/core/java/android/animation/Animator.java b/core/java/android/animation/Animator.java index 844063c04e83c..8e31d323009fe 100644 --- a/core/java/android/animation/Animator.java +++ b/core/java/android/animation/Animator.java @@ -16,6 +16,7 @@ package android.animation; +import android.content.pm.ActivityInfo.Config; import android.content.res.ConstantState; import java.util.ArrayList; @@ -50,7 +51,7 @@ public abstract class Animator implements Cloneable { * A set of flags which identify the type of configuration changes that can affect this * Animator. Used by the Animator cache. */ - int mChangingConfigurations = 0; + @Config int mChangingConfigurations = 0; /** * If this animator is inflated from a constant state, keep a reference to it so that @@ -344,7 +345,7 @@ public abstract class Animator implements Cloneable { * @see android.content.pm.ActivityInfo * @hide */ - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations; } @@ -358,7 +359,7 @@ public abstract class Animator implements Cloneable { * @see android.content.pm.ActivityInfo * @hide */ - public void setChangingConfigurations(int configs) { + public void setChangingConfigurations(@Config int configs) { mChangingConfigurations = configs; } @@ -368,7 +369,7 @@ public abstract class Animator implements Cloneable { * This method is called while loading the animator. * @hide */ - public void appendChangingConfigurations(int configs) { + public void appendChangingConfigurations(@Config int configs) { mChangingConfigurations |= configs; } @@ -564,7 +565,7 @@ public abstract class Animator implements Cloneable { private static class AnimatorConstantState extends ConstantState { final Animator mAnimator; - int mChangingConf; + @Config int mChangingConf; public AnimatorConstantState(Animator animator) { mAnimator = animator; @@ -574,7 +575,7 @@ public abstract class Animator implements Cloneable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConf; } diff --git a/core/java/android/animation/AnimatorInflater.java b/core/java/android/animation/AnimatorInflater.java index 8d03b551a3479..7d5931fc1cc28 100644 --- a/core/java/android/animation/AnimatorInflater.java +++ b/core/java/android/animation/AnimatorInflater.java @@ -16,7 +16,10 @@ package android.animation; import android.annotation.AnimatorRes; +import android.annotation.AnyRes; +import android.annotation.NonNull; import android.content.Context; +import android.content.pm.ActivityInfo.Config; import android.content.res.ConfigurationBoundResourceCache; import android.content.res.ConstantState; import android.content.res.Resources; @@ -1062,7 +1065,7 @@ public class AnimatorInflater { return anim; } - private static int getChangingConfigs(Resources resources, int id) { + private static @Config int getChangingConfigs(@NonNull Resources resources, @AnyRes int id) { synchronized (sTmpTypedValue) { resources.getValue(id, sTmpTypedValue, true); return sTmpTypedValue.changingConfigurations; diff --git a/core/java/android/animation/StateListAnimator.java b/core/java/android/animation/StateListAnimator.java index d49e914cf5cca..b6d6910c1dc85 100644 --- a/core/java/android/animation/StateListAnimator.java +++ b/core/java/android/animation/StateListAnimator.java @@ -16,6 +16,7 @@ package android.animation; +import android.content.pm.ActivityInfo.Config; import android.content.res.ConstantState; import android.util.StateSet; import android.view.View; @@ -53,7 +54,7 @@ public class StateListAnimator implements Cloneable { private WeakReference mViewRef; private StateListAnimatorConstantState mConstantState; private AnimatorListenerAdapter mAnimatorListener; - private int mChangingConfigurations; + private @Config int mChangingConfigurations; public StateListAnimator() { initAnimatorListener(); @@ -223,7 +224,7 @@ public class StateListAnimator implements Cloneable { * @see android.content.pm.ActivityInfo * @hide */ - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations; } @@ -237,7 +238,7 @@ public class StateListAnimator implements Cloneable { * @see android.content.pm.ActivityInfo * @hide */ - public void setChangingConfigurations(int configs) { + public void setChangingConfigurations(@Config int configs) { mChangingConfigurations = configs; } @@ -247,7 +248,7 @@ public class StateListAnimator implements Cloneable { * This method is called while loading the animator. * @hide */ - public void appendChangingConfigurations(int configs) { + public void appendChangingConfigurations(@Config int configs) { mChangingConfigurations |= configs; } @@ -309,7 +310,7 @@ public class StateListAnimator implements Cloneable { final StateListAnimator mAnimator; - int mChangingConf; + @Config int mChangingConf; public StateListAnimatorConstantState(StateListAnimator animator) { mAnimator = animator; @@ -318,7 +319,7 @@ public class StateListAnimator implements Cloneable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConf; } diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 14ef61ce63d40..5da3c866077a4 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -18,6 +18,7 @@ package android.content.pm; import android.annotation.IntDef; import android.content.res.Configuration; +import android.content.res.Configuration.NativeConfig; import android.os.Parcel; import android.os.Parcelable; import android.util.Printer; @@ -495,6 +496,28 @@ public class ActivityInfo extends ComponentInfo @ScreenOrientation public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; + /** @hide */ + @IntDef(flag = true, + value = { + CONFIG_MCC, + CONFIG_MNC, + CONFIG_LOCALE, + CONFIG_TOUCHSCREEN, + CONFIG_KEYBOARD, + CONFIG_KEYBOARD_HIDDEN, + CONFIG_NAVIGATION, + CONFIG_ORIENTATION, + CONFIG_SCREEN_LAYOUT, + CONFIG_UI_MODE, + CONFIG_SCREEN_SIZE, + CONFIG_SMALLEST_SCREEN_SIZE, + CONFIG_DENSITY, + CONFIG_LAYOUT_DIRECTION, + CONFIG_FONT_SCALE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface Config {} + /** * Bit in {@link #configChanges} that indicates that the activity * can itself handle changes to the IMSI MCC. Set from the @@ -629,7 +652,7 @@ public class ActivityInfo extends ComponentInfo * * @hide */ - public static int activityInfoConfigToNative(int input) { + public static @NativeConfig int activityInfoConfigJavaToNative(@Config int input) { int output = 0; for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { if ((input & (1 << i)) != 0) { @@ -644,7 +667,7 @@ public class ActivityInfo extends ComponentInfo * * @hide */ - public static int activityInfoConfigNativeToJava(int input) { + public static @Config int activityInfoConfigNativeToJava(@NativeConfig int input) { int output = 0; for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { if ((input & CONFIG_NATIVE_BITS[i]) != 0) { diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 7b0b98d4389ca..4ad86f7c7019d 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -21,6 +21,7 @@ import android.annotation.ArrayRes; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.StringRes; +import android.content.res.Configuration.NativeConfig; import android.os.ParcelFileDescriptor; import android.util.Log; import android.util.SparseArray; @@ -796,7 +797,10 @@ public final class AssetManager implements AutoCloseable { /*package*/ static final int STYLE_DATA = 1; /*package*/ static final int STYLE_ASSET_COOKIE = 2; /*package*/ static final int STYLE_RESOURCE_ID = 3; - /*package*/ static final int STYLE_CHANGING_CONFIGURATIONS = 4; + + /* Offset within typed data array for native changingConfigurations. */ + static final int STYLE_CHANGING_CONFIGURATIONS = 4; + /*package*/ static final int STYLE_DENSITY = 5; /*package*/ native static final boolean applyStyle(long theme, int defStyleAttr, int defStyleRes, long xmlParser, @@ -845,7 +849,7 @@ public final class AssetManager implements AutoCloseable { TypedValue outValue, boolean resolve); /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix); - /*package*/ native static final int getThemeChangingConfigurations(long theme); + /*package*/ native static final @NativeConfig int getThemeChangingConfigurations(long theme); private native final long openXmlAssetNative(int cookie, String fileName); diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java index 9e1b312c8372c..5bf2e3e5aa495 100644 --- a/core/java/android/content/res/ColorStateList.java +++ b/core/java/android/content/res/ColorStateList.java @@ -19,6 +19,7 @@ package android.content.res; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.Resources.Theme; import android.graphics.Color; @@ -82,7 +83,7 @@ public class ColorStateList extends ComplexColor implements Parcelable { private ColorStateListFactory mFactory; private int[][] mThemeAttrs; - private int mChangingConfigurations; + private @Config int mChangingConfigurations; private int[][] mStateSpecs; private int[] mColors; @@ -251,7 +252,7 @@ public class ColorStateList extends ComplexColor implements Parcelable { int depth; int type; - int changingConfigurations = 0; + @Config int changingConfigurations = 0; int defaultColor = DEFAULT_COLOR; boolean hasUnresolvedAttrs = false; @@ -440,7 +441,7 @@ public class ColorStateList extends ComplexColor implements Parcelable { * * @see android.content.pm.ActivityInfo */ - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations; } @@ -620,7 +621,7 @@ public class ColorStateList extends ComplexColor implements Parcelable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mSrc.mChangingConfigurations; } diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java index be4f89567f51c..9b1d4627807cd 100644 --- a/core/java/android/content/res/Configuration.java +++ b/core/java/android/content/res/Configuration.java @@ -22,8 +22,11 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlSerializer; +import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.ActivityInfo; +import android.content.pm.ActivityInfo.Config; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; @@ -32,6 +35,8 @@ import android.util.LocaleList; import android.view.View; import java.io.IOException; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Locale; @@ -663,6 +668,28 @@ public final class Configuration implements Parcelable, Comparabledelta are ignored and not copied in to the current - * Configuration. - * @return Returns a bit mask of the changed fields, as per - * {@link #diff}. + * Copies the fields from delta into this Configuration object, keeping + * track of which ones have changed. Any undefined fields in {@code delta} + * are ignored and not copied in to the current Configuration. + * + * @return a bit mask of the changed fields, as per {@link #diff} */ - public int updateFrom(Configuration delta) { + public @Config int updateFrom(@NonNull Configuration delta) { int changed = 0; if (delta.fontScale > 0 && fontScale != delta.fontScale) { changed |= ActivityInfo.CONFIG_FONT_SCALE; @@ -1171,17 +1197,19 @@ public final class Configuration implements Parcelable, Comparable extends ThemedResourceCache entry, int configChanges) { + public boolean shouldInvalidateEntry(ConstantState entry, @Config int configChanges) { return Configuration.needNewResources(configChanges, entry.getChangingConfigurations()); } } diff --git a/core/java/android/content/res/ConstantState.java b/core/java/android/content/res/ConstantState.java index ee609df2e2322..09d4a59d14189 100644 --- a/core/java/android/content/res/ConstantState.java +++ b/core/java/android/content/res/ConstantState.java @@ -15,6 +15,8 @@ */ package android.content.res; +import android.content.pm.ActivityInfo.Config; + /** * A cache class that can provide new instances of a particular resource which may change * depending on the current {@link Resources.Theme} or {@link Configuration}. @@ -33,7 +35,7 @@ abstract public class ConstantState { * Return a bit mask of configuration changes that will impact * this resource (and thus require completely reloading it). */ - abstract public int getChangingConfigurations(); + abstract public @Config int getChangingConfigurations(); /** * Create a new instance without supplying resources the caller diff --git a/core/java/android/content/res/GradientColor.java b/core/java/android/content/res/GradientColor.java index cc46cbd43258f..329134094824d 100644 --- a/core/java/android/content/res/GradientColor.java +++ b/core/java/android/content/res/GradientColor.java @@ -20,6 +20,7 @@ import android.annotation.ColorInt; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.Resources.Theme; import com.android.internal.R; @@ -83,7 +84,7 @@ public class GradientColor extends ComplexColor { /** Lazily-created factory for this GradientColor. */ private GradientColorFactory mFactory; - private int mChangingConfigurations; + private @Config int mChangingConfigurations; private int mDefaultColor; // After parsing all the attributes from XML, this shader is the ultimate result containing @@ -506,7 +507,7 @@ public class GradientColor extends ComplexColor { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mSrc.mChangingConfigurations; } diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java index 0858cb8b9305d..90037f7b508ce 100644 --- a/core/java/android/content/res/ResourcesImpl.java +++ b/core/java/android/content/res/ResourcesImpl.java @@ -15,6 +15,9 @@ */ package android.content.res; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import android.animation.Animator; import android.animation.StateListAnimator; import android.annotation.AnyRes; @@ -26,6 +29,7 @@ import android.annotation.RawRes; import android.annotation.StyleRes; import android.annotation.StyleableRes; import android.content.pm.ActivityInfo; +import android.content.pm.ActivityInfo.Config; import android.content.res.Resources.NotFoundException; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -40,8 +44,6 @@ import android.util.LongSparseArray; import android.util.Slog; import android.util.TypedValue; import android.util.Xml; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; import java.io.InputStream; import java.util.Arrays; @@ -65,7 +67,7 @@ public class ResourcesImpl { private static final boolean TRACE_FOR_PRELOAD = false; private static final boolean TRACE_FOR_MISS_PRELOAD = false; - private static final int LAYOUT_DIR_CONFIG = ActivityInfo.activityInfoConfigToNative( + private static final int LAYOUT_DIR_CONFIG = ActivityInfo.activityInfoConfigJavaToNative( ActivityInfo.CONFIG_LAYOUT_DIRECTION); private static final int ID_OTHER = 0x01000004; @@ -331,7 +333,7 @@ public class ResourcesImpl { // the framework. mCompatibilityInfo.applyToDisplayMetrics(mMetrics); - final int configChanges = calcConfigChanges(config); + final @Config int configChanges = calcConfigChanges(config); LocaleList locales = mConfiguration.getLocales(); if (locales.isEmpty()) { @@ -395,26 +397,30 @@ public class ResourcesImpl { } /** - * Called by ConfigurationBoundResourceCacheTest. + * Applies the new configuration, returning a bitmask of the changes + * between the old and new configurations. + * + * @param config the new configuration + * @return bitmask of config changes */ - public int calcConfigChanges(Configuration config) { - int configChanges = 0xfffffff; - if (config != null) { - mTmpConfig.setTo(config); - int density = config.densityDpi; - if (density == Configuration.DENSITY_DPI_UNDEFINED) { - density = mMetrics.noncompatDensityDpi; - } - - mCompatibilityInfo.applyToConfiguration(density, mTmpConfig); - - if (mTmpConfig.getLocales().isEmpty()) { - mTmpConfig.setLocales(LocaleList.getDefault()); - } - configChanges = mConfiguration.updateFrom(mTmpConfig); - configChanges = ActivityInfo.activityInfoConfigToNative(configChanges); + public @Config int calcConfigChanges(@Nullable Configuration config) { + if (config == null) { + // If there is no configuration, assume all flags have changed. + return 0xFFFFFFFF; } - return configChanges; + + mTmpConfig.setTo(config); + int density = config.densityDpi; + if (density == Configuration.DENSITY_DPI_UNDEFINED) { + density = mMetrics.noncompatDensityDpi; + } + + mCompatibilityInfo.applyToConfiguration(density, mTmpConfig); + + if (mTmpConfig.getLocales().isEmpty()) { + mTmpConfig.setLocales(LocaleList.getDefault()); + } + return mConfiguration.updateFrom(mTmpConfig); } /** @@ -593,8 +599,8 @@ public class ResourcesImpl { } } - private boolean verifyPreloadConfig(int changingConfigurations, int allowVarying, - int resourceId, String name) { + private boolean verifyPreloadConfig(@Config int changingConfigurations, + @Config int allowVarying, @AnyRes int resourceId, @Nullable String name) { // We allow preloading of resources even if they vary by font scale (which // doesn't impact resource selection) or density (which we handle specially by // simply turning off all preloading), as well as any other configs specified @@ -1104,7 +1110,7 @@ public class ResourcesImpl { return mAssets.getStyleAttributes(getAppliedStyleResId()); } - int getChangingConfigurations() { + @Config int getChangingConfigurations() { synchronized (mKey) { final int nativeChangingConfig = AssetManager.getThemeChangingConfigurations(mTheme); diff --git a/core/java/android/content/res/ThemedResourceCache.java b/core/java/android/content/res/ThemedResourceCache.java index 9a2d061474e6c..f1b1e74a697ea 100644 --- a/core/java/android/content/res/ThemedResourceCache.java +++ b/core/java/android/content/res/ThemedResourceCache.java @@ -18,6 +18,7 @@ package android.content.res; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.Resources.Theme; import android.content.res.Resources.ThemeKey; import android.util.LongSparseArray; @@ -115,7 +116,7 @@ abstract class ThemedResourceCache { * * @param configChanges a bitmask of configuration changes */ - public void onConfigurationChange(int configChanges) { + public void onConfigurationChange(@Config int configChanges) { prune(configChanges); } @@ -192,7 +193,7 @@ abstract class ThemedResourceCache { * simply prune missing weak references * @return {@code true} if the cache is completely empty after pruning */ - private boolean prune(int configChanges) { + private boolean prune(@Config int configChanges) { synchronized (this) { if (mThemedEntries != null) { for (int i = mThemedEntries.size() - 1; i >= 0; i--) { @@ -211,7 +212,7 @@ abstract class ThemedResourceCache { } private boolean pruneEntriesLocked(@Nullable LongSparseArray> entries, - int configChanges) { + @Config int configChanges) { if (entries == null) { return true; } @@ -226,7 +227,7 @@ abstract class ThemedResourceCache { return entries.size() == 0; } - private boolean pruneEntryLocked(@Nullable T entry, int configChanges) { + private boolean pruneEntryLocked(@Nullable T entry, @Config int configChanges) { return entry == null || (configChanges != 0 && shouldInvalidateEntry(entry, configChanges)); } diff --git a/core/java/android/content/res/TypedArray.java b/core/java/android/content/res/TypedArray.java index 022bdfb9309e5..f6ac0bac125a2 100644 --- a/core/java/android/content/res/TypedArray.java +++ b/core/java/android/content/res/TypedArray.java @@ -20,6 +20,8 @@ import android.annotation.AnyRes; import android.annotation.ColorInt; import android.annotation.Nullable; import android.annotation.StyleableRes; +import android.content.pm.ActivityInfo; +import android.content.pm.ActivityInfo.Config; import android.graphics.drawable.Drawable; import android.os.StrictMode; import android.util.AttributeSet; @@ -252,7 +254,8 @@ public class TypedArray { * @throws RuntimeException if the TypedArray has already been recycled. * @hide */ - public String getNonConfigurationString(@StyleableRes int index, int allowedChangingConfigs) { + public String getNonConfigurationString(@StyleableRes int index, + @Config int allowedChangingConfigs) { if (mRecycled) { throw new RuntimeException("Cannot make calls to a recycled instance!"); } @@ -260,7 +263,9 @@ public class TypedArray { index *= AssetManager.STYLE_NUM_ENTRIES; final int[] data = mData; final int type = data[index+AssetManager.STYLE_TYPE]; - if ((data[index+AssetManager.STYLE_CHANGING_CONFIGURATIONS]&~allowedChangingConfigs) != 0) { + final @Config int changingConfigs = ActivityInfo.activityInfoConfigNativeToJava( + data[index + AssetManager.STYLE_CHANGING_CONFIGURATIONS]); + if ((changingConfigs & ~allowedChangingConfigs) != 0) { return null; } if (type == TypedValue.TYPE_NULL) { @@ -1155,12 +1160,12 @@ public class TypedArray { * @throws RuntimeException if the TypedArray has already been recycled. * @see android.content.pm.ActivityInfo */ - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { if (mRecycled) { throw new RuntimeException("Cannot make calls to a recycled instance!"); } - int changingConfig = 0; + @Config int changingConfig = 0; final int[] data = mData; final int N = length(); @@ -1170,7 +1175,8 @@ public class TypedArray { if (type == TypedValue.TYPE_NULL) { continue; } - changingConfig |= data[index + AssetManager.STYLE_CHANGING_CONFIGURATIONS]; + changingConfig |= ActivityInfo.activityInfoConfigNativeToJava( + data[index + AssetManager.STYLE_CHANGING_CONFIGURATIONS]); } return changingConfig; } @@ -1185,7 +1191,8 @@ public class TypedArray { outValue.data = data[index+AssetManager.STYLE_DATA]; outValue.assetCookie = data[index+AssetManager.STYLE_ASSET_COOKIE]; outValue.resourceId = data[index+AssetManager.STYLE_RESOURCE_ID]; - outValue.changingConfigurations = data[index+AssetManager.STYLE_CHANGING_CONFIGURATIONS]; + outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( + data[index + AssetManager.STYLE_CHANGING_CONFIGURATIONS]); outValue.density = data[index+AssetManager.STYLE_DENSITY]; outValue.string = (type == TypedValue.TYPE_STRING) ? loadStringValueAt(index) : null; return true; diff --git a/core/java/android/util/TypedValue.java b/core/java/android/util/TypedValue.java index 98aaa8149c1ca..bd00aba325ea9 100644 --- a/core/java/android/util/TypedValue.java +++ b/core/java/android/util/TypedValue.java @@ -17,6 +17,7 @@ package android.util; import android.annotation.AnyRes; +import android.content.pm.ActivityInfo.Config; /** * Container for a dynamically typed data value. Primarily used with @@ -183,9 +184,11 @@ public class TypedValue { @AnyRes public int resourceId; - /** If Value came from a resource, these are the configurations for which - * its contents can change. */ - public int changingConfigurations = -1; + /** + * If the value came from a resource, these are the configurations for + * which its contents can change. + */ + public @Config int changingConfigurations = -1; /** * If the Value came from a resource, this holds the corresponding pixel density. diff --git a/core/java/android/view/animation/BaseInterpolator.java b/core/java/android/view/animation/BaseInterpolator.java index 9c0014c951c36..a78fa1eac0399 100644 --- a/core/java/android/view/animation/BaseInterpolator.java +++ b/core/java/android/view/animation/BaseInterpolator.java @@ -16,22 +16,24 @@ package android.view.animation; +import android.content.pm.ActivityInfo.Config; + /** * An abstract class which is extended by default interpolators. */ abstract public class BaseInterpolator implements Interpolator { - private int mChangingConfiguration; + private @Config int mChangingConfiguration; /** * @hide */ - public int getChangingConfiguration() { + public @Config int getChangingConfiguration() { return mChangingConfiguration; } /** * @hide */ - void setChangingConfiguration(int changingConfiguration) { + void setChangingConfiguration(@Config int changingConfiguration) { mChangingConfiguration = changingConfiguration; } } diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java index 39ea2054ce6bf..437ebaab7fd74 100644 --- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java @@ -27,6 +27,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityThread; import android.app.Application; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -230,7 +231,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mAnimatedVectorState.getChangingConfigurations(); } @@ -449,7 +450,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 { } private static class AnimatedVectorDrawableState extends ConstantState { - int mChangingConfigurations; + @Config int mChangingConfigurations; VectorDrawable mVectorDrawable; /** Animators that require a theme before inflation. */ @@ -513,7 +514,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations; } diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index bffbc751ee834..9d8ede0489249 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -17,6 +17,7 @@ package android.graphics.drawable; import android.annotation.NonNull; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -454,7 +455,7 @@ public class BitmapDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mBitmapState.getChangingConfigurations(); } @@ -910,7 +911,7 @@ public class BitmapDrawable extends Drawable { int mTargetDensity = DisplayMetrics.DENSITY_DEFAULT; boolean mAutoMirrored = false; - int mChangingConfigurations; + @Config int mChangingConfigurations; boolean mRebuildShader; BitmapState(Bitmap bitmap) { @@ -958,7 +959,7 @@ public class BitmapDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | (mTint != null ? mTint.getChangingConfigurations() : 0); } diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java index 5ad31f75f20ab..7524cac47491b 100644 --- a/graphics/java/android/graphics/drawable/ColorDrawable.java +++ b/graphics/java/android/graphics/drawable/ColorDrawable.java @@ -18,6 +18,7 @@ package android.graphics.drawable; import android.annotation.ColorInt; import android.annotation.NonNull; +import android.content.pm.ActivityInfo.Config; import android.graphics.*; import android.graphics.PorterDuff.Mode; import android.content.res.ColorStateList; @@ -70,7 +71,7 @@ public class ColorDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mColorState.getChangingConfigurations(); } @@ -292,7 +293,7 @@ public class ColorDrawable extends Drawable { int mBaseColor; // base color, independent of setAlpha() @ViewDebug.ExportedProperty int mUseColor; // basecolor modulated by setAlpha() - int mChangingConfigurations; + @Config int mChangingConfigurations; ColorStateList mTint = null; Mode mTintMode = DEFAULT_TINT_MODE; @@ -326,7 +327,7 @@ public class ColorDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | (mTint != null ? mTint.getChangingConfigurations() : 0); } diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index f106c680bbc85..3915984475732 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -19,6 +19,7 @@ package android.graphics.drawable; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -134,7 +135,7 @@ public abstract class Drawable { private int[] mStateSet = StateSet.WILD_CARD; private int mLevel = 0; - private int mChangingConfigurations = 0; + private @Config int mChangingConfigurations = 0; private Rect mBounds = ZERO_BOUNDS_RECT; // lazily becomes a new Rect() private WeakReference mCallback = null; private boolean mVisible = true; @@ -249,7 +250,7 @@ public abstract class Drawable { * * @see android.content.pm.ActivityInfo */ - public void setChangingConfigurations(int configs) { + public void setChangingConfigurations(@Config int configs) { mChangingConfigurations = configs; } @@ -266,7 +267,7 @@ public abstract class Drawable { * * @see android.content.pm.ActivityInfo */ - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations; } @@ -1294,7 +1295,7 @@ public abstract class Drawable { * Return a bit mask of configuration changes that will impact * this drawable (and thus require completely reloading it). */ - public abstract int getChangingConfigurations(); + public abstract @Config int getChangingConfigurations(); /** * @return Total pixel count diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index a91d1f0ac7809..42f48633eacb5 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -17,6 +17,7 @@ package android.graphics.drawable; import android.annotation.NonNull; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -87,7 +88,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mDrawableContainerState.getChangingConfigurations(); } @@ -649,8 +650,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { Resources mSourceRes; int mDensity = DisplayMetrics.DENSITY_DEFAULT; - int mChangingConfigurations; - int mChildrenChangingConfigurations; + @Config int mChangingConfigurations; + @Config int mChildrenChangingConfigurations; SparseArray mDrawableFutures; Drawable[] mDrawables; @@ -781,7 +782,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | mChildrenChangingConfigurations; } diff --git a/graphics/java/android/graphics/drawable/DrawableWrapper.java b/graphics/java/android/graphics/drawable/DrawableWrapper.java index 4df2d57f25745..5abfc54bfce3d 100644 --- a/graphics/java/android/graphics/drawable/DrawableWrapper.java +++ b/graphics/java/android/graphics/drawable/DrawableWrapper.java @@ -23,6 +23,7 @@ import org.xmlpull.v1.XmlPullParserException; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -229,7 +230,7 @@ public abstract class DrawableWrapper extends Drawable implements Drawable.Callb } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | (mState != null ? mState.getChangingConfigurations() : 0) | mDrawable.getChangingConfigurations(); @@ -444,7 +445,7 @@ public abstract class DrawableWrapper extends Drawable implements Drawable.Callb abstract static class DrawableWrapperState extends Drawable.ConstantState { private int[] mThemeAttrs; - int mChangingConfigurations; + @Config int mChangingConfigurations; int mDensity = DisplayMetrics.DENSITY_DEFAULT; Drawable.ConstantState mDrawableState; @@ -524,7 +525,7 @@ public abstract class DrawableWrapper extends Drawable implements Drawable.Callb public abstract Drawable newDrawable(@Nullable Resources res); @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | (mDrawableState != null ? mDrawableState.getChangingConfigurations() : 0); } diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 7b1e62a6390de..bcc354c5b7366 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -20,6 +20,7 @@ import android.annotation.ColorInt; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -958,7 +959,7 @@ public class GradientDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mGradientState.getChangingConfigurations(); } @@ -1734,7 +1735,7 @@ public class GradientDrawable extends Drawable { } final static class GradientState extends ConstantState { - public int mChangingConfigurations; + public @Config int mChangingConfigurations; public @Shape int mShape = RECTANGLE; public @GradientType int mGradient = LINEAR_GRADIENT; public int mAngle = 0; @@ -1962,7 +1963,7 @@ public class GradientDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | (mStrokeColors != null ? mStrokeColors.getChangingConfigurations() : 0) | (mSolidColors != null ? mSolidColors.getChangingConfigurations() : 0) diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java index d142f9502d913..8417a406f0b09 100644 --- a/graphics/java/android/graphics/drawable/LayerDrawable.java +++ b/graphics/java/android/graphics/drawable/LayerDrawable.java @@ -18,6 +18,7 @@ package android.graphics.drawable; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -971,7 +972,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mLayerState.getChangingConfigurations(); } @@ -1864,8 +1865,8 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { int mPaddingEnd = -1; int mOpacityOverride = PixelFormat.UNKNOWN; - int mChangingConfigurations; - int mChildrenChangingConfigurations; + @Config int mChangingConfigurations; + @Config int mChildrenChangingConfigurations; private boolean mHaveOpacity; private int mOpacity; @@ -1989,7 +1990,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | mChildrenChangingConfigurations; } diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java index 681653967aa1e..fd3b9b47fe1a6 100644 --- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java +++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java @@ -18,6 +18,7 @@ package android.graphics.drawable; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -260,7 +261,7 @@ public class NinePatchDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mNinePatchState.getChangingConfigurations(); } @@ -575,7 +576,7 @@ public class NinePatchDrawable extends Drawable { } final static class NinePatchState extends ConstantState { - int mChangingConfigurations; + @Config int mChangingConfigurations; // Values loaded during inflation. NinePatch mNinePatch = null; @@ -651,7 +652,7 @@ public class NinePatchDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | (mTint != null ? mTint.getChangingConfigurations() : 0); } diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index ee0861ae60f5a..caf2e7a4cb4cb 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -23,6 +23,7 @@ import org.xmlpull.v1.XmlPullParserException; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -1033,7 +1034,7 @@ public class RippleDrawable extends LayerDrawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | (mColor != null ? mColor.getChangingConfigurations() : 0); } diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index 30b588e1b4b73..fe82a93cf5b52 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -16,6 +16,7 @@ package android.graphics.drawable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; @@ -260,7 +261,7 @@ public class ShapeDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mShapeState.getChangingConfigurations(); } @@ -526,7 +527,7 @@ public class ShapeDrawable extends Drawable { */ final static class ShapeState extends ConstantState { int[] mThemeAttrs; - int mChangingConfigurations; + @Config int mChangingConfigurations; Paint mPaint; Shape mShape; ColorStateList mTint = null; @@ -571,7 +572,7 @@ public class ShapeDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | (mTint != null ? mTint.getChangingConfigurations() : 0); } diff --git a/graphics/java/android/graphics/drawable/TransitionDrawable.java b/graphics/java/android/graphics/drawable/TransitionDrawable.java index e5c235efaba53..0122338a7255e 100644 --- a/graphics/java/android/graphics/drawable/TransitionDrawable.java +++ b/graphics/java/android/graphics/drawable/TransitionDrawable.java @@ -16,6 +16,7 @@ package android.graphics.drawable; +import android.content.pm.ActivityInfo.Config; import android.content.res.Resources; import android.graphics.Canvas; import android.os.SystemClock; @@ -259,7 +260,7 @@ public class TransitionDrawable extends LayerDrawable implements Drawable.Callba } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations; } } diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index 44a91fefc4a0a..ae98c22dd4b00 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -16,6 +16,7 @@ package android.graphics.drawable; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.ComplexColor; import android.content.res.GradientColor; @@ -686,7 +687,7 @@ public class VectorDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return super.getChangingConfigurations() | mVectorState.getChangingConfigurations(); } @@ -714,7 +715,7 @@ public class VectorDrawable extends Drawable { static class VectorDrawableState extends ConstantState { // Variables below need to be copied (deep copy if applicable) for mutation. int[] mThemeAttrs; - int mChangingConfigurations; + @Config int mChangingConfigurations; ColorStateList mTint = null; Mode mTintMode = DEFAULT_TINT_MODE; boolean mAutoMirrored; @@ -823,7 +824,7 @@ public class VectorDrawable extends Drawable { } @Override - public int getChangingConfigurations() { + public @Config int getChangingConfigurations() { return mChangingConfigurations | (mTint != null ? mTint.getChangingConfigurations() : 0); } @@ -923,7 +924,7 @@ public class VectorDrawable extends Drawable { // mLocalMatrix is updated based on the update of transformation information, // either parsed from the XML or by animation. - private int mChangingConfigurations; + private @Config int mChangingConfigurations; private int[] mThemeAttrs; private String mGroupName = null; @@ -1169,7 +1170,7 @@ public class VectorDrawable extends Drawable { protected PathParser.PathData mPathData = null; String mPathName; - int mChangingConfigurations; + @Config int mChangingConfigurations; public VPath() { // Empty constructor.