From d07dca11abb496b2ad8edff70327c277ecfa05bd Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Sat, 26 Jun 2021 00:01:41 -0700 Subject: Only provide the resolved activity info to the global intercept window - Previously we were adding the activity info to the ClipData, but that data is provided to non-intercept windows when the drop happens and can be retrieved using reflection. The intention was only to provide this activity info to the shell global intercept window for invoking split. Instead of baking the info into the ClipData, we pass the resolved info along side the data and only construct a ClipData with the additional info for the intercept window. Fixes: 191057499 Test: atest DragDropControllerTests Change-Id: I2ccc9f1f666ff2a388f22b6e6a7b5eea3102964c --- core/java/android/content/ClipData.java | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'core/java/android/content/ClipData.java') diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java index 54b39bd215bf..0bc459a19e7d 100644 --- a/core/java/android/content/ClipData.java +++ b/core/java/android/content/ClipData.java @@ -179,6 +179,10 @@ public class ClipData implements Parcelable { final ArrayList mItems; + // This is false by default unless the ClipData is obtained via + // {@link #copyForTransferWithActivityInfo}. + private boolean mParcelItemActivityInfos; + /** * Description of a single item in a ClipData. * @@ -204,9 +208,11 @@ public class ClipData implements Parcelable { final Intent mIntent; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) Uri mUri; - // Additional activity info resolved by the system - ActivityInfo mActivityInfo; private TextLinks mTextLinks; + // Additional activity info resolved by the system. This is only parceled with the ClipData + // if the data is obtained from {@link #copyForTransferWithActivityInfo} + private ActivityInfo mActivityInfo; + /** @hide */ public Item(Item other) { @@ -214,6 +220,8 @@ public class ClipData implements Parcelable { mHtmlText = other.mHtmlText; mIntent = other.mIntent; mUri = other.mUri; + mActivityInfo = other.mActivityInfo; + mTextLinks = other.mTextLinks; } /** @@ -816,6 +824,24 @@ public class ClipData implements Parcelable { mItems = new ArrayList(other.mItems); } + /** + * Returns a copy of the ClipData which will parcel the Item's activity infos. + * @hide + */ + public ClipData copyForTransferWithActivityInfo() { + ClipData copy = new ClipData(this); + copy.mParcelItemActivityInfos = true; + return copy; + } + + /** + * Returns whether this clip data will parcel the Item's activity infos. + * @hide + */ + public boolean willParcelWithActivityInfo() { + return mParcelItemActivityInfos; + } + /** * Create a new ClipData holding data of the type * {@link ClipDescription#MIMETYPE_TEXT_PLAIN}. @@ -1208,7 +1234,7 @@ public class ClipData implements Parcelable { dest.writeString8(item.mHtmlText); dest.writeTypedObject(item.mIntent, flags); dest.writeTypedObject(item.mUri, flags); - dest.writeTypedObject(item.mActivityInfo, flags); + dest.writeTypedObject(mParcelItemActivityInfos ? item.mActivityInfo : null, flags); dest.writeTypedObject(item.mTextLinks, flags); } } -- cgit v1.2.3