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

Commit 3d7bba6a authored by Orhan Uysal's avatar Orhan Uysal Committed by Android (Google) Code Review
Browse files

Merge "Use desktop API to remove desktop for dismiss" into main

parents 9c3c7cc3 c2adf8cf
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1492,6 +1492,17 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
        }
    }

    /** Call shell to remove the desktop that is on given `displayId` */
    public void removeDesktop(int displayId) {
        if (mDesktopMode != null) {
            try {
                mDesktopMode.removeDesktop(displayId);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call removeDesktop", e);
            }
        }
    }

    //
    // Unfold transition
    //
+18 −10
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ import android.widget.ListView;
import android.widget.OverScroller;
import android.widget.Toast;
import android.window.PictureInPictureSurfaceTransaction;
import android.window.flags.DesktopModeFlags;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -3935,9 +3936,11 @@ public abstract class RecentsView<
                    if (shouldRemoveTask) {
                        if (dismissedTaskView.isRunningTask()) {
                            finishRecentsAnimation(true /* toRecents */, false /* shouldPip */,
                                    () -> removeTaskInternal(dismissedTaskViewId));
                                    () -> removeTaskInternal(dismissedTaskViewId,
                                            dismissedTaskView instanceof DesktopTaskView));
                        } else {
                            removeTaskInternal(dismissedTaskViewId);
                            removeTaskInternal(dismissedTaskViewId,
                                    dismissedTaskView instanceof DesktopTaskView);
                        }
                        announceForAccessibility(
                                getResources().getString(R.string.task_view_closed));
@@ -4305,15 +4308,20 @@ public abstract class RecentsView<
        return lastVisibleIndex;
    }

    private void removeTaskInternal(int dismissedTaskViewId) {
    private void removeTaskInternal(int dismissedTaskViewId, boolean isDesktop) {
        int[] taskIds = getTaskIdsForTaskViewId(dismissedTaskViewId);
        UI_HELPER_EXECUTOR.getHandler().post(
                () -> {
        UI_HELPER_EXECUTOR.getHandler().post(() -> {
            if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue() && isDesktop) {
                // TODO: b/372005228 - Use the api with desktop id instead.
                SystemUiProxy.INSTANCE.get(getContext()).removeDesktop(
                        mContainer.getDisplay().getDisplayId());
            } else {
                for (int taskId : taskIds) {
                    if (taskId != -1) {
                        ActivityManagerWrapper.getInstance().removeTask(taskId);
                    }
                }
            }
        });
    }