diff options
2 files changed, 6 insertions, 4 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java index a62dd1c83520..4df9ae4b2ee3 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java @@ -107,8 +107,11 @@ public class DragUtils { /** * Returns a list of the mime types provided in the clip description. */ - public static String getMimeTypesConcatenated(ClipDescription description) { + public static String getMimeTypesConcatenated(@Nullable ClipDescription description) { String mimeTypes = ""; + if (description == null) { + return mimeTypes; + } for (int i = 0; i < description.getMimeTypeCount(); i++) { if (i > 0) { mimeTypes += ", "; diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropControllerTest.java index 32bb8bbdbbe3..1b1a5a909220 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropControllerTest.java @@ -152,17 +152,16 @@ public class DragAndDropControllerTest extends ShellTestCase { } @Test - public void testOnDragStarted_withNoClipData() { + public void testOnDragStarted_withNoClipDataOrDescription() { final View dragLayout = mock(View.class); final Display display = mock(Display.class); doReturn(display).when(dragLayout).getDisplay(); doReturn(DEFAULT_DISPLAY).when(display).getDisplayId(); - final ClipData clipData = createAppClipData(MIMETYPE_APPLICATION_SHORTCUT); final DragEvent event = mock(DragEvent.class); doReturn(ACTION_DRAG_STARTED).when(event).getAction(); doReturn(null).when(event).getClipData(); - doReturn(clipData.getDescription()).when(event).getClipDescription(); + doReturn(null).when(event).getClipDescription(); // Ensure there's a target so that onDrag will execute mController.addDisplayDropTarget(0, mContext, mock(WindowManager.class), |