Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b143ff6b authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev
Browse files

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
parent e244fd33
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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.