diff options
| author | Winson Chung <winsonc@google.com> | 2021-06-26 00:01:41 -0700 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2021-07-01 17:32:18 +0000 |
| commit | d07dca11abb496b2ad8edff70327c277ecfa05bd (patch) | |
| tree | d8ad6d59db60121a9aa656ebfb681f40c0534f34 /core/java/android/content/ClipData.java | |
| parent | 598c5fd593b8f8205f6a88661ce105ad05be6bba (diff) | |
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
Diffstat (limited to 'core/java/android/content/ClipData.java')
| -rw-r--r-- | core/java/android/content/ClipData.java | 32 |
1 files changed, 29 insertions, 3 deletions
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<Item> 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; } /** @@ -817,6 +825,24 @@ public class ClipData implements Parcelable { } /** + * 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); } } |
