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

Commit 736c0298 authored by Uwais Ashraf's avatar Uwais Ashraf
Browse files

Don't add wallpaper activity to list of tasks

This will prevent it from showing up in recent apps.

Bug: 342627272
Fix: 375603439
Test: RecentTasksControllerTest
Flag: com.android.launcher3.enable_refactor_task_thumbnail
Change-Id: I04deef136d84163153e99342688a7bbe5b5ea5a8
parent 8eb5ac27
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ android_library {
        "kotlinx-coroutines-core",
        "//frameworks/libs/systemui:com_android_systemui_shared_flags_lib",
        "//frameworks/libs/systemui:iconloader_base",
        "com_android_launcher3_flags_lib",
        "com_android_wm_shell_flags_lib",
        "PlatformAnimationLib",
        "WindowManager-Shell-proto",
+4 −5
Original line number Diff line number Diff line
@@ -17,12 +17,10 @@
package com.android.wm.shell.desktopmode

import android.app.Activity
import android.app.ActivityManager
import android.app.TaskInfo
import android.content.ComponentName
import android.os.Bundle
import android.view.WindowManager
import com.android.internal.protolog.ProtoLog
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE

/**
 * A transparent activity used in the desktop mode to show the wallpaper under the freeform windows.
@@ -42,11 +40,12 @@ class DesktopWallpaperActivity : Activity() {

    companion object {
        private const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui"
        private val wallpaperActivityComponent =
        @JvmStatic
        val wallpaperActivityComponent =
            ComponentName(SYSTEM_UI_PACKAGE_NAME, DesktopWallpaperActivity::class.java.name)

        @JvmStatic
        fun isWallpaperTask(taskInfo: ActivityManager.RunningTaskInfo) =
        fun isWallpaperTask(taskInfo: TaskInfo) =
            taskInfo.baseIntent.component?.let(::isWallpaperComponent) ?: false

        @JvmStatic
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.content.pm.PackageManager.FEATURE_PC;

import static com.android.wm.shell.Flags.enableShellTopTaskTracking;
import static com.android.wm.shell.desktopmode.DesktopWallpaperActivity.isWallpaperTask;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_TASK_OBSERVER;
import static com.android.wm.shell.shared.ShellSharedConstants.KEY_EXTRA_SHELL_RECENT_TASKS;

@@ -53,6 +54,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.internal.protolog.ProtoLog;
import com.android.launcher3.Flags;
import com.android.wm.shell.common.ExternalInterfaceBinder;
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
@@ -530,6 +532,10 @@ public class RecentTasksController implements TaskStackListenerCallback,
                groupedTasks.add(GroupedTaskInfo.forSplitTasks(taskInfo, pairedTaskInfo,
                        mTaskSplitBoundsMap.get(pairedTaskId)));
            } else {
                if (Flags.enableRefactorTaskThumbnail() && isWallpaperTask(taskInfo)) {
                    // Don't add the wallpaper task as an entry in grouped tasks
                    continue;
                }
                // TODO(346588978): Consolidate multiple visible fullscreen tasks into the same
                //  grouped task
                groupedTasks.add(GroupedTaskInfo.forFullscreenTasks(taskInfo));
+30 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.launcher3.Flags.FLAG_ENABLE_REFACTOR_TASK_THUMBNAIL;
import static com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_PERSISTENCE;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;

@@ -51,6 +52,7 @@ import android.app.ActivityTaskManager;
import android.app.KeyguardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Point;
import android.graphics.Rect;
@@ -72,6 +74,7 @@ import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.desktopmode.DesktopRepository;
import com.android.wm.shell.desktopmode.DesktopWallpaperActivity;
import com.android.wm.shell.shared.GroupedTaskInfo;
import com.android.wm.shell.shared.ShellSharedConstants;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
@@ -237,6 +240,19 @@ public class RecentTasksControllerTest extends ShellTestCase {
                t3.taskId, -1);
    }

    @EnableFlags(FLAG_ENABLE_REFACTOR_TASK_THUMBNAIL)
    @Test
    public void testGetRecentTasks_removesDesktopWallpaperActivity() {
        RecentTaskInfo t1 = makeTaskInfo(1);
        RecentTaskInfo desktopWallpaperTaskInfo = makeDesktopWallpaperTaskInfo(2);
        RecentTaskInfo t3 = makeTaskInfo(3);
        setRawList(t1, desktopWallpaperTaskInfo, t3);

        ArrayList<GroupedTaskInfo> recentTasks =
                mRecentTasksController.getRecentTasks(MAX_VALUE, RECENT_IGNORE_UNAVAILABLE, 0);
        assertGroupedTasksListEquals(recentTasks, t1.taskId, -1, t3.taskId, -1);
    }

    @Test
    public void testGetRecentTasks_withPairs() {
        RecentTaskInfo t1 = makeTaskInfo(1);
@@ -691,10 +707,24 @@ public class RecentTasksControllerTest extends ShellTestCase {
    private RecentTaskInfo makeTaskInfo(int taskId) {
        RecentTaskInfo info = new RecentTaskInfo();
        info.taskId = taskId;

        Intent intent = new Intent();
        intent.setComponent(new ComponentName("com." + taskId, "Activity" + taskId));
        info.baseIntent = intent;

        info.lastNonFullscreenBounds = new Rect();
        return info;
    }

    /**
     * Helper to create a desktop wallpaper activity with a given task id.
     */
    private RecentTaskInfo makeDesktopWallpaperTaskInfo(int taskId) {
        RecentTaskInfo info = makeTaskInfo(taskId);
        info.baseIntent.setComponent(DesktopWallpaperActivity.getWallpaperActivityComponent());
        return info;
    }

    /**
     * Helper to create a running task with a given task id.
     */