Merge "Ensure all Java-side usages of config flags are using Java flags" into nyc-dev

This commit is contained in:
Alan Viverette
2016-03-14 15:01:50 +00:00
committed by Android (Google) Code Review
28 changed files with 219 additions and 121 deletions

View File

@@ -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<Animator> {
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;
}

View File

@@ -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;

View File

@@ -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<View> 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;
}

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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, Comparable<Configuration
*/
public int seq;
/** @hide */
@IntDef(flag = true,
value = {
NATIVE_CONFIG_MCC,
NATIVE_CONFIG_MNC,
NATIVE_CONFIG_LOCALE,
NATIVE_CONFIG_TOUCHSCREEN,
NATIVE_CONFIG_KEYBOARD,
NATIVE_CONFIG_KEYBOARD_HIDDEN,
NATIVE_CONFIG_NAVIGATION,
NATIVE_CONFIG_ORIENTATION,
NATIVE_CONFIG_DENSITY,
NATIVE_CONFIG_SCREEN_SIZE,
NATIVE_CONFIG_VERSION,
NATIVE_CONFIG_SCREEN_LAYOUT,
NATIVE_CONFIG_UI_MODE,
NATIVE_CONFIG_SMALLEST_SCREEN_SIZE,
NATIVE_CONFIG_LAYOUTDIR,
})
@Retention(RetentionPolicy.SOURCE)
public @interface NativeConfig {}
/** @hide Native-specific bit mask for MCC config; DO NOT USE UNLESS YOU ARE SURE. */
public static final int NATIVE_CONFIG_MCC = 0x0001;
/** @hide Native-specific bit mask for MNC config; DO NOT USE UNLESS YOU ARE SURE. */
@@ -917,14 +944,13 @@ public final class Configuration implements Parcelable, Comparable<Configuration
}
/**
* Copy the fields from delta into this Configuration object, keeping
* track of which ones have changed. Any undefined fields in
* <var>delta</var> 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<Configuration
}
/**
* Determine if a new resource needs to be loaded from the bit set of
* Determines if a new resource needs to be loaded from the bit set of
* configuration changes returned by {@link #updateFrom(Configuration)}.
*
* @param configChanges The mask of changes configurations as returned by
* {@link #updateFrom(Configuration)}.
* @param interestingChanges The configuration changes that the resource
* can handled, as given in {@link android.util.TypedValue#changingConfigurations}.
*
* @return Return true if the resource needs to be loaded, else false.
* @param configChanges the mask of changes configurations as returned by
* {@link #updateFrom(Configuration)}
* @param interestingChanges the configuration changes that the resource
* can handle as given in
* {@link android.util.TypedValue#changingConfigurations}
* @return {@code true} if the resource needs to be loaded, {@code false}
* otherwise
*/
public static boolean needNewResources(int configChanges, int interestingChanges) {
public static boolean needNewResources(@Config int configChanges,
@Config int interestingChanges) {
return (configChanges & (interestingChanges|ActivityInfo.CONFIG_FONT_SCALE)) != 0;
}

View File

@@ -16,6 +16,8 @@
package android.content.res;
import android.content.pm.ActivityInfo.Config;
/**
* A Cache class which can be used to cache resource objects that are easy to clone but more
* expensive to inflate.
@@ -42,7 +44,7 @@ public class ConfigurationBoundResourceCache<T> extends ThemedResourceCache<Cons
}
@Override
public boolean shouldInvalidateEntry(ConstantState<T> entry, int configChanges) {
public boolean shouldInvalidateEntry(ConstantState<T> entry, @Config int configChanges) {
return Configuration.needNewResources(configChanges, entry.getChangingConfigurations());
}
}

View File

@@ -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<T> {
* 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

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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<T> {
*
* @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<T> {
* 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<T> {
}
private boolean pruneEntriesLocked(@Nullable LongSparseArray<WeakReference<T>> entries,
int configChanges) {
@Config int configChanges) {
if (entries == null) {
return true;
}
@@ -226,7 +227,7 @@ abstract class ThemedResourceCache<T> {
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));
}

View File

@@ -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;

View File

@@ -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.

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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<Callback> 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

View File

@@ -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<ConstantState> 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;
}

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -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.