Merge "Only commitRunningAppsToUI if shownTasks changed" into main

This commit is contained in:
Treehugger Robot
2024-07-02 09:07:41 +00:00
committed by Android (Google) Code Review
6 changed files with 306 additions and 5 deletions
@@ -149,20 +149,39 @@ class TaskbarRecentAppsController(
taskListChangeId =
recentsModel.getTasks { tasks ->
allRecentTasks = tasks
val oldRunningPackages = runningAppPackages
val oldMinimizedPackages = minimizedAppPackages
desktopTask = allRecentTasks.filterIsInstance<DesktopTask>().firstOrNull()
onRecentsOrHotseatChanged()
controllers.taskbarViewController.commitRunningAppsToUI()
val runningPackagesChanged = oldRunningPackages != runningAppPackages
val minimizedPackagessChanged = oldMinimizedPackages != minimizedAppPackages
if (
onRecentsOrHotseatChanged() ||
runningPackagesChanged ||
minimizedPackagessChanged
) {
controllers.taskbarViewController.commitRunningAppsToUI()
}
}
}
}
private fun onRecentsOrHotseatChanged() {
/**
* Updates [shownTasks] when Recents or Hotseat changes.
*
* @return Whether [shownTasks] changed.
*/
private fun onRecentsOrHotseatChanged(): Boolean {
val oldShownTasks = shownTasks
shownTasks =
if (isInDesktopMode) {
computeShownRunningTasks()
} else {
computeShownRecentTasks()
}
val shownTasksChanged = oldShownTasks != shownTasks
if (!shownTasksChanged) {
return shownTasksChanged
}
for (groupTask in shownTasks) {
for (task in groupTask.tasks) {
@@ -174,6 +193,7 @@ class TaskbarRecentAppsController(
}
}
}
return shownTasksChanged
}
private fun computeShownRunningTasks(): List<GroupTask> {
@@ -22,6 +22,7 @@ import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import java.util.List;
import java.util.Objects;
/**
* A {@link Task} container that can contain N number of tasks that are part of the desktop in
@@ -68,4 +69,16 @@ public class DesktopTask extends GroupTask {
return "type=" + taskViewType + " tasks=" + tasks;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof DesktopTask that)) return false;
if (!super.equals(o)) return false;
return Objects.equals(tasks, that.tasks);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), tasks);
}
}
@@ -26,6 +26,7 @@ import com.android.systemui.shared.recents.model.Task;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* A {@link Task} container that can contain one or two tasks, depending on if the two tasks
@@ -91,4 +92,17 @@ public class GroupTask {
return "type=" + taskViewType + " task1=" + task1 + " task2=" + task2;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GroupTask that)) return false;
return taskViewType == that.taskViewType && Objects.equals(task1,
that.task1) && Objects.equals(task2, that.task2)
&& Objects.equals(mSplitBounds, that.mSplitBounds);
}
@Override
public int hashCode() {
return Objects.hash(task1, task2, mSplitBounds, taskViewType);
}
}