summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorWillie Koomson <wvk@google.com>2022-01-12 22:08:26 +0000
committerWillie Koomson <wvk@google.com>2022-01-27 22:43:45 +0000
commit35641ae2c08a764d9480d65e4081b22473379bc4 (patch)
treecf1de5ccb74513f4b3e1ec061d058832a64aef4e /core/java/android/widget/RemoteViews.java
parent3a83f0e9a9f6be24076104faadc48b7be4ea4ed7 (diff)
Propagate apply flags to nested RemoteViews
This change propagates FLAG_WIDGET_IS_COLLECTION_CHILD and FLAG_USE_LIGHT_BACKGROUND_LAYOUT to nested RemoteViews (either added by addView, or set as portrait/landscape/sized RemoteViews) if that flag is also present on the parent RemoteView. For FLAG_WIDGET_IS_COLLECTION_CHILD, this prevents a PendingIntent from being set on a RemoteView that is a child of a collection item RemoteView. For FLAG_USE_LIGHT_BACKGROUND_LAYOUT, this ensures that nested RemoteViews use their light background layout if this is set on the parent. Bug: 214288099 Test: RemoteViewsTest Change-Id: I8da92d0d338631a99ee718a136bf9674827437bb
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 191962df9292..b00a3829f468 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -301,6 +301,13 @@ public class RemoteViews implements Parcelable, Filter {
public static final int FLAG_USE_LIGHT_BACKGROUND_LAYOUT = 4;
/**
+ * This mask determines which flags are propagated to nested RemoteViews (either added by
+ * addView, or set as portrait/landscape/sized RemoteViews).
+ */
+ static final int FLAG_MASK_TO_PROPAGATE =
+ FLAG_WIDGET_IS_COLLECTION_CHILD | FLAG_USE_LIGHT_BACKGROUND_LAYOUT;
+
+ /**
* A ReadWriteHelper which has the same behavior as ReadWriteHelper.DEFAULT, but which is
* intentionally a different instance in order to trick Bundle reader so that it doesn't allow
* lazy initialization.
@@ -467,6 +474,18 @@ public class RemoteViews implements Parcelable, Filter {
*/
public void addFlags(@ApplyFlags int flags) {
mApplyFlags = mApplyFlags | flags;
+
+ int flagsToPropagate = flags & FLAG_MASK_TO_PROPAGATE;
+ if (flagsToPropagate != 0) {
+ if (hasSizedRemoteViews()) {
+ for (RemoteViews remoteView : mSizedRemoteViews) {
+ remoteView.addFlags(flagsToPropagate);
+ }
+ } else if (hasLandscapeAndPortraitLayouts()) {
+ mLandscape.addFlags(flagsToPropagate);
+ mPortrait.addFlags(flagsToPropagate);
+ }
+ }
}
/**
@@ -2407,6 +2426,10 @@ public class RemoteViews implements Parcelable, Filter {
// will return -1.
final int nextChild = getNextRecyclableChild(target);
RemoteViews rvToApply = mNestedViews.getRemoteViewsToApply(context);
+
+ int flagsToPropagate = mApplyFlags & FLAG_MASK_TO_PROPAGATE;
+ if (flagsToPropagate != 0) rvToApply.addFlags(flagsToPropagate);
+
if (nextChild >= 0 && mStableId != NO_ID) {
// At that point, the views starting at index nextChild are the ones recyclable but
// not yet recycled. All views added on that round of application are placed before.