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

Commit e38430db authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille
Browse files

Add the Dev Option for Desktop Experience

Add the Settings constants and the needed methods, including to update
the system property when the Settings changes.

Note: This should not be backed up.

Test: atest DesktopModeFlagsTest
Bug: 389092752
Flag: com.android.window.flags.show_desktop_experience_dev_option
Change-Id: I87af51b0df997236b166db6ed834d44a943dde96
parent 8b1e155a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -13738,6 +13738,16 @@ public final class Settings {
        public static final String DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT
                = "enable_freeform_support";
        /**
         * Whether to override the availability of the desktop experiences features on the
         * device. With desktop experiences enabled, secondary displays can be used to run
         * apps, in desktop mode by default. Otherwise they can only be used for mirroring.
         * @hide
         */
        @Readable
        public static final String DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES =
                "override_desktop_experience_features";
        /**
         * Whether to override the availability of the desktop mode on the main display of the
         * device. If on, users can make move an app to the desktop, allowing a freeform windowing
+8 −1
Original line number Diff line number Diff line
@@ -218,6 +218,13 @@ public class DesktopModeStatus {
        return isDeviceEligibleForDesktopMode(context) && Flags.showDesktopWindowingDevOption();
    }

    /**
     * Return {@code true} if desktop mode dev option should be shown on current device
     */
    public static boolean canShowDesktopExperienceDevOption(@NonNull Context context) {
        return Flags.showDesktopExperienceDevOption();
    }

    /** Returns if desktop mode dev option should be enabled if there is no user override. */
    public static boolean shouldDevOptionBeEnabledByDefault() {
        return Flags.enableDesktopWindowingMode();
@@ -290,7 +297,7 @@ public class DesktopModeStatus {
    /**
     * Return {@code true} if desktop mode is unrestricted and is supported in the device.
     */
    private static boolean isDeviceEligibleForDesktopMode(@NonNull Context context) {
    public static boolean isDeviceEligibleForDesktopMode(@NonNull Context context) {
        return !enforceDeviceRestrictions() || isDesktopModeSupported(context);
    }

+1 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ public class SettingsBackupTest {
                    Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT,
                    Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS,
                    Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_MODE_FEATURES,
                    Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES,
                    Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES,
                    Settings.Global.DEVELOPMENT_FORCE_RTL,
                    Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW,
+20 −0
Original line number Diff line number Diff line
@@ -314,6 +314,7 @@ import android.window.ActivityWindowInfo;
import android.window.AddToSurfaceSyncGroupResult;
import android.window.ClientWindowFrames;
import android.window.ConfigurationChangeSetting;
import android.window.DesktopModeFlags;
import android.window.IGlobalDragListener;
import android.window.IScreenRecordingCallback;
import android.window.ISurfaceSyncGroupCompletedListener;
@@ -843,6 +844,8 @@ public class WindowManagerService extends IWindowManager.Stub
                DEVELOPMENT_WM_DISPLAY_SETTINGS_PATH);
        private final Uri mMaximumObscuringOpacityForTouchUri = Settings.Global.getUriFor(
                Settings.Global.MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH);
        private final Uri mDevelopmentOverrideDesktopExperienceUri = Settings.Global.getUriFor(
                Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES);

        public SettingsObserver() {
            super(new Handler());
@@ -870,6 +873,8 @@ public class WindowManagerService extends IWindowManager.Stub
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(mMaximumObscuringOpacityForTouchUri, false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(mDevelopmentOverrideDesktopExperienceUri, false, this,
                    UserHandle.USER_ALL);
        }

        @Override
@@ -913,6 +918,11 @@ public class WindowManagerService extends IWindowManager.Stub
                return;
            }

            if (mDevelopmentOverrideDesktopExperienceUri.equals(uri)) {
                updateDevelopmentOverrideDesktopExperience();
                return;
            }

            @UpdateAnimationScaleMode
            final int mode;
            if (mWindowAnimationScaleUri.equals(uri)) {
@@ -979,6 +989,16 @@ public class WindowManagerService extends IWindowManager.Stub
            mAtmService.mForceResizableActivities = forceResizable;
        }

        void updateDevelopmentOverrideDesktopExperience() {
            ContentResolver resolver = mContext.getContentResolver();
            final int overrideDesktopMode = Settings.Global.getInt(resolver,
                    Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES,
                    DesktopModeFlags.ToggleOverride.OVERRIDE_UNSET.getSetting());

            SystemProperties.set(DesktopModeFlags.SYSTEM_PROPERTY_NAME,
                    Integer.toString(overrideDesktopMode));
        }

        void updateDevEnableNonResizableMultiWindow() {
            ContentResolver resolver = mContext.getContentResolver();
            final boolean devEnableNonResizableMultiWindow = Settings.Global.getInt(resolver,