Loading src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.settings.connecteddevice.display.ExternalDisplaySettin import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isRotationSettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isRotationSettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isTopologyPaneEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isTopologyPaneEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isUseDisplaySettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isUseDisplaySettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplayUtilsKt.isDisplayInMiroringMode; import android.app.Activity; import android.app.Activity; import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums; Loading Loading @@ -442,7 +443,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen context, refresh, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE); context, refresh, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE); } } } } if (isDisplaySizeSettingEnabled(mInjector)) { if (isDisplaySizeSettingEnabled(mInjector) && !isDisplayInMiroringMode(context)) { addSizePreference(context, refresh, display, position); addSizePreference(context, refresh, display, position); } } } } Loading src/com/android/settings/connecteddevice/display/ExternalDisplayUtils.kt 0 → 100644 +32 −0 Original line number Original line Diff line number Diff line /* * Copyright 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.connecteddevice.display import android.content.Context import android.provider.Settings import android.window.DesktopExperienceFlags fun isDisplayInMiroringMode(context: Context) = if (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue) { 0 != Settings.Secure.getInt(context.contentResolver, Settings.Secure.MIRROR_BUILT_IN_DISPLAY, 0) } else { 0 == Settings.Global.getInt( context.contentResolver, Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, 0) } src/com/android/settings/connecteddevice/display/Mirroring.kt +1 −7 Original line number Original line Diff line number Diff line Loading @@ -34,13 +34,7 @@ class MirrorPreference(context: Context, val contentModeEnabled: Boolean): super.onAttached() super.onAttached() isEnabled = contentModeEnabled isEnabled = contentModeEnabled if (contentModeEnabled) { isChecked = isDisplayInMiroringMode(context) setChecked(0 != Settings.Secure.getInt(context.contentResolver, MIRROR_SETTING, 0)) } else { setChecked(0 == Settings.Global.getInt( context.contentResolver, Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, 0)) } } } override fun onClick() { override fun onClick() { Loading tests/robotests/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java +30 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.settings.connecteddevice.display; package com.android.settings.connecteddevice.display; import static android.view.Display.INVALID_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.provider.Settings.Secure.MIRROR_BUILT_IN_DISPLAY; import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_NOT_FOUND_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_NOT_FOUND_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_SETTINGS_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_SETTINGS_RESOURCE; Loading @@ -37,6 +39,8 @@ import static org.mockito.Mockito.verify; import android.app.Activity; import android.app.Activity; import android.content.Context; import android.content.Context; import android.os.Bundle; import android.os.Bundle; import android.platform.test.annotations.EnableFlags; import android.provider.Settings; import android.view.View; import android.view.View; import android.widget.TextView; import android.widget.TextView; Loading Loading @@ -247,6 +251,32 @@ public class ExternalDisplayPreferenceFragmentTest extends ExternalDisplayTestBa .isEqualTo(getText(EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); .isEqualTo(getText(EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); } } @Test @UiThreadTest @EnableFlags(FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT) public void testShowEnabledDisplay_displaySizeDisabled_isInMirrorMode_doNotShowSizePref() { // Mirror built in display Settings.Secure.putInt( mContext.getContentResolver(), MIRROR_BUILT_IN_DISPLAY, 1); // Only one display available doReturn(List.of(mDisplays.get(0))).when(mMockedInjector).getConnectedDisplays(); // Init initFragment(); mHandler.flush(); assertDisplayListCount(1); var category = getExternalDisplayCategory(0); var pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.keyForNth(0)); assertThat(pref).isNotNull(); pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_ROTATION.keyForNth(0)); assertThat(pref).isNotNull(); var footerPref = category.findPreference(PrefBasics.FOOTER.key); assertThat(footerPref).isNotNull(); var sizePref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_SIZE.keyForNth(0)); assertThat(sizePref).isNull(); assertThat("" + footerPref.getTitle()) .isEqualTo(getText(EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); } @Test @Test @UiThreadTest @UiThreadTest public void testShowEnabledDisplay_OnlyOneDisplayAvailable() { public void testShowEnabledDisplay_OnlyOneDisplayAvailable() { Loading Loading
src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.settings.connecteddevice.display.ExternalDisplaySettin import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isRotationSettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isRotationSettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isTopologyPaneEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isTopologyPaneEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isUseDisplaySettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.isUseDisplaySettingEnabled; import static com.android.settings.connecteddevice.display.ExternalDisplayUtilsKt.isDisplayInMiroringMode; import android.app.Activity; import android.app.Activity; import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums; Loading Loading @@ -442,7 +443,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen context, refresh, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE); context, refresh, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE); } } } } if (isDisplaySizeSettingEnabled(mInjector)) { if (isDisplaySizeSettingEnabled(mInjector) && !isDisplayInMiroringMode(context)) { addSizePreference(context, refresh, display, position); addSizePreference(context, refresh, display, position); } } } } Loading
src/com/android/settings/connecteddevice/display/ExternalDisplayUtils.kt 0 → 100644 +32 −0 Original line number Original line Diff line number Diff line /* * Copyright 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.connecteddevice.display import android.content.Context import android.provider.Settings import android.window.DesktopExperienceFlags fun isDisplayInMiroringMode(context: Context) = if (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue) { 0 != Settings.Secure.getInt(context.contentResolver, Settings.Secure.MIRROR_BUILT_IN_DISPLAY, 0) } else { 0 == Settings.Global.getInt( context.contentResolver, Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, 0) }
src/com/android/settings/connecteddevice/display/Mirroring.kt +1 −7 Original line number Original line Diff line number Diff line Loading @@ -34,13 +34,7 @@ class MirrorPreference(context: Context, val contentModeEnabled: Boolean): super.onAttached() super.onAttached() isEnabled = contentModeEnabled isEnabled = contentModeEnabled if (contentModeEnabled) { isChecked = isDisplayInMiroringMode(context) setChecked(0 != Settings.Secure.getInt(context.contentResolver, MIRROR_SETTING, 0)) } else { setChecked(0 == Settings.Global.getInt( context.contentResolver, Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, 0)) } } } override fun onClick() { override fun onClick() { Loading
tests/robotests/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java +30 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.settings.connecteddevice.display; package com.android.settings.connecteddevice.display; import static android.view.Display.INVALID_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.provider.Settings.Secure.MIRROR_BUILT_IN_DISPLAY; import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_NOT_FOUND_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_NOT_FOUND_FOOTER_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_SETTINGS_RESOURCE; import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_SETTINGS_RESOURCE; Loading @@ -37,6 +39,8 @@ import static org.mockito.Mockito.verify; import android.app.Activity; import android.app.Activity; import android.content.Context; import android.content.Context; import android.os.Bundle; import android.os.Bundle; import android.platform.test.annotations.EnableFlags; import android.provider.Settings; import android.view.View; import android.view.View; import android.widget.TextView; import android.widget.TextView; Loading Loading @@ -247,6 +251,32 @@ public class ExternalDisplayPreferenceFragmentTest extends ExternalDisplayTestBa .isEqualTo(getText(EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); .isEqualTo(getText(EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); } } @Test @UiThreadTest @EnableFlags(FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT) public void testShowEnabledDisplay_displaySizeDisabled_isInMirrorMode_doNotShowSizePref() { // Mirror built in display Settings.Secure.putInt( mContext.getContentResolver(), MIRROR_BUILT_IN_DISPLAY, 1); // Only one display available doReturn(List.of(mDisplays.get(0))).when(mMockedInjector).getConnectedDisplays(); // Init initFragment(); mHandler.flush(); assertDisplayListCount(1); var category = getExternalDisplayCategory(0); var pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.keyForNth(0)); assertThat(pref).isNotNull(); pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_ROTATION.keyForNth(0)); assertThat(pref).isNotNull(); var footerPref = category.findPreference(PrefBasics.FOOTER.key); assertThat(footerPref).isNotNull(); var sizePref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_SIZE.keyForNth(0)); assertThat(sizePref).isNull(); assertThat("" + footerPref.getTitle()) .isEqualTo(getText(EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); } @Test @Test @UiThreadTest @UiThreadTest public void testShowEnabledDisplay_OnlyOneDisplayAvailable() { public void testShowEnabledDisplay_OnlyOneDisplayAvailable() { Loading