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

Commit 72856988 authored by Omar Elmekkawy's avatar Omar Elmekkawy Committed by Android (Google) Code Review
Browse files

Merge "Migrate tiling listening to display config changes from ShellController" into main

parents 7c770772 d8625fea
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.wm.shell.windowdecor.tiling
import android.app.ActivityManager.RunningTaskInfo
import android.app.WindowConfiguration.WINDOWING_MODE_PINNED
import android.content.Context
import android.content.pm.ActivityInfo.CONFIG_ASSETS_PATHS
import android.content.pm.ActivityInfo.CONFIG_DENSITY
import android.content.pm.ActivityInfo.CONFIG_UI_MODE
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.Rect
@@ -60,7 +63,6 @@ import com.android.wm.shell.shared.FocusTransitionListener
import com.android.wm.shell.shared.annotations.ShellBackgroundThread
import com.android.wm.shell.shared.annotations.ShellMainThread
import com.android.wm.shell.shared.desktopmode.DesktopState
import com.android.wm.shell.sysui.ConfigurationChangeListener
import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.transition.FocusTransitionObserver
import com.android.wm.shell.transition.Transitions
@@ -108,7 +110,7 @@ class DesktopTilingWindowDecoration(
    DragEventListener,
    Transitions.TransitionObserver,
    FocusTransitionListener,
    ConfigurationChangeListener {
    DisplayController.OnDisplaysChangedListener {
    companion object {
        private val TAG: String = DesktopTilingWindowDecoration::class.java.simpleName
        private const val TILING_DIVIDER_TAG = "Tiling Divider"
@@ -252,7 +254,7 @@ class DesktopTilingWindowDecoration(
                )
        } else if (firstTiledApp) {
            shellTaskOrganizer.addTaskVanishedListener(this)
            shellController.addConfigurationChangeListener(this)
            displayController.addDisplayWindowListener(this)
        }
    }

@@ -749,24 +751,31 @@ class DesktopTilingWindowDecoration(
        removeTaskIfTiled(taskId, taskVanished = true, shouldDelayUpdate = true)
    }

    override fun onConfigurationChanged(newConfiguration: Configuration?) {
        val config =
            checkNotNull(configuration) { "Expected non null tiling config for desk: $deskId" }
        checkForUiModeChange(config)
        configuration = config
    }

    override fun onThemeChanged() {
    fun onThemeChanged() {
        desktopTilingDividerWindowManager?.onThemeChange()
    }

    override fun onDensityOrFontScaleChanged() {
    fun onDensityChanged() {
        val config =
            checkNotNull(configuration) { "Expected non null tiling config for desk: $deskId" }
        desktopTilingDividerWindowManager?.release()
        desktopTilingDividerWindowManager = initTilingManagerForDisplay(displayId, config)
    }

    override fun onDisplayConfigurationChanged(displayId: Int, config: Configuration?) {
        if (displayId != this.displayId) return
        val newConfig = checkNotNull(config) { "Expected non null tiling config for desk: $deskId" }

        val diff = newConfig.diff(configuration)
        val themeChanged = (diff and CONFIG_ASSETS_PATHS) != 0 || (diff and CONFIG_UI_MODE) != 0
        val densityChanged = (diff and CONFIG_DENSITY) != 0

        checkForUiModeChange(newConfig)
        if (densityChanged) onDensityChanged()
        if (themeChanged) onThemeChanged()
        configuration = config
    }

    private fun checkForUiModeChange(config: Configuration?) {
        val uiMode =
            config?.uiMode
@@ -933,7 +942,7 @@ class DesktopTilingWindowDecoration(

        if (leftTaskResizingHelper == null && rightTaskResizingHelper == null) {
            shellTaskOrganizer.removeTaskVanishedListener(this)
            shellController.removeConfigurationChangeListener(this)
            displayController.removeDisplayWindowListener(this)
        }
        isTilingFocused = false
        isTilingManagerInitialised = false
+2 −4
Original line number Diff line number Diff line
@@ -708,7 +708,7 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
        whenever(configuration.uiMode).thenReturn(-1)
        tilingDecoration.desktopTilingDividerWindowManager = desktopTilingDividerWindowManager
        tilingDecoration.isTilingManagerInitialised = true
        tilingDecoration.onConfigurationChanged(newConfig)
        tilingDecoration.onDisplayConfigurationChanged(displayId, newConfig)
        verify(desktopTilingDividerWindowManager, times(1)).onThemeChange()
    }

@@ -739,9 +739,7 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

        tilingDecoration.leftTaskResizingHelper = tiledTaskHelper
        tilingDecoration.desktopTilingDividerWindowManager = desktopTilingDividerWindowManager
        assertThrows(NullPointerException::class.java) {
            tilingDecoration.onDensityOrFontScaleChanged()
        }
        assertThrows(NullPointerException::class.java) { tilingDecoration.onDensityChanged() }
    }

    @Test