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

Commit b7b45cb3 authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge changes I3e1f1342,I5493598e,I33e0db3a,I1a506d02 into main

* changes:
  DesktopTasksController: Let Wallpaper launchable on ext. displays.
  DesktopmodeWindowDecorViewModel: Use Display Context.
  DesktopTasksController: Create VisualIndicator w/ Display's Context.
  DesktopModeVisualIndicator: use taskInfo's display's bounds instead.
parents 2d6848e1 289f62a4
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ import android.view.animation.DecelerateInterpolator;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.VisibleForTesting;


import com.android.internal.policy.SystemBarUtils;
import com.android.internal.policy.SystemBarUtils;
import com.android.window.flags.Flags;
import com.android.wm.shell.R;
import com.android.wm.shell.R;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayController;
@@ -245,9 +246,17 @@ public class DesktopModeVisualIndicator {
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        final Resources resources = mContext.getResources();
        final Resources resources = mContext.getResources();
        final DisplayMetrics metrics = resources.getDisplayMetrics();
        final DisplayMetrics metrics = resources.getDisplayMetrics();
        final int screenWidth = metrics.widthPixels;
        final int screenWidth;
        final int screenHeight = metrics.heightPixels;
        final int screenHeight;

        if (Flags.enableBugFixesForSecondaryDisplay()) {
            final DisplayLayout displayLayout =
                    mDisplayController.getDisplayLayout(mTaskInfo.displayId);
            screenWidth = displayLayout.width();
            screenHeight = displayLayout.height();
        } else {
            screenWidth = metrics.widthPixels;
            screenHeight = metrics.heightPixels;
        }
        mView = new View(mContext);
        mView = new View(mContext);
        final SurfaceControl.Builder builder = new SurfaceControl.Builder();
        final SurfaceControl.Builder builder = new SurfaceControl.Builder();
        mRootTdaOrganizer.attachToDisplayArea(mTaskInfo.displayId, builder);
        mRootTdaOrganizer.attachToDisplayArea(mTaskInfo.displayId, builder);
+14 −4
Original line number Original line Diff line number Diff line
@@ -1202,9 +1202,12 @@ class DesktopTasksController(
        moveHomeTask(wct, toTop = true)
        moveHomeTask(wct, toTop = true)


        // Currently, we only handle the desktop on the default display really.
        // Currently, we only handle the desktop on the default display really.
        if (displayId == DEFAULT_DISPLAY && ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()) {
        if (
            (displayId == DEFAULT_DISPLAY || Flags.enableBugFixesForSecondaryDisplay()) &&
                ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()
        ) {
            // Add translucent wallpaper activity to show the wallpaper underneath
            // Add translucent wallpaper activity to show the wallpaper underneath
            addWallpaperActivity(wct)
            addWallpaperActivity(displayId, wct)
        }
        }


        val expandedTasksOrderedFrontToBack = taskRepository.getExpandedTasksOrdered(displayId)
        val expandedTasksOrderedFrontToBack = taskRepository.getExpandedTasksOrdered(displayId)
@@ -1253,7 +1256,7 @@ class DesktopTasksController(
            ?.let { homeTask -> wct.reorder(homeTask.getToken(), /* onTop= */ toTop) }
            ?.let { homeTask -> wct.reorder(homeTask.getToken(), /* onTop= */ toTop) }
    }
    }


    private fun addWallpaperActivity(wct: WindowContainerTransaction) {
    private fun addWallpaperActivity(displayId: Int, wct: WindowContainerTransaction) {
        logV("addWallpaperActivity")
        logV("addWallpaperActivity")
        val userHandle = UserHandle.of(userId)
        val userHandle = UserHandle.of(userId)
        val userContext = context.createContextAsUser(userHandle, /* flags= */ 0)
        val userContext = context.createContextAsUser(userHandle, /* flags= */ 0)
@@ -1264,6 +1267,9 @@ class DesktopTasksController(
                launchWindowingMode = WINDOWING_MODE_FULLSCREEN
                launchWindowingMode = WINDOWING_MODE_FULLSCREEN
                pendingIntentBackgroundActivityStartMode =
                pendingIntentBackgroundActivityStartMode =
                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
                if (Flags.enableBugFixesForSecondaryDisplay()) {
                    launchDisplayId = displayId
                }
            }
            }
        val pendingIntent =
        val pendingIntent =
            PendingIntent.getActivityAsUser(
            PendingIntent.getActivityAsUser(
@@ -2048,7 +2054,11 @@ class DesktopTasksController(
                    syncQueue,
                    syncQueue,
                    taskInfo,
                    taskInfo,
                    displayController,
                    displayController,
                    context,
                    if (Flags.enableBugFixesForSecondaryDisplay()) {
                        displayController.getDisplayContext(taskInfo.displayId)
                    } else {
                        context
                    },
                    taskSurface,
                    taskSurface,
                    rootTaskDisplayAreaOrganizer,
                    rootTaskDisplayAreaOrganizer,
                    dragStartState,
                    dragStartState,
+3 −1
Original line number Original line Diff line number Diff line
@@ -1634,7 +1634,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        }
        }
        final DesktopModeWindowDecoration windowDecoration =
        final DesktopModeWindowDecoration windowDecoration =
                mDesktopModeWindowDecorFactory.create(
                mDesktopModeWindowDecorFactory.create(
                        mContext,
                        Flags.enableBugFixesForSecondaryDisplay()
                                ? mDisplayController.getDisplayContext(taskInfo.displayId)
                                : mContext,
                        mContext.createContextAsUser(UserHandle.of(taskInfo.userId), 0 /* flags */),
                        mContext.createContextAsUser(UserHandle.of(taskInfo.userId), 0 /* flags */),
                        mDisplayController,
                        mDisplayController,
                        mSplitScreenController,
                        mSplitScreenController,