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

Commit 1026b458 authored by Ats Jenk's avatar Ats Jenk
Browse files

Use system density for window decoration

There is a prototype feature to allow overriding density for desktop
tasks. This override should not apply to the window decoration.
If the override system property is detected, use the system density for
the window decoration.

Bug: 272529050
Test: set 272 dpi for desktop tasks, move a fullscreen task to desktop,
  observe that task is using a different density, but window decoration
  is using the system density
Test: remove desktop task density override, observe that desktop task
  window decoration using task density (which matches system)
Change-Id: I1c8db490e527381b2adaa0a657050822763e1516
parent 6a3d3910
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -279,10 +279,6 @@ class DesktopTasksController(
        }
    }

    private fun isDesktopDensityOverrideSet(): Boolean {
        return DESKTOP_DENSITY_OVERRIDE in DESKTOP_DENSITY_ALLOWED_RANGE
    }

    private fun getFullscreenDensityDpi(): Int {
        return context.resources.displayMetrics.densityDpi
    }
@@ -354,5 +350,13 @@ class DesktopTasksController(
        private val DESKTOP_DENSITY_OVERRIDE =
            SystemProperties.getInt("persist.wm.debug.desktop_mode_density", 0)
        private val DESKTOP_DENSITY_ALLOWED_RANGE = (100..1000)

        /**
         * Check if desktop density override is enabled
         */
        @JvmStatic
        fun isDesktopDensityOverrideSet(): Boolean {
            return DESKTOP_DENSITY_OVERRIDE in DESKTOP_DENSITY_ALLOWED_RANGE
        }
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Point;
@@ -46,6 +47,7 @@ import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.desktopmode.DesktopTasksController;

/**
 * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with
@@ -95,6 +97,17 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        mDesktopActive = DesktopModeStatus.isActive(mContext);
    }

    @Override
    protected Configuration getConfigurationWithOverrides(
            ActivityManager.RunningTaskInfo taskInfo) {
        Configuration configuration = taskInfo.getConfiguration();
        if (DesktopTasksController.isDesktopDensityOverrideSet()) {
            // Density is overridden for desktop tasks. Keep system density for window decoration.
            configuration.densityDpi = mContext.getResources().getConfiguration().densityDpi;
        }
        return configuration;
    }

    void setCaptionListeners(
            View.OnClickListener onCaptionButtonClickListener,
            View.OnTouchListener onCaptionTouchListener) {
+12 −2
Original line number Diff line number Diff line
@@ -131,7 +131,17 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
        mSurfaceControlViewHostFactory = surfaceControlViewHostFactory;

        mDisplay = mDisplayController.getDisplay(mTaskInfo.displayId);
        mDecorWindowContext = mContext.createConfigurationContext(mTaskInfo.getConfiguration());
        mDecorWindowContext = mContext.createConfigurationContext(
                getConfigurationWithOverrides(mTaskInfo));
    }

    /**
     * Get {@link Configuration} from supplied {@link RunningTaskInfo}.
     *
     * Allows values to be overridden before returning the configuration.
     */
    protected Configuration getConfigurationWithOverrides(RunningTaskInfo taskInfo) {
        return taskInfo.getConfiguration();
    }

    /**
@@ -165,7 +175,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>

        outResult.mRootView = rootView;
        rootView = null; // Clear it just in case we use it accidentally
        final Configuration taskConfig = mTaskInfo.getConfiguration();
        final Configuration taskConfig = getConfigurationWithOverrides(mTaskInfo);
        if (oldTaskConfig.densityDpi != taskConfig.densityDpi
                || mDisplay == null
                || mDisplay.getDisplayId() != mTaskInfo.displayId) {