diff options
| author | 2015-12-17 16:38:42 +0000 | |
|---|---|---|
| committer | 2015-12-17 16:38:42 +0000 | |
| commit | ad217b68f8bfc993984fb0ceea4bae149bc46157 (patch) | |
| tree | c6438594634eda327115bcca60af482abeae7d9a | |
| parent | aa4f800891e801e78cc4a0a9839fc59938cabdd3 (diff) | |
| parent | 713a5cdb5347afa6556385f81ba972e1773f8e8f (diff) | |
Merge "Don't call public non-final getResources() from getAssets()"
| -rw-r--r-- | core/java/android/content/Context.java | 24 | ||||
| -rw-r--r-- | core/java/android/content/ContextWrapper.java | 3 | ||||
| -rw-r--r-- | core/java/android/view/ContextThemeWrapper.java | 7 |
3 files changed, 28 insertions, 6 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 38a4475064af..67bdad576af3 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -326,10 +326,30 @@ public abstract class Context { */ public static final int BIND_NOT_VISIBLE = 0x40000000; - /** Return an AssetManager instance for your application's package. */ + /** + * Returns an AssetManager instance for the application's package. + * <p> + * <strong>Note:</strong> Implementations of this method should return + * an AssetManager instance that is consistent with the Resources instance + * returned by {@link #getResources()}. For example, they should share the + * same {@link Configuration} object. + * + * @return an AssetManager instance for the application's package + * @see #getResources() + */ public abstract AssetManager getAssets(); - /** Return a Resources instance for your application's package. */ + /** + * Returns a Resources instance for the application's package. + * <p> + * <strong>Note:</strong> Implementations of this method should return + * a Resources instance that is consistent with the AssetManager instance + * returned by {@link #getAssets()}. For example, they should share the + * same {@link Configuration} object. + * + * @return a Resources instance for the application's package + * @see #getAssets() + */ public abstract Resources getResources(); /** Return PackageManager instance to find global package information. */ diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java index 1a3d262f6b56..c99ddc8fbe11 100644 --- a/core/java/android/content/ContextWrapper.java +++ b/core/java/android/content/ContextWrapper.java @@ -82,8 +82,7 @@ public class ContextWrapper extends Context { } @Override - public Resources getResources() - { + public Resources getResources() { return mBase.getResources(); } diff --git a/core/java/android/view/ContextThemeWrapper.java b/core/java/android/view/ContextThemeWrapper.java index ea0873d6fb1b..4888877cb28b 100644 --- a/core/java/android/view/ContextThemeWrapper.java +++ b/core/java/android/view/ContextThemeWrapper.java @@ -104,11 +104,15 @@ public class ContextThemeWrapper extends ContextWrapper { @Override public AssetManager getAssets() { // Ensure we're returning assets with the correct configuration. - return getResources().getAssets(); + return getResourcesInternal().getAssets(); } @Override public Resources getResources() { + return getResourcesInternal(); + } + + private Resources getResourcesInternal() { if (mResources == null) { if (mOverrideConfiguration == null) { mResources = super.getResources(); @@ -117,7 +121,6 @@ public class ContextThemeWrapper extends ContextWrapper { mResources = resContext.getResources(); } } - return mResources; } |