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

Commit a5c249ca authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE due to null clip descriptions" into main

parents c616d8f4 00a6ab64
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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 += ", ";
+2 −3
Original line number Diff line number Diff line
@@ -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),