Loading core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -10041,6 +10041,12 @@ public final class Settings { public static final String MINIMAL_POST_PROCESSING_ALLOWED = "minimal_post_processing_allowed"; /** * Whether to mirror the built-in display on all connected displays. * @hide */ public static final String MIRROR_BUILT_IN_DISPLAY = "mirror_built_in_display"; /** * No mode switching will happen. * Loading packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ public class SecureSettings { Settings.Secure.RTT_CALLING_MODE, Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED, Settings.Secure.MIRROR_BUILT_IN_DISPLAY, Settings.Secure.MATCH_CONTENT_FRAME_RATE, Settings.Secure.NIGHT_DISPLAY_CUSTOM_START_TIME, Settings.Secure.NIGHT_DISPLAY_CUSTOM_END_TIME, Loading packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ public class SecureSettingsValidators { Secure.INCALL_POWER_BUTTON_BEHAVIOR, new DiscreteValueValidator(new String[] {"1", "2"})); VALIDATORS.put(Secure.MINIMAL_POST_PROCESSING_ALLOWED, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.MIRROR_BUILT_IN_DISPLAY, BOOLEAN_VALIDATOR); VALIDATORS.put( Secure.MATCH_CONTENT_FRAME_RATE, new DiscreteValueValidator(new String[] {"0", "1", "2"})); Loading services/core/java/com/android/server/display/DisplayManagerService.java +51 −6 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; import static android.os.Process.FIRST_APPLICATION_UID; import static android.os.Process.ROOT_UID; import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS; import static android.provider.Settings.Secure.MIRROR_BUILT_IN_DISPLAY; import static android.provider.Settings.Secure.RESOLUTION_MODE_FULL; import static android.provider.Settings.Secure.RESOLUTION_MODE_HIGH; import static android.provider.Settings.Secure.RESOLUTION_MODE_UNKNOWN; Loading @@ -71,6 +72,7 @@ import android.companion.virtual.VirtualDeviceManager; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; Loading Loading @@ -534,6 +536,8 @@ public final class DisplayManagerService extends SystemService { private final boolean mExtraDisplayEventLogging; private final String mExtraDisplayLoggingPackageName; private boolean mMirrorBuiltInDisplay; private final BroadcastReceiver mIdleModeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading Loading @@ -782,7 +786,11 @@ public final class DisplayManagerService extends SystemService { } dpc.onSwitchUser(newUserId, userSerial, newBrightness); }); handleSettingsChange(); handleMinimalPostProcessingAllowedSettingChange(); if (mFlags.isDisplayContentModeManagementEnabled()) { updateMirrorBuiltInDisplaySettingLocked(); } } } Loading Loading @@ -825,12 +833,15 @@ public final class DisplayManagerService extends SystemService { // relevant configuration should be in place. recordTopInsetLocked(mLogicalDisplayMapper.getDisplayLocked(Display.DEFAULT_DISPLAY)); updateSettingsLocked(); updateMinimalPostProcessingAllowedSettingLocked(); updateUserDisabledHdrTypesFromSettingsLocked(); updateUserPreferredDisplayModeSettingsLocked(); if (mIsHdrOutputControlEnabled) { updateHdrConversionModeSettingsLocked(); } if (mFlags.isDisplayContentModeManagementEnabled()) { updateMirrorBuiltInDisplaySettingLocked(); } } mDisplayModeDirector.setDesiredDisplayModeSpecsListener( Loading Loading @@ -1180,27 +1191,61 @@ public final class DisplayManagerService extends SystemService { mContext.getContentResolver().registerContentObserver( Settings.Secure.getUriFor( Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED), false, this); if (mFlags.isDisplayContentModeManagementEnabled()) { mContext.getContentResolver().registerContentObserver( Settings.Secure.getUriFor( MIRROR_BUILT_IN_DISPLAY), false, this, UserHandle.USER_ALL); } } @Override public void onChange(boolean selfChange, Uri uri) { handleSettingsChange(); if (Settings.Secure.getUriFor( Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED).equals(uri)) { handleMinimalPostProcessingAllowedSettingChange(); return; } if (Settings.Secure.getUriFor(MIRROR_BUILT_IN_DISPLAY).equals(uri)) { if (mFlags.isDisplayContentModeManagementEnabled()) { updateMirrorBuiltInDisplaySettingLocked(); } return; } } } private void handleSettingsChange() { private void handleMinimalPostProcessingAllowedSettingChange() { synchronized (mSyncRoot) { updateSettingsLocked(); updateMinimalPostProcessingAllowedSettingLocked(); scheduleTraversalLocked(false); } } private void updateSettingsLocked() { private void updateMinimalPostProcessingAllowedSettingLocked() { setMinimalPostProcessingAllowed(Settings.Secure.getIntForUser( mContext.getContentResolver(), Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED, 1, UserHandle.USER_CURRENT) != 0); } private void updateMirrorBuiltInDisplaySettingLocked() { if (!mFlags.isDisplayContentModeManagementEnabled()) { Slog.e(TAG, "MirrorBuiltInDisplay setting shouldn't be updated when the flag is off."); return; } synchronized (mSyncRoot) { ContentResolver resolver = mContext.getContentResolver(); final boolean mirrorBuiltInDisplay = Settings.Secure.getIntForUser(resolver, MIRROR_BUILT_IN_DISPLAY, 0, UserHandle.USER_CURRENT) != 0; if (mMirrorBuiltInDisplay == mirrorBuiltInDisplay) { return; } mMirrorBuiltInDisplay = mirrorBuiltInDisplay; } } private void restoreResolutionFromBackup() { int savedMode = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.SCREEN_RESOLUTION_MODE, Loading services/core/java/com/android/server/display/feature/DisplayManagerFlags.java +9 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,10 @@ public class DisplayManagerFlags { Flags.FLAG_DISPLAY_LISTENER_PERFORMANCE_IMPROVEMENTS, Flags::displayListenerPerformanceImprovements ); private final FlagState mEnableDisplayContentModeManagementFlagState = new FlagState( Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT, Flags::enableDisplayContentModeManagement ); private final FlagState mSubscribeGranularDisplayEvents = new FlagState( Flags.FLAG_SUBSCRIBE_GRANULAR_DISPLAY_EVENTS, Loading Loading @@ -556,6 +560,10 @@ public class DisplayManagerFlags { return mDisplayListenerPerformanceImprovementsFlagState.isEnabled(); } public boolean isDisplayContentModeManagementEnabled() { return mEnableDisplayContentModeManagementFlagState.isEnabled(); } /** * @return {@code true} if the flag for subscribing to granular display events is enabled */ Loading Loading @@ -618,6 +626,7 @@ public class DisplayManagerFlags { pw.println(" " + mEnablePluginManagerFlagState); pw.println(" " + mDisplayListenerPerformanceImprovementsFlagState); pw.println(" " + mSubscribeGranularDisplayEvents); pw.println(" " + mEnableDisplayContentModeManagementFlagState); } private static class FlagState { Loading Loading
core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -10041,6 +10041,12 @@ public final class Settings { public static final String MINIMAL_POST_PROCESSING_ALLOWED = "minimal_post_processing_allowed"; /** * Whether to mirror the built-in display on all connected displays. * @hide */ public static final String MIRROR_BUILT_IN_DISPLAY = "mirror_built_in_display"; /** * No mode switching will happen. * Loading
packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ public class SecureSettings { Settings.Secure.RTT_CALLING_MODE, Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED, Settings.Secure.MIRROR_BUILT_IN_DISPLAY, Settings.Secure.MATCH_CONTENT_FRAME_RATE, Settings.Secure.NIGHT_DISPLAY_CUSTOM_START_TIME, Settings.Secure.NIGHT_DISPLAY_CUSTOM_END_TIME, Loading
packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ public class SecureSettingsValidators { Secure.INCALL_POWER_BUTTON_BEHAVIOR, new DiscreteValueValidator(new String[] {"1", "2"})); VALIDATORS.put(Secure.MINIMAL_POST_PROCESSING_ALLOWED, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.MIRROR_BUILT_IN_DISPLAY, BOOLEAN_VALIDATOR); VALIDATORS.put( Secure.MATCH_CONTENT_FRAME_RATE, new DiscreteValueValidator(new String[] {"0", "1", "2"})); Loading
services/core/java/com/android/server/display/DisplayManagerService.java +51 −6 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; import static android.os.Process.FIRST_APPLICATION_UID; import static android.os.Process.ROOT_UID; import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS; import static android.provider.Settings.Secure.MIRROR_BUILT_IN_DISPLAY; import static android.provider.Settings.Secure.RESOLUTION_MODE_FULL; import static android.provider.Settings.Secure.RESOLUTION_MODE_HIGH; import static android.provider.Settings.Secure.RESOLUTION_MODE_UNKNOWN; Loading @@ -71,6 +72,7 @@ import android.companion.virtual.VirtualDeviceManager; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; Loading Loading @@ -534,6 +536,8 @@ public final class DisplayManagerService extends SystemService { private final boolean mExtraDisplayEventLogging; private final String mExtraDisplayLoggingPackageName; private boolean mMirrorBuiltInDisplay; private final BroadcastReceiver mIdleModeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading Loading @@ -782,7 +786,11 @@ public final class DisplayManagerService extends SystemService { } dpc.onSwitchUser(newUserId, userSerial, newBrightness); }); handleSettingsChange(); handleMinimalPostProcessingAllowedSettingChange(); if (mFlags.isDisplayContentModeManagementEnabled()) { updateMirrorBuiltInDisplaySettingLocked(); } } } Loading Loading @@ -825,12 +833,15 @@ public final class DisplayManagerService extends SystemService { // relevant configuration should be in place. recordTopInsetLocked(mLogicalDisplayMapper.getDisplayLocked(Display.DEFAULT_DISPLAY)); updateSettingsLocked(); updateMinimalPostProcessingAllowedSettingLocked(); updateUserDisabledHdrTypesFromSettingsLocked(); updateUserPreferredDisplayModeSettingsLocked(); if (mIsHdrOutputControlEnabled) { updateHdrConversionModeSettingsLocked(); } if (mFlags.isDisplayContentModeManagementEnabled()) { updateMirrorBuiltInDisplaySettingLocked(); } } mDisplayModeDirector.setDesiredDisplayModeSpecsListener( Loading Loading @@ -1180,27 +1191,61 @@ public final class DisplayManagerService extends SystemService { mContext.getContentResolver().registerContentObserver( Settings.Secure.getUriFor( Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED), false, this); if (mFlags.isDisplayContentModeManagementEnabled()) { mContext.getContentResolver().registerContentObserver( Settings.Secure.getUriFor( MIRROR_BUILT_IN_DISPLAY), false, this, UserHandle.USER_ALL); } } @Override public void onChange(boolean selfChange, Uri uri) { handleSettingsChange(); if (Settings.Secure.getUriFor( Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED).equals(uri)) { handleMinimalPostProcessingAllowedSettingChange(); return; } if (Settings.Secure.getUriFor(MIRROR_BUILT_IN_DISPLAY).equals(uri)) { if (mFlags.isDisplayContentModeManagementEnabled()) { updateMirrorBuiltInDisplaySettingLocked(); } return; } } } private void handleSettingsChange() { private void handleMinimalPostProcessingAllowedSettingChange() { synchronized (mSyncRoot) { updateSettingsLocked(); updateMinimalPostProcessingAllowedSettingLocked(); scheduleTraversalLocked(false); } } private void updateSettingsLocked() { private void updateMinimalPostProcessingAllowedSettingLocked() { setMinimalPostProcessingAllowed(Settings.Secure.getIntForUser( mContext.getContentResolver(), Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED, 1, UserHandle.USER_CURRENT) != 0); } private void updateMirrorBuiltInDisplaySettingLocked() { if (!mFlags.isDisplayContentModeManagementEnabled()) { Slog.e(TAG, "MirrorBuiltInDisplay setting shouldn't be updated when the flag is off."); return; } synchronized (mSyncRoot) { ContentResolver resolver = mContext.getContentResolver(); final boolean mirrorBuiltInDisplay = Settings.Secure.getIntForUser(resolver, MIRROR_BUILT_IN_DISPLAY, 0, UserHandle.USER_CURRENT) != 0; if (mMirrorBuiltInDisplay == mirrorBuiltInDisplay) { return; } mMirrorBuiltInDisplay = mirrorBuiltInDisplay; } } private void restoreResolutionFromBackup() { int savedMode = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.SCREEN_RESOLUTION_MODE, Loading
services/core/java/com/android/server/display/feature/DisplayManagerFlags.java +9 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,10 @@ public class DisplayManagerFlags { Flags.FLAG_DISPLAY_LISTENER_PERFORMANCE_IMPROVEMENTS, Flags::displayListenerPerformanceImprovements ); private final FlagState mEnableDisplayContentModeManagementFlagState = new FlagState( Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT, Flags::enableDisplayContentModeManagement ); private final FlagState mSubscribeGranularDisplayEvents = new FlagState( Flags.FLAG_SUBSCRIBE_GRANULAR_DISPLAY_EVENTS, Loading Loading @@ -556,6 +560,10 @@ public class DisplayManagerFlags { return mDisplayListenerPerformanceImprovementsFlagState.isEnabled(); } public boolean isDisplayContentModeManagementEnabled() { return mEnableDisplayContentModeManagementFlagState.isEnabled(); } /** * @return {@code true} if the flag for subscribing to granular display events is enabled */ Loading Loading @@ -618,6 +626,7 @@ public class DisplayManagerFlags { pw.println(" " + mEnablePluginManagerFlagState); pw.println(" " + mDisplayListenerPerformanceImprovementsFlagState); pw.println(" " + mSubscribeGranularDisplayEvents); pw.println(" " + mEnableDisplayContentModeManagementFlagState); } private static class FlagState { Loading