diff options
| author | 2016-04-13 14:03:24 -0700 | |
|---|---|---|
| committer | 2016-04-13 14:19:50 -0700 | |
| commit | 3c987600aa7a1ae2f920f96e09d32862f824d52d (patch) | |
| tree | 9d8873d9e0494cba78248a5a51b49abef31fdd7d | |
| parent | 11aade9f6e82844d494c43a5ad0bbae87cbf9601 (diff) | |
Guard against null clipdata objects.
Bug: 28074897
Change-Id: I7f0e520d6f1ce40e6db2fbead21ee4bb37aa3a61
| -rw-r--r-- | packages/DocumentsUI/src/com/android/documentsui/DocumentClipper.java | 4 | ||||
| -rw-r--r-- | packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentClipper.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentClipper.java index 15bfc3b93087..059b5e09cc90 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentClipper.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentClipper.java @@ -32,6 +32,7 @@ import com.android.documentsui.model.DocumentInfo; import libcore.io.IoUtils; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -76,7 +77,8 @@ public final class DocumentClipper { * This should be run from inside an AsyncTask. */ public List<DocumentInfo> getClippedDocuments() { - return getDocumentsFromClipData(mClipboard.getPrimaryClip()); + ClipData data = mClipboard.getPrimaryClip(); + return data == null ? Collections.EMPTY_LIST : getDocumentsFromClipData(data); } /** diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java index fba25abc206a..fd862a216544 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java @@ -1176,14 +1176,23 @@ public class DirectoryFragment extends Fragment case DragEvent.ACTION_DROP: // After a drop event, always stop highlighting the target. setDropTargetHighlight(v, false); + + ClipData clipData = event.getClipData(); + if (clipData == null) { + Log.w(TAG, "Received invalid drop event with null clipdata. Ignoring."); + return false; + } + // Don't copy from the cwd into the cwd. Note: this currently doesn't work for // multi-window drag, because localState isn't carried over from one process to // another. Object src = event.getLocalState(); DocumentInfo dst = getDestination(v); if (Objects.equals(src, dst)) { + if (DEBUG) Log.d(TAG, "Drop target same as source. Ignoring."); return false; } + // Recognize multi-window drag and drop based on the fact that localState is not // carried between processes. It will stop working when the localsState behavior // is changed. The info about window should be passed in the localState then. @@ -1192,7 +1201,8 @@ public class DirectoryFragment extends Fragment Metrics.logUserAction(getContext(), src == null ? Metrics.USER_ACTION_DRAG_N_DROP_MULTI_WINDOW : Metrics.USER_ACTION_DRAG_N_DROP); - copyFromClipData(event.getClipData(), dst); + + copyFromClipData(clipData, dst); return true; } return false; |