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

Commit 162d30b2 authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Remove flag enable_task_view_controller_cleanup" into main

parents d8c270d9 f336c91c
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -171,16 +171,6 @@ flag {
    bug: "349828130"
}

flag {
    name: "enable_task_view_controller_cleanup"
    namespace: "multitasking"
    description: "Fix memory leak with task view controllers"
    bug: "369995920"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "task_view_repository"
    namespace: "multitasking"
+2 −25
Original line number Diff line number Diff line
@@ -20,15 +20,12 @@ import android.app.ActivityManager
import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN
import android.content.ComponentName
import android.content.Context
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.core.app.ApplicationProvider
import androidx.test.filters.SmallTest
import com.android.window.flags.Flags.FLAG_EXCLUDE_TASK_FROM_RECENTS
import com.android.wm.shell.Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE
import com.android.wm.shell.Flags.FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP
import com.android.wm.shell.shared.bubbles.BubbleAnythingFlagHelper
import com.android.wm.shell.taskview.TaskView
import com.google.common.truth.Truth.assertThat
@@ -84,32 +81,13 @@ class BubbleTaskViewTest(flags: FlagsParameterization) {
    }

    @Test
    @DisableFlags(FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP)
    fun cleanup_flagOff_invalidTaskId_doesNotRemoveTask() {
    fun cleanup_invalidTaskId_removesTask() {
        bubbleTaskView.cleanup()
        verify(taskView, never()).removeTask()
    }

    @Test
    @EnableFlags(FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP)
    fun cleanup_flagOn_invalidTaskId_removesTask() {
        bubbleTaskView.cleanup()
        verify(taskView).removeTask()
    }

    @Test
    @DisableFlags(FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP)
    fun cleanup_flagOff_validTaskId_removesTask() {
        bubbleTaskView.listener.onTaskCreated(123 /* taskId */, componentName)

        bubbleTaskView.cleanup()

        verify(taskView).removeTask()
    }

    @Test
    @EnableFlags(FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP)
    fun cleanup_flagOn_validTaskId_removesTask() {
    fun cleanup_validTaskId_removesTask() {
        bubbleTaskView.listener.onTaskCreated(123 /* taskId */, componentName)

        bubbleTaskView.cleanup()
@@ -153,7 +131,6 @@ class BubbleTaskViewTest(flags: FlagsParameterization) {
        @Parameters(name = "{0}")
        fun getParams() = FlagsParameterization.allCombinationsOf(
            FLAG_ENABLE_CREATE_ANY_BUBBLE,
            FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP,
            FLAG_EXCLUDE_TASK_FROM_RECENTS,
        )
    }
+4 −7
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.app.ActivityManager.RunningTaskInfo
import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.content.ComponentName
import androidx.annotation.VisibleForTesting
import com.android.wm.shell.Flags
import com.android.wm.shell.bubbles.util.BubbleUtils.isBubbleToFullscreen
import com.android.wm.shell.taskview.TaskView
import java.util.concurrent.Executor
@@ -109,7 +108,6 @@ class BubbleTaskView(val taskView: TaskView, executor: Executor) {
     * This should be called after all other cleanup animations have finished.
     */
    fun cleanup() {
        if (Flags.enableTaskViewControllerCleanup() || taskId != INVALID_TASK_ID) {
        if (isBubbleToFullscreen(taskView.taskInfo)) {
            taskView.unregisterTask()
        } else {
@@ -117,4 +115,3 @@ class BubbleTaskView(val taskView: TaskView, executor: Executor) {
        }
    }
}
}
+5 −24
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.content.pm.ShortcutInfo;
import android.graphics.Rect;
import android.os.Binder;
import android.os.IBinder;
import android.util.ArrayMap;
import android.util.Slog;
import android.view.SurfaceControl;
import android.view.WindowManager;
@@ -145,10 +144,8 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
        mSyncQueue = syncQueue;
        if (useRepo()) {
            mTaskViews = null;
        } else if (Flags.enableTaskViewControllerCleanup()) {
            mTaskViews = new WeakHashMap<>();
        } else {
            mTaskViews = new ArrayMap<>();
            mTaskViews = new WeakHashMap<>();
        }
        mTaskViewRepo = repository;
        // Defer registration until the first TaskView because we want this to be the "first" in
@@ -325,23 +322,12 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
            final TaskViewRepository.TaskViewState state = mTaskViewRepo.byToken(taskInfo.token);
            return state != null ? state.getTaskView() : null;
        }
        if (Flags.enableTaskViewControllerCleanup()) {
        for (TaskViewTaskController controller : mTaskViews.keySet()) {
            if (controller.getTaskInfo() == null) continue;
            if (taskInfo.token.equals(controller.getTaskInfo().token)) {
                return controller;
            }
        }
        } else {
            ArrayMap<TaskViewTaskController, TaskViewRepository.TaskViewState> taskViews =
                    (ArrayMap<TaskViewTaskController, TaskViewRepository.TaskViewState>) mTaskViews;
            for (int i = 0; i < taskViews.size(); ++i) {
                if (taskViews.keyAt(i).getTaskInfo() == null) continue;
                if (taskInfo.token.equals(taskViews.keyAt(i).getTaskInfo().token)) {
                    return taskViews.keyAt(i);
                }
            }
        }
        return null;
    }

@@ -430,11 +416,6 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
            ProtoLog.d(WM_SHELL_BUBBLES_NOISY, "Transitions.removeTaskView(): taskView=%d no token",
                    taskView.hashCode());
            // We don't have a task yet, so just clean up records
            if (!Flags.enableTaskViewControllerCleanup()) {
                // Call to remove task before we have one, do nothing
                Slog.w(TAG, "Trying to remove a task that was never added? (no taskToken)");
                return;
            }
            unregisterTaskView(taskView);
            return;
        }
+0 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static com.android.window.flags.Flags.FLAG_EXCLUDE_TASK_FROM_RECENTS;
import static com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_ANYTHING;
import static com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_APP_COMPAT_FIXES;
import static com.android.wm.shell.Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE;
import static com.android.wm.shell.Flags.FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP;
import static com.android.wm.shell.bubbles.util.BubbleTestUtils.verifyExitBubbleTransaction;

import static com.google.common.truth.Truth.assertThat;
@@ -91,7 +90,6 @@ public class TaskViewTransitionsTest extends ShellTestCase {
    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return FlagsParameterization.allCombinationsOf(
                FLAG_ENABLE_TASK_VIEW_CONTROLLER_CLEANUP,
                FLAG_EXCLUDE_TASK_FROM_RECENTS,
                FLAG_ENABLE_BUBBLE_ANYTHING);
    }