From b143ff6b6c2d1614e5f5ff06aa2fe19d05cad490 Mon Sep 17 00:00:00 2001 From: Vladislav Kaznacheev Date: Fri, 27 Jan 2017 16:39:13 -0800 Subject: [PATCH] Handle SecurityException in ClipData.Item.coerceToText Catch SecurityException and print a log warning. The most likely reason for such SecurityException is a drag and drop operation with a resource (such as a file) for which the recipient app has no permissions. Bug: 34716083 Test: Drag a file from Files app to Docs, Docs should not crash Change-Id: Ib4ebbb01bd3ca87b221e15fac769368272ff4fc4 --- core/java/android/content/ClipData.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java index 70967712f0687..b39f1e0f47d42 100644 --- a/core/java/android/content/ClipData.java +++ b/core/java/android/content/ClipData.java @@ -353,6 +353,9 @@ public class ClipData implements Parcelable { } return builder.toString(); + } catch (SecurityException e) { + Log.w("ClipData", "Failure opening stream", e); + } catch (FileNotFoundException e) { // Unable to open content URI as text... not really an // error, just something to ignore. @@ -536,6 +539,9 @@ public class ClipData implements Parcelable { return Html.escapeHtml(text); } + } catch (SecurityException e) { + Log.w("ClipData", "Failure opening stream", e); + } catch (FileNotFoundException e) { // Unable to open content URI as text... not really an // error, just something to ignore.