summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2017-06-14 16:54:05 -0400
committerAlan Viverette <alanv@google.com>2017-06-14 17:33:49 -0400
commit0a14ba56a72481fbe949bae70e8fd7421fc8998f (patch)
treec1ce4db5c4d52ecc1d657c46575ede50417ebbbe /core/java/android/widget/RemoteViews.java
parent01762d4f8ed119233b3b61d63f2fc76fd388758f (diff)
Manually merge 23bb5bf262279ab37cfa109091c1bf0ae75e0685 to fix APIs
Also updates documentation for RemoteViews clone to reflect the ISE; however, the implementation is still incorrect and the method should be deprecated and replaced with a copy constructor. Bug: 62576297 Test: make -j32 Change-Id: I72dea99fa45a838d22eb54190a0f26a15e8ba766
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java39
1 files changed, 24 insertions, 15 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index af459855c53d..37961ffc0e66 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -2417,25 +2417,34 @@ public class RemoteViews implements Parcelable, Filter {
recalculateMemoryUsage();
}
+ /**
+ * Returns a deep copy of the RemoteViews object. The RemoteView may not be
+ * attached to another RemoteView -- it must be the root of a hierarchy.
+ *
+ * @throws IllegalStateException if this is not the root of a RemoteView
+ * hierarchy
+ */
+ @Override
+ public RemoteViews clone() {
+ synchronized (this) {
+ Preconditions.checkState(mIsRoot, "RemoteView has been attached to another RemoteView. "
+ + "May only clone the root of a RemoteView hierarchy.");
- public synchronized RemoteViews clone() {
- Preconditions.checkState(mIsRoot, "RemoteView has been attached to another RemoteView. "
- + "May only clone the root of a RemoteView hierarchy.");
-
- Parcel p = Parcel.obtain();
+ Parcel p = Parcel.obtain();
- // Do not parcel the Bitmap cache - doing so creates an expensive copy of all bitmaps.
- // Instead pretend we're not owning the cache while parceling.
- mIsRoot = false;
- writeToParcel(p, PARCELABLE_ELIDE_DUPLICATES);
- p.setDataPosition(0);
- mIsRoot = true;
+ // Do not parcel the Bitmap cache - doing so creates an expensive copy of all bitmaps.
+ // Instead pretend we're not owning the cache while parceling.
+ mIsRoot = false;
+ writeToParcel(p, PARCELABLE_ELIDE_DUPLICATES);
+ p.setDataPosition(0);
+ mIsRoot = true;
- RemoteViews rv = new RemoteViews(p, mBitmapCache.clone(), mApplication, 0);
- rv.mIsRoot = true;
+ RemoteViews rv = new RemoteViews(p, mBitmapCache.clone(), mApplication, 0);
+ rv.mIsRoot = true;
- p.recycle();
- return rv;
+ p.recycle();
+ return rv;
+ }
}
public String getPackage() {