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

Commit 19b72b7c authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Make isTopActivityExemptFromDesktopWindowing condition more readable

Flag: EXEMPT refactor
Test: atest WMShellUnitTests:DesktopModeCompatPolicyTest
Fixes: 407477368
Change-Id: I48c9148005f82eb7cff1fe927f62b311c9ca035d
parent 4d42e12d
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -58,13 +58,21 @@ class DesktopModeCompatPolicy(private val context: Context) {
        isTopActivityNoDisplay: Boolean,
        isActivityStackTransparent: Boolean,
        userId: Int
    ) =
        DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODALS_POLICY.isTrue &&
                ((isSystemUiTask(packageName) ||
                        isPartOfDefaultHomePackageOrNoHomeAvailable(packageName) ||
                        (isTransparentTask(isActivityStackTransparent, numActivities) &&
                                hasFullscreenTransparentPermission(packageName, userId))) &&
                        !isTopActivityNoDisplay)
    ) = when {
        !DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODALS_POLICY.isTrue -> false
        // If activity is not being displayed, window mode change has no visual affect so leave
        // unchanged.
        isTopActivityNoDisplay -> false
        // If activity belongs to system ui package, safe to force out of desktop.
        isSystemUiTask(packageName) -> true
        // If activity belongs to default home package, safe to force out of desktop.
        isPartOfDefaultHomePackageOrNoHomeAvailable(packageName) -> true
        // If all activities in task stack are transparent AND package has the relevant fullscreen
        // transparent permission, safe to force out of desktop.
        isTransparentTask(isActivityStackTransparent, numActivities) &&
                hasFullscreenTransparentPermission(packageName, userId) -> true
        else -> false
    }

    /** @see DesktopModeCompatUtils.shouldExcludeCaptionFromAppBounds */
    fun shouldExcludeCaptionFromAppBounds(taskInfo: TaskInfo): Boolean =