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

Commit f37f242c authored by Mark Renouf's avatar Mark Renouf
Browse files

Expose NAME constant from a companion property for testing

Bug: 327613051
Test: N/A
Flag: NONE
Change-Id: Ib7fe8982f99b8f289663e7b70ac6d8b8a4edfe56
parent b002fcde
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ import com.android.systemui.screenshot.policy.CapturePolicy.PolicyResult.NotMatc
import com.android.systemui.screenshot.policy.CaptureType.FullScreen
import javax.inject.Inject

private const val POLICY_NAME = "PrivateProfile"

/**
 * Condition: When any visible task belongs to a private user.
 *
@@ -41,7 +39,7 @@ constructor(
    override suspend fun check(content: DisplayContentModel): PolicyResult {
        // The systemUI notification shade isn't a private profile app, skip.
        if (content.systemUiState.shadeExpanded) {
            return NotMatched(policy = POLICY_NAME, reason = "Notification shade is expanded")
            return NotMatched(policy = NAME, reason = "Notification shade is expanded")
        }

        // Find the first visible rootTaskInfo with a child task owned by a private user
@@ -56,14 +54,11 @@ constructor(
                        }
                        ?.let { root to it }
                }
                ?: return NotMatched(
                    policy = POLICY_NAME,
                    reason = "No private profile tasks are visible"
                )
                ?: return NotMatched(policy = NAME, reason = "No private profile tasks are visible")

        // If matched, return parameters needed to modify the request.
        return Matched(
            policy = POLICY_NAME,
            policy = NAME,
            reason = "At least one private profile task is visible",
            CaptureParameters(
                type = FullScreen(content.displayId),
@@ -72,4 +67,7 @@ constructor(
            )
        )
    }
    companion object {
        const val NAME = "PrivateProfile"
    }
}
+8 −5
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ import com.android.systemui.screenshot.policy.CaptureType.IsolatedTask
import javax.inject.Inject
import kotlinx.coroutines.flow.first

private const val POLICY_NAME = "WorkProfile"

/**
 * Condition: When the top visible task (excluding PIP mode) belongs to a work user.
 *
@@ -39,10 +37,11 @@ class WorkProfilePolicy
constructor(
    private val profileTypes: ProfileTypeRepository,
) : CapturePolicy {

    override suspend fun check(content: DisplayContentModel): PolicyResult {
        // The systemUI notification shade isn't a work app, skip.
        if (content.systemUiState.shadeExpanded) {
            return NotMatched(policy = POLICY_NAME, reason = "Notification shade is expanded")
            return NotMatched(policy = NAME, reason = "Notification shade is expanded")
        }

        // Find the first non PiP rootTask with a top child task owned by a work user
@@ -54,13 +53,13 @@ constructor(
                    profileTypes.getProfileType(child.userId) == ProfileType.WORK
                }
                ?: return NotMatched(
                    policy = POLICY_NAME,
                    policy = NAME,
                    reason = "The top-most non-PINNED task does not belong to a work profile user"
                )

        // If matched, return parameters needed to modify the request.
        return PolicyResult.Matched(
            policy = POLICY_NAME,
            policy = NAME,
            reason = "The top-most non-PINNED task ($childTask) belongs to a work profile user",
            CaptureParameters(
                type = IsolatedTask(taskId = childTask.id, taskBounds = childTask.bounds),
@@ -69,4 +68,8 @@ constructor(
            )
        )
    }

    companion object {
        val NAME = "WorkProfile"
    }
}