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

Commit 05ba94f9 authored by Ebru Kurnaz's avatar Ebru Kurnaz
Browse files

Add an option to wm density command to set the density ratio.

With the option -r the density ratio will be set to preserve display
size on resolution change:  adb shell wm density [-d DisplayId] -r

Flag: com.android.window.flags.enable_persisting_display_size_for_connected_displays
Test: Manual test
Bug: 401521173
Change-Id: Ie2c0f61a145d87d613dd66153799561437828b7a
parent 01c534a5
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -341,9 +341,16 @@ public class WindowManagerShellCommand extends ShellCommand {
            }
        }

        String ratioArg = getNextArg();
        if (density > 0) {
            if ("-r".equals(ratioArg)) {
                mInterface.setForcedDisplayDensityRatio(displayId,
                        (float) density / mInterface.getInitialDisplayDensity(displayId),
                        UserHandle.USER_CURRENT);
            } else {
                mInterface.setForcedDisplayDensityForUser(displayId, density,
                        UserHandle.USER_CURRENT);
            }
        } else {
            mInterface.clearForcedDisplayDensityForUser(displayId,
                    UserHandle.USER_CURRENT);
@@ -1564,8 +1571,9 @@ public class WindowManagerShellCommand extends ShellCommand {
        pw.println("  size [reset|WxH|WdpxHdp] [-d DISPLAY_ID]");
        pw.println("    Return or override display size.");
        pw.println("    width and height in pixels unless suffixed with 'dp'.");
        pw.println("  density [reset|DENSITY] [-d DISPLAY_ID] [-u UNIQUE_ID]");
        pw.println("  density [reset|DENSITY] [-d DISPLAY_ID] [-u UNIQUE_ID] [-r]");
        pw.println("    Return or override display density.");
        pw.println("    Use option -r at the end to persist display size on resolution change.");
        pw.println("  folded-area [reset|LEFT,TOP,RIGHT,BOTTOM]");
        pw.println("    Return or override folded area.");
        pw.println("  scaling [off|auto] [-d DISPLAY_ID]");