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

Commit 7ce5eb57 authored by Ats Jenk's avatar Ats Jenk
Browse files

Use aconfig flag for desktop mode

Delays registration of DesktopModeLaunchParamsModifier to after
receiving onSystemReady() callback. Otherwise we are trying to access
the desktop windowing flag too early, before the flagging system is
initialized.

Bug: 304778354
Test: enable aconfig flag, check that desktop windowing is available

Change-Id: I5d743e34e943657f8485e5de50c660f67068660e
parent c066ac64
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -18,11 +18,15 @@ package com.android.wm.shell.desktopmode;

import android.os.SystemProperties;

import com.android.wm.shell.Flags;

/**
 * Constants for desktop mode feature
 */
public class DesktopModeStatus {

    private static final boolean ENABLE_DESKTOP_WINDOWING = Flags.enableDesktopWindowing();

    /**
     * Flag to indicate whether desktop mode proto is available on the device
     */
@@ -54,6 +58,12 @@ public class DesktopModeStatus {
     * Return {@code true} is desktop windowing proto 2 is enabled
     */
    public static boolean isEnabled() {
        // Check for aconfig flag first
        if (ENABLE_DESKTOP_WINDOWING) {
            return true;
        }
        // Fall back to sysprop flag
        // TODO(b/304778354): remove sysprop once desktop aconfig flag supports dynamic overriding
        return IS_PROTO2_ENABLED;
    }

+1 −0
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ java_library_static {
        "notification_flags_lib",
        "biometrics_flags_lib",
        "am_flags_lib",
        "com_android_wm_shell_flags_lib",
    ],
    javac_shard_size: 50,
    javacflags: [
+9 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.SystemProperties;
import android.util.Slog;

import com.android.server.wm.LaunchParamsController.LaunchParamsModifier;
import com.android.wm.shell.Flags;

/**
 * The class that defines default launch params for tasks in desktop mode
@@ -40,6 +41,7 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
    private static final boolean DEBUG = false;

    // Desktop mode feature flags.
    private static final boolean ENABLE_DESKTOP_WINDOWING = Flags.enableDesktopWindowing();
    private static final boolean DESKTOP_MODE_PROTO2_SUPPORTED =
            SystemProperties.getBoolean("persist.wm.debug.desktop_mode_2", false);
    // Override default freeform task width when desktop mode is enabled. In dips.
@@ -91,7 +93,7 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
        // previous windowing mode to be restored even if the desktop mode state has changed.
        // Let task launches inherit the windowing mode from the source task if available, which
        // should have the desired windowing mode set by WM Shell. See b/286929122.
        if (DESKTOP_MODE_PROTO2_SUPPORTED && source != null && source.getTask() != null) {
        if (isDesktopModeSupported() && source != null && source.getTask() != null) {
            final Task sourceTask = source.getTask();
            outParams.mWindowingMode = sourceTask.getWindowingMode();
            appendLog("inherit-from-source=" + outParams.mWindowingMode);
@@ -140,6 +142,12 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {

    /** Whether desktop mode is supported. */
    static boolean isDesktopModeSupported() {
        // Check for aconfig flag first
        if (ENABLE_DESKTOP_WINDOWING) {
            return true;
        }
        // Fall back to sysprop flag
        // TODO(b/304778354): remove sysprop once desktop aconfig flag supports dynamic overriding
        return DESKTOP_MODE_PROTO2_SUPPORTED;
    }
}