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

Commit 64078439 authored by Mark Renouf's avatar Mark Renouf Committed by Android (Google) Code Review
Browse files

Merge "Screenshot Policy updates" into main

parents 1f54363d 7fbe13d2
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.screenshot.data.model

import android.content.ComponentName
import android.graphics.Rect
import com.android.systemui.screenshot.data.model.DisplayContentScenarios.Bounds.FREEFORM_FULL_SCREEN
import com.android.systemui.screenshot.data.model.DisplayContentScenarios.Bounds.FREEFORM_MAXIMIZED
import com.android.systemui.screenshot.data.model.DisplayContentScenarios.Bounds.FREE_FORM
import com.android.systemui.screenshot.data.model.DisplayContentScenarios.Bounds.FULL_SCREEN
import com.android.systemui.screenshot.data.model.DisplayContentScenarios.Bounds.PIP
@@ -153,11 +155,23 @@ object DisplayContentScenarios {
    fun freeFormApps(
        vararg tasks: TaskSpec,
        focusedTaskId: Int,
        maximizedTaskId: Int = -1,
        shadeExpanded: Boolean = false,
    ): DisplayContentModel {
        val freeFormTasks =
            tasks
                .map { freeForm(it) }
                .map {
                    freeForm(
                        task = it,
                        bounds =
                            if (it.taskId == maximizedTaskId) {
                                FREEFORM_MAXIMIZED
                            } else {
                                FREE_FORM
                            },
                        maxBounds = FREEFORM_FULL_SCREEN,
                    )
                }
                // Root tasks are ordered top-down in List<RootTaskInfo>.
                // Sort 'focusedTaskId' last (Boolean natural ordering: [false, true])
                .sortedBy { it.childTaskIds[0] != focusedTaskId }
@@ -180,9 +194,9 @@ object DisplayContentScenarios {
        val PIP = Rect(440, 1458, 1038, 1794)
        val SPLIT_TOP = Rect(0, 0, 1080, 1187)
        val SPLIT_BOTTOM = Rect(0, 1213, 1080, 2400)
        val FREE_FORM = Rect(119, 332, 1000, 1367)

        // "Tablet" size
        val FREE_FORM = Rect(119, 332, 1000, 1367)
        val FREEFORM_FULL_SCREEN = Rect(0, 0, 2560, 1600)
        val FREEFORM_MAXIMIZED = Rect(0, 48, 2560, 1480)
        val FREEFORM_SPLIT_LEFT = Rect(0, 0, 1270, 1600)
@@ -301,11 +315,12 @@ object DisplayContentScenarios {
            }

        /** An activity in FreeForm mode */
        fun freeForm(task: TaskSpec, bounds: Rect = FREE_FORM) =
        fun freeForm(task: TaskSpec, bounds: Rect = FREE_FORM, maxBounds: Rect = bounds) =
            newRootTaskInfo(
                taskId = task.taskId,
                userId = task.userId,
                bounds = bounds,
                maxBounds = maxBounds,
                windowingMode = WindowingMode.Freeform,
                topActivity = ComponentName.unflattenFromString(task.name),
            ) {
+2 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ fun newRootTaskInfo(
    activityType: ActivityType = Standard,
    windowingMode: WindowingMode = FullScreen,
    bounds: Rect = Rect(),
    maxBounds: Rect = bounds,
    topActivity: ComponentName? = null,
    topActivityType: ActivityType = Standard,
    numActivities: Int? = null,
@@ -94,6 +95,7 @@ fun newRootTaskInfo(
            setWindowingMode(windowingMode.toInt())
            setActivityType(activityType.toInt())
            setBounds(bounds)
            setMaxBounds(maxBounds)
        }
        this.bounds = bounds
        this.displayId = displayId
+8 −6
Original line number Diff line number Diff line
@@ -90,9 +90,11 @@ class PrivateProfilePolicyTest {
                Matched(
                    PrivateProfilePolicy.NAME,
                    PrivateProfilePolicy.PRIVATE_TASK_VISIBLE,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = FullScreen(displayId = 0),
                        component = ComponentName.unflattenFromString(YOUTUBE),
                        component =
                            ComponentName.unflattenFromString(YOUTUBE)
                                ?: error("Invalid component name"),
                        owner = UserHandle.of(PRIVATE),
                    ),
                )
@@ -142,7 +144,7 @@ class PrivateProfilePolicyTest {
                Matched(
                    PrivateProfilePolicy.NAME,
                    PrivateProfilePolicy.PRIVATE_TASK_VISIBLE,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = FullScreen(displayId = 0),
                        component = ComponentName.unflattenFromString(YOUTUBE),
                        owner = UserHandle.of(PRIVATE),
@@ -167,7 +169,7 @@ class PrivateProfilePolicyTest {
                Matched(
                    PrivateProfilePolicy.NAME,
                    PrivateProfilePolicy.PRIVATE_TASK_VISIBLE,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = FullScreen(displayId = 0),
                        component = ComponentName.unflattenFromString(FILES),
                        owner = UserHandle.of(PRIVATE),
@@ -188,7 +190,7 @@ class PrivateProfilePolicyTest {
                Matched(
                    PrivateProfilePolicy.NAME,
                    PrivateProfilePolicy.PRIVATE_TASK_VISIBLE,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = FullScreen(displayId = 0),
                        component = ComponentName.unflattenFromString(YOUTUBE_PIP),
                        owner = UserHandle.of(PRIVATE),
@@ -212,7 +214,7 @@ class PrivateProfilePolicyTest {
                Matched(
                    PrivateProfilePolicy.NAME,
                    PrivateProfilePolicy.PRIVATE_TASK_VISIBLE,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = FullScreen(displayId = 0),
                        component = ComponentName.unflattenFromString(YOUTUBE_PIP),
                        owner = UserHandle.of(PRIVATE),
+217 −151

File changed.

Preview size limit exceeded, changes collapsed.

+4 −4
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ class WorkProfilePolicyTest {
                PolicyResult.Matched(
                    policy = WorkProfilePolicy.NAME,
                    reason = WORK_TASK_IS_TOP,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = IsolatedTask(taskId = 1002, taskBounds = FULL_SCREEN),
                        component = ComponentName.unflattenFromString(FILES),
                        owner = UserHandle.of(WORK),
@@ -162,7 +162,7 @@ class WorkProfilePolicyTest {
                PolicyResult.Matched(
                    policy = WorkProfilePolicy.NAME,
                    reason = WORK_TASK_IS_TOP,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = IsolatedTask(taskId = 1002, taskBounds = FULL_SCREEN.splitTop(20)),
                        component = ComponentName.unflattenFromString(FILES),
                        owner = UserHandle.of(WORK),
@@ -200,7 +200,7 @@ class WorkProfilePolicyTest {
                PolicyResult.Matched(
                    policy = WorkProfilePolicy.NAME,
                    reason = WORK_TASK_IS_TOP,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = IsolatedTask(taskId = 1003, taskBounds = FULL_SCREEN),
                        component = ComponentName.unflattenFromString(FILES),
                        owner = UserHandle.of(WORK),
@@ -226,7 +226,7 @@ class WorkProfilePolicyTest {
                PolicyResult.Matched(
                    policy = WorkProfilePolicy.NAME,
                    reason = WORK_TASK_IS_TOP,
                    CaptureParameters(
                    LegacyCaptureParameters(
                        type = IsolatedTask(taskId = 1003, taskBounds = FREE_FORM),
                        component = ComponentName.unflattenFromString(FILES),
                        owner = UserHandle.of(WORK),
Loading