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

Commit 20ba2657 authored by Jerry Chang's avatar Jerry Chang Committed by Automerger Merge Worker
Browse files

Merge "Fix unable to drag notification to enter split screen" into sc-v2-dev am: cb5907cc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16170303

Change-Id: I396c063fe5576ec0d3755fcf0105abf676d91ef2
parents 303e2eaa cb5907cc
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.ClipDescription;
import android.content.pm.ActivityInfo;
import android.view.DragEvent;

import androidx.annotation.Nullable;

import com.android.internal.logging.InstanceId;
import com.android.internal.logging.InstanceIdSequence;
import com.android.internal.logging.UiEvent;
@@ -61,9 +63,7 @@ public class DragAndDropEventLogger {
            mInstanceId = mIdSequence.newInstanceId();
        }
        mActivityInfo = item.getActivityInfo();
        mUiEventLogger.logWithInstanceId(getStartEnum(description),
                mActivityInfo.applicationInfo.uid,
                mActivityInfo.applicationInfo.packageName, mInstanceId);
        log(getStartEnum(description), mActivityInfo);
        return mInstanceId;
    }

@@ -71,18 +71,21 @@ public class DragAndDropEventLogger {
     * Logs a successful drop.
     */
    public void logDrop() {
        mUiEventLogger.logWithInstanceId(DragAndDropUiEventEnum.GLOBAL_APP_DRAG_DROPPED,
                mActivityInfo.applicationInfo.uid,
                mActivityInfo.applicationInfo.packageName, mInstanceId);
        log(DragAndDropUiEventEnum.GLOBAL_APP_DRAG_DROPPED, mActivityInfo);
    }

    /**
     * Logs the end of a drag.
     */
    public void logEnd() {
        mUiEventLogger.logWithInstanceId(DragAndDropUiEventEnum.GLOBAL_APP_DRAG_END,
                mActivityInfo.applicationInfo.uid,
                mActivityInfo.applicationInfo.packageName, mInstanceId);
        log(DragAndDropUiEventEnum.GLOBAL_APP_DRAG_END, mActivityInfo);
    }

    private void log(UiEventLogger.UiEventEnum event, @Nullable ActivityInfo activityInfo) {
        mUiEventLogger.logWithInstanceId(event,
                activityInfo == null ? 0 : activityInfo.applicationInfo.uid,
                activityInfo == null ? null : activityInfo.applicationInfo.packageName,
                mInstanceId);
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -1760,8 +1760,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     * Called when a notification is dropped on proper target window.
     */
    public void dragAndDropSuccess() {
        if (mOnDragSuccessListener != null) {
            mOnDragSuccessListener.onDragSuccess(getEntry());
        }
    }

    private void doLongClickCallback() {
        doLongClickCallback(getWidth() / 2, getHeight() / 2);
+2 −1
Original line number Diff line number Diff line
@@ -148,7 +148,8 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
    /**
     * A launch root task for activity launching with {@link FLAG_ACTIVITY_LAUNCH_ADJACENT} flag.
     */
    private Task mLaunchAdjacentFlagRootTask;
    @VisibleForTesting
    Task mLaunchAdjacentFlagRootTask;

    /**
     * A focusable root task that is purposely to be positioned at the top. Although the root
+2 −2
Original line number Diff line number Diff line
@@ -566,17 +566,17 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: {
                final WindowContainer wc = WindowContainer.fromBinder(hop.getContainer());
                final Task task = wc != null ? wc.asTask() : null;
                final boolean clearRoot = hop.getToTop();
                if (task == null) {
                    throw new IllegalArgumentException("Cannot set non-task as launch root: " + wc);
                } else if (!task.mCreatedByOrganizer) {
                    throw new UnsupportedOperationException(
                            "Cannot set non-organized task as adjacent flag root: " + wc);
                } else if (task.getAdjacentTaskFragment() == null) {
                } else if (task.getAdjacentTaskFragment() == null && !clearRoot) {
                    throw new UnsupportedOperationException(
                            "Cannot set non-adjacent task as adjacent flag root: " + wc);
                }

                final boolean clearRoot = hop.getToTop();
                task.getDisplayArea().setLaunchAdjacentFlagRootTask(clearRoot ? null : task);
                break;
            }
+30 −0
Original line number Diff line number Diff line
@@ -542,6 +542,36 @@ public class WindowOrganizerTests extends WindowTestsBase {
        assertEquals(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY, infos.get(0).getWindowingMode());
    }

    @Test
    public void testSetAdjacentLaunchRoot() {
        DisplayContent dc = mWm.mRoot.getDisplayContent(Display.DEFAULT_DISPLAY);

        final Task task1 = mWm.mAtmService.mTaskOrganizerController.createRootTask(
                dc, WINDOWING_MODE_MULTI_WINDOW, null);
        final RunningTaskInfo info1 = task1.getTaskInfo();
        final Task task2 = mWm.mAtmService.mTaskOrganizerController.createRootTask(
                dc, WINDOWING_MODE_MULTI_WINDOW, null);
        final RunningTaskInfo info2 = task2.getTaskInfo();

        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.setAdjacentRoots(info1.token, info2.token);
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
        assertEquals(task1.getAdjacentTaskFragment(), task2);
        assertEquals(task2.getAdjacentTaskFragment(), task1);

        wct = new WindowContainerTransaction();
        wct.setLaunchAdjacentFlagRoot(info1.token);
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
        assertEquals(dc.getDefaultTaskDisplayArea().mLaunchAdjacentFlagRootTask, task1);

        task1.setAdjacentTaskFragment(null);
        task2.setAdjacentTaskFragment(null);
        wct = new WindowContainerTransaction();
        wct.clearLaunchAdjacentFlagRoot(info1.token);
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
        assertEquals(dc.getDefaultTaskDisplayArea().mLaunchAdjacentFlagRootTask, null);
    }

    @Test
    public void testTileAddRemoveChild() {
        final StubOrganizer listener = new StubOrganizer();