Let ViewStub be used in RemoteViews.
Specifically, this carefully ensures that ViewStub.inflate() uses
the restricted LayoutInflater from RemoteViews, which has a filter
to enforce the @RemoteView annotation.
Bug: 2541651
Change-Id: I341aacbf6029cdd717a894eb084760c6ec224786
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index 3c0ee12..26a5b26 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -583,7 +583,14 @@
Object[] args = mConstructorArgs;
args[1] = attrs;
- return constructor.newInstance(args);
+
+ final View view = constructor.newInstance(args);
+ if (view instanceof ViewStub) {
+ // always use ourselves when inflating ViewStub later
+ final ViewStub viewStub = (ViewStub) view;
+ viewStub.setLayoutInflater(this);
+ }
+ return view;
} catch (NoSuchMethodException e) {
InflateException ie = new InflateException(attrs.getPositionDescription()