Merge changes from topic "mkephart-clipboard-share-intent" into udc-qpr-dev am: 194cce357f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23767803 Change-Id: I60892ff4a89d1e2d264cb1f9dd51abe93ccf1698 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.clipboardoverlay;
|
package com.android.systemui.clipboardoverlay;
|
||||||
|
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipDescription;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -41,10 +42,16 @@ class IntentCreator {
|
|||||||
// From the ACTION_SEND docs:
|
// From the ACTION_SEND docs:
|
||||||
// "If using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it should be the
|
// "If using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it should be the
|
||||||
// MIME type of the data in EXTRA_STREAM"
|
// MIME type of the data in EXTRA_STREAM"
|
||||||
if (clipData.getItemAt(0).getUri() != null) {
|
Uri uri = clipData.getItemAt(0).getUri();
|
||||||
shareIntent.setDataAndType(
|
if (uri != null) {
|
||||||
clipData.getItemAt(0).getUri(), clipData.getDescription().getMimeType(0));
|
// We don't use setData here because some apps interpret this as "to:".
|
||||||
shareIntent.putExtra(Intent.EXTRA_STREAM, clipData.getItemAt(0).getUri());
|
shareIntent.setType(clipData.getDescription().getMimeType(0));
|
||||||
|
// Include URI in ClipData also, so that grantPermission picks it up.
|
||||||
|
shareIntent.setClipData(new ClipData(
|
||||||
|
new ClipDescription(
|
||||||
|
"content", new String[]{clipData.getDescription().getMimeType(0)}),
|
||||||
|
new ClipData.Item(uri)));
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
} else {
|
} else {
|
||||||
shareIntent.putExtra(
|
shareIntent.putExtra(
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ public class IntentCreatorTest extends SysuiTestCase {
|
|||||||
assertEquals(Intent.ACTION_CHOOSER, intent.getAction());
|
assertEquals(Intent.ACTION_CHOOSER, intent.getAction());
|
||||||
assertFlags(intent, EXTERNAL_INTENT_FLAGS);
|
assertFlags(intent, EXTERNAL_INTENT_FLAGS);
|
||||||
Intent target = intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent.class);
|
Intent target = intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent.class);
|
||||||
assertEquals(uri, target.getData());
|
assertEquals(uri, target.getParcelableExtra(Intent.EXTRA_STREAM, Uri.class));
|
||||||
|
assertEquals(uri, target.getClipData().getItemAt(0).getUri());
|
||||||
assertEquals("image/png", target.getType());
|
assertEquals("image/png", target.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user