diff --git a/res/values/strings.xml b/res/values/strings.xml index 5fa003176ed..73cee9a467d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12268,11 +12268,11 @@ Settings Panel - - Enable freeform windowing experiences + + Enable freeform windows - - Enable desktop mode on secondary display + + Enable freeform windows on secondary display Enable non-resizable in multi window @@ -13232,12 +13232,12 @@ Customize %1$s - + A reboot is required to enable freeform window support. - - A reboot is required to update availability of freeform windowing experiences. - - A reboot is required to enable desktop mode on secondary displays. + + A reboot is required to update availability of freeform windows. + + A reboot is required to enable freeform windows on secondary displays. Reboot now diff --git a/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceController.java b/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceController.java index 0d3d835dc5f..2bce9ad32bd 100644 --- a/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceController.java +++ b/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceController.java @@ -67,6 +67,12 @@ public class DesktopModeSecondaryDisplayPreferenceController extends Settings.Global.putInt(mContext.getContentResolver(), DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF); + // Update freeform window support on device. + // DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT setting enables freeform support on device + // where it's not present by default. + Settings.Global.putInt(mContext.getContentResolver(), + Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, + isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF); if (isEnabled && mFragment != null) { RebootConfirmationDialogFragment.show( mFragment, R.string.reboot_dialog_enable_desktop_mode_on_secondary_display, diff --git a/tests/robotests/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceControllerTest.java index 5931004cb66..3691d12e899 100644 --- a/tests/robotests/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/DesktopModeSecondaryDisplayPreferenceControllerTest.java @@ -16,6 +16,7 @@ package com.android.settings.development; +import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT; import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS; import static com.android.settings.development.DesktopModeSecondaryDisplayPreferenceController.SETTING_VALUE_OFF; @@ -55,6 +56,7 @@ public class DesktopModeSecondaryDisplayPreferenceControllerTest { private static final String ENG_BUILD_TYPE = "eng"; private static final String USER_BUILD_TYPE = "user"; + private static final int SETTING_VALUE_INVALID = -1; @Mock private SwitchPreference mPreference; @@ -102,21 +104,41 @@ public class DesktopModeSecondaryDisplayPreferenceControllerTest { @Test public void onPreferenceChange_switchEnabled_enablesDesktopModeOnSecondaryDisplay() { - mController.onPreferenceChange(mPreference, true /* new value */); + mController.onPreferenceChange(mPreference, /* newValue= */ true); final int mode = Settings.Global.getInt(mContext.getContentResolver(), - DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, -1 /* default */); + DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, + /* def= */ SETTING_VALUE_INVALID); assertThat(mode).isEqualTo(SETTING_VALUE_ON); verify(mTransaction).add(any(RebootConfirmationDialogFragment.class), any()); } @Test - public void onPreferenceChange_switchDisabled_disablesDesktopModeOnSecondaryDisplay() { - mController.onPreferenceChange(mPreference, false /* new value */); + public void onPreferenceChange_switchEnabled_enablesFreeformSupport() { + mController.onPreferenceChange(mPreference, /* newValue= */ true); final int mode = Settings.Global.getInt(mContext.getContentResolver(), - DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, -1 /* default */); + DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, /* def= */ SETTING_VALUE_INVALID); + assertThat(mode).isEqualTo(SETTING_VALUE_ON); + } + + @Test + public void onPreferenceChange_switchDisabled_disablesDesktopModeOnSecondaryDisplay() { + mController.onPreferenceChange(mPreference, /* newValue= */ false); + + final int mode = Settings.Global.getInt(mContext.getContentResolver(), + DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, + /* def= */ SETTING_VALUE_INVALID); + assertThat(mode).isEqualTo(SETTING_VALUE_OFF); + } + + @Test + public void onPreferenceChange_switchDisabled_disablesFreeformSupport() { + mController.onPreferenceChange(mPreference, /* newValue= */ false); + + final int mode = Settings.Global.getInt(mContext.getContentResolver(), + DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, /* def= */ SETTING_VALUE_INVALID); assertThat(mode).isEqualTo(SETTING_VALUE_OFF); } @@ -145,7 +167,8 @@ public class DesktopModeSecondaryDisplayPreferenceControllerTest { mController.onDeveloperOptionsSwitchDisabled(); final int mode = Settings.Global.getInt(mContext.getContentResolver(), - DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, -1 /* default */); + DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, + /* def= */ SETTING_VALUE_INVALID); assertThat(mode).isEqualTo(SETTING_VALUE_OFF); verify(mPreference).setEnabled(false); }