summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2019-02-07 08:36:54 -0800
committerGeorge Mount <mount@google.com>2019-02-07 22:15:58 +0000
commit3843288297149fa3f4ce9030adf1dcedbbce0f0f (patch)
tree542a83f7ea2faf8eacc36f72bb82a2d7ebb13846 /core/java/android
parent23f34cd61f5569927c746090a626e05f740cb2ae (diff)
Remove access to private field mFactorySet.
Fixes: 123769585 Test: compiled framework mFactorySet is being modified by app developers to reset the factory on an existing LayoutInflater. Instead, a developer should use LayoutInflater#cloneInContext() to create a new LayoutInflater and set the factory on it instead. This is often desired at the Activity level, so that any part of the application getting a LayoutInflater using the Activity as a Context will get the LayoutInflater with a custom factory. To do this, the Activity has to replace the returned LayoutInflater. Something like this should work: private LayoutInflater mLayoutInflater; @Override public Object getSystemService(String name) { if (Context.LAYOUT_INFLATER_SERVICE.equals(name)) { if (mLayoutInflater == null) { mLayoutInflater = ((LayoutInflater)super.getSystemService(name)).cloneInContext(this); mLayoutInflater.setFactory(new CustomLayoutFactory()); } return mLayoutInflater; } return super.getSystemService(name); } Change-Id: I155ea9538c5783b32301252fb3fb9baa1cc92036
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/LayoutInflater.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index 6a290b7fe045..8685046949ec 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -93,7 +93,12 @@ public abstract class LayoutInflater {
protected final Context mContext;
// these are optional, set by the caller
- @UnsupportedAppUsage
+ /**
+ * If any developer has desire to change this value, they should instead use
+ * {@link #cloneInContext(Context)} and set the new factory in thew newly-created
+ * LayoutInflater.
+ */
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
private boolean mFactorySet;
@UnsupportedAppUsage
private Factory mFactory;