Merge "Fixed a bug with decorated custom views" into oc-mr1-dev

am: 9d41e8cd47

Change-Id: I36099788ad09bb8035374c2ca27caffabc21dfb0
This commit is contained in:
Selim Cinek
2017-08-22 23:20:24 +00:00
committed by android-build-merger
4 changed files with 62 additions and 13 deletions

View File

@@ -6951,6 +6951,7 @@ public class Notification implements Parcelable
customContent = customContent.clone();
remoteViews.removeAllViewsExceptId(R.id.notification_main_column, R.id.progress);
remoteViews.addView(R.id.notification_main_column, customContent, 0 /* index */);
remoteViews.setReapplyDisallowed();
}
// also update the end margin if there is an image
int endMargin = R.dimen.notification_content_margin_end;
@@ -7057,6 +7058,7 @@ public class Notification implements Parcelable
customContent = customContent.clone();
remoteViews.removeAllViews(id);
remoteViews.addView(id, customContent);
remoteViews.setReapplyDisallowed();
}
return remoteViews;
}

View File

@@ -153,6 +153,12 @@ public class RemoteViews implements Parcelable, Filter {
*/
private boolean mIsRoot = true;
/**
* Whether reapply is disallowed on this remoteview. This maybe be true if some actions modify
* the layout in a way that isn't recoverable, since views are being removed.
*/
private boolean mReapplyDisallowed;
/**
* Constants to whether or not this RemoteViews is composed of a landscape and portrait
* RemoteViews.
@@ -214,6 +220,26 @@ public class RemoteViews implements Parcelable, Filter {
}
}
/**
* Set that it is disallowed to reapply another remoteview with the same layout as this view.
* This should be done if an action is destroying the view tree of the base layout.
*
* @hide
*/
public void setReapplyDisallowed() {
mReapplyDisallowed = true;
}
/**
* @return Whether it is disallowed to reapply another remoteview with the same layout as this
* view. True if this remoteview has actions that destroyed view tree of the base layout.
*
* @hide
*/
public boolean isReapplyDisallowed() {
return mReapplyDisallowed;
}
/**
* Handle with care!
*/
@@ -2429,6 +2455,7 @@ public class RemoteViews implements Parcelable, Filter {
mApplication = mPortrait.mApplication;
mLayoutId = mPortrait.getLayoutId();
}
mReapplyDisallowed = parcel.readInt() == 0;
// setup the memory usage statistics
mMemoryUsageCounter = new MemoryUsageCounter();
@@ -3738,6 +3765,7 @@ public class RemoteViews implements Parcelable, Filter {
// Both RemoteViews already share the same package and user
mPortrait.writeToParcel(dest, flags | PARCELABLE_ELIDE_DUPLICATES);
}
dest.writeInt(mReapplyDisallowed ? 1 : 0);
}
private static ApplicationInfo getApplicationInfo(String packageName, int userId) {