summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorGreg Kaiser <gkaiser@google.com>2021-03-18 13:34:57 -0700
committerGreg Kaiser <gkaiser@google.com>2021-03-18 15:28:46 -0700
commitb96f77af78e5a18ef7ee56bb932ae91f6505dbfd (patch)
tree11def238a5f2aeeb6d2df6a5935a4481404a16bf /core/java/android/widget/RemoteViews.java
parent5230666bb7552f4545f20e99875016574ddaf416 (diff)
Revert "Correct recycling to take setViewId into account."
This reverts commit 308a272289cafedbb72bc7f5310ac54d50502ae7. Bug: 183104573 Test: Install from Play Store with the screen off on wembley, and the device doesn't crash when the screen turns back on. Change-Id: I289fcafc6685c4ede295e8d6916a54da9bac1ad5
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java17
1 files changed, 4 insertions, 13 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 0cedcea7b4d4..2b73923fc5f4 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -2196,7 +2196,7 @@ public class RemoteViews implements Parcelable, Filter {
int recycledViewIndex = findViewIndexToRecycle(target, rvToApply);
if (recycledViewIndex >= 0) {
View child = target.getChildAt(recycledViewIndex);
- if (rvToApply.canRecycleView(child)) {
+ if (getViewLayoutId(child) == rvToApply.getLayoutId()) {
if (nextChild < recycledViewIndex) {
target.removeViews(nextChild, recycledViewIndex - nextChild);
}
@@ -2254,7 +2254,7 @@ public class RemoteViews implements Parcelable, Filter {
// application are placed before.
ViewTree recycled = target.mChildren.get(recycledViewIndex);
// We can only recycle the view if the layout id is the same.
- if (rvToApply.canRecycleView(recycled.mRoot)) {
+ if (getViewLayoutId(recycled.mRoot) == rvToApply.getLayoutId()) {
if (recycledViewIndex > nextChild) {
target.removeChildren(nextChild, recycledViewIndex - nextChild);
}
@@ -3726,8 +3726,7 @@ public class RemoteViews implements Parcelable, Filter {
*
* The {@code stableId} will be used to identify a potential view to recycled when the remote
* view is inflated. Views can be re-used if inserted in the same order, potentially with
- * some views appearing / disappearing. To be recycled the view must not change the layout
- * used to inflate it or its view id (see {@link RemoteViews#setViewId}).
+ * some views appearing / disappearing.
*
* Note: if a view is re-used, all the actions will be re-applied on it. However, its properties
* are not reset, so what was applied in previous round will have an effect. As a view may be
@@ -5117,7 +5116,6 @@ public class RemoteViews implements Parcelable, Filter {
View v = inflater.inflate(rv.getLayoutId(), parent, false);
if (mViewId != View.NO_ID) {
v.setId(mViewId);
- v.setTagInternal(R.id.remote_views_override_id, mViewId);
}
v.setTagInternal(R.id.widget_frame, rv.getLayoutId());
return v;
@@ -5337,13 +5335,6 @@ public class RemoteViews implements Parcelable, Filter {
reapply(context, v, handler, size, colorResources, true);
}
- /** @hide */
- public boolean canRecycleView(View v) {
- Integer overrideIdTag = (Integer) v.getTag(R.id.remote_views_override_id);
- int overrideId = overrideIdTag == null ? View.NO_ID : overrideIdTag;
- return (Integer) v.getTag(R.id.widget_frame) == getLayoutId() && mViewId == overrideId;
- }
-
// Note: topLevel should be true only for calls on the topLevel RemoteViews, internal calls
// should set it to false.
private void reapply(Context context, View v, InteractionHandler handler, SizeF size,
@@ -5356,7 +5347,7 @@ public class RemoteViews implements Parcelable, Filter {
// (orientation or size), we throw an exception, since the layouts may be completely
// unrelated.
if (hasMultipleLayouts()) {
- if (!rvToApply.canRecycleView(v)) {
+ if ((Integer) v.getTag(R.id.widget_frame) != rvToApply.getLayoutId()) {
throw new RuntimeException("Attempting to re-apply RemoteViews to a view that" +
" that does not share the same root layout id.");
}