Loading res/values/strings.xml +1 −3 Original line number Diff line number Diff line Loading @@ -12912,9 +12912,7 @@ <string name="hwui_force_dark_summary">Overrides the force-dark feature to be always-on</string> <!-- If blurs are supported on SurfaceFlinger. [CHAR LIMIT=60] --> <string name="enable_blurs_on_windows_title">Enable blurs</string> <!-- If blurs are supported on SurfaceFlinger, summary. [CHAR LIMIT=NONE] --> <string name="enable_blurs_on_windows_summary">Enables window blurs at compositor level. Requires device reboot.</string> <string name="enable_blurs_on_windows_title">Window-level blurs</string> <!-- Title for the top level Privacy Settings [CHAR LIMIT=30]--> <string name="privacy_dashboard_title">Privacy</string> res/xml/development_settings.xml +1 −2 Original line number Diff line number Diff line Loading @@ -492,8 +492,7 @@ <SwitchPreference android:key="enable_blurs_on_windows" android:title="@string/enable_blurs_on_windows_title" android:summary="@string/enable_blurs_on_windows_summary" /> android:title="@string/enable_blurs_on_windows_title"/> <SwitchPreference android:key="force_msaa" Loading src/com/android/settings/development/EnableBlursPreferenceController.java +12 −13 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.settings.development; import static android.view.CrossWindowBlurListeners.CROSS_WINDOW_BLUR_SUPPORTED; import android.content.Context; import android.os.SystemProperties; import android.provider.Settings; import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; Loading @@ -25,22 +27,18 @@ import androidx.preference.SwitchPreference; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.SystemPropPoker; /** * Controller that toggles window blurs on SurfaceFlinger on devices that support it. * Controller that toggles window blurs on devices that support it. */ public final class EnableBlursPreferenceController extends DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin { @VisibleForTesting static final String DISABLE_BLURS_SYSPROP = "persist.sys.sf.disable_blurs"; private static final String ENABLE_BLURS_ON_WINDOWS = "enable_blurs_on_windows"; private final boolean mBlurSupported; public EnableBlursPreferenceController(Context context) { this(context, SystemProperties .getBoolean("ro.surface_flinger.supports_background_blur", false)); this(context, CROSS_WINDOW_BLUR_SUPPORTED); } @VisibleForTesting Loading @@ -56,9 +54,9 @@ public final class EnableBlursPreferenceController extends DeveloperOptionsPrefe @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean isDisabled = !(Boolean) newValue; SystemProperties.set(DISABLE_BLURS_SYSPROP, isDisabled ? "1" : "0"); SystemPropPoker.getInstance().poke(); boolean enabled = (Boolean) newValue; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, enabled ? 0 : 1); return true; } Loading @@ -69,15 +67,16 @@ public final class EnableBlursPreferenceController extends DeveloperOptionsPrefe @Override public void updateState(Preference preference) { boolean isEnabled = !SystemProperties.getBoolean( DISABLE_BLURS_SYSPROP, false /* default */); boolean isEnabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0) == 0; ((SwitchPreference) mPreference).setChecked(isEnabled); } @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); SystemProperties.set(DISABLE_BLURS_SYSPROP, null); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0); updateState(null); } } tests/robotests/src/com/android/settings/development/EnableBlursPreferenceControllerTest.java +11 −11 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.os.SystemProperties; import android.provider.Settings; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; Loading Loading @@ -65,26 +65,25 @@ public final class EnableBlursPreferenceControllerTest { public void onPreferenceChanged_settingEnabled_enableBlurs() { mController.onPreferenceChange(mPreference, true /* new value */); final boolean mode = SystemProperties .getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, false /* default */); assertThat(mode).isFalse(); final boolean blursDisabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0) == 1; assertThat(blursDisabled).isFalse(); } @Test public void onPreferenceChanged_settingDisabled_disableBlurs() { mController.onPreferenceChange(mPreference, false /* new value */); final boolean mode = SystemProperties .getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, false /* default */); final boolean blursDisabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0) == 1; assertThat(mode).isTrue(); assertThat(blursDisabled).isTrue(); } @Test public void updateState_settingEnabled_preferenceShouldNotBeChecked() { SystemProperties.set(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, "1"); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 1); mController.updateState(mPreference); verify(mPreference).setChecked(false); Loading @@ -92,7 +91,8 @@ public final class EnableBlursPreferenceControllerTest { @Test public void updateState_settingDisabled_preferenceShouldBeChecked() { SystemProperties.set(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, "0"); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0); mController.updateState(mPreference); verify(mPreference).setChecked(true); Loading Loading
res/values/strings.xml +1 −3 Original line number Diff line number Diff line Loading @@ -12912,9 +12912,7 @@ <string name="hwui_force_dark_summary">Overrides the force-dark feature to be always-on</string> <!-- If blurs are supported on SurfaceFlinger. [CHAR LIMIT=60] --> <string name="enable_blurs_on_windows_title">Enable blurs</string> <!-- If blurs are supported on SurfaceFlinger, summary. [CHAR LIMIT=NONE] --> <string name="enable_blurs_on_windows_summary">Enables window blurs at compositor level. Requires device reboot.</string> <string name="enable_blurs_on_windows_title">Window-level blurs</string> <!-- Title for the top level Privacy Settings [CHAR LIMIT=30]--> <string name="privacy_dashboard_title">Privacy</string>
res/xml/development_settings.xml +1 −2 Original line number Diff line number Diff line Loading @@ -492,8 +492,7 @@ <SwitchPreference android:key="enable_blurs_on_windows" android:title="@string/enable_blurs_on_windows_title" android:summary="@string/enable_blurs_on_windows_summary" /> android:title="@string/enable_blurs_on_windows_title"/> <SwitchPreference android:key="force_msaa" Loading
src/com/android/settings/development/EnableBlursPreferenceController.java +12 −13 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.settings.development; import static android.view.CrossWindowBlurListeners.CROSS_WINDOW_BLUR_SUPPORTED; import android.content.Context; import android.os.SystemProperties; import android.provider.Settings; import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; Loading @@ -25,22 +27,18 @@ import androidx.preference.SwitchPreference; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.SystemPropPoker; /** * Controller that toggles window blurs on SurfaceFlinger on devices that support it. * Controller that toggles window blurs on devices that support it. */ public final class EnableBlursPreferenceController extends DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin { @VisibleForTesting static final String DISABLE_BLURS_SYSPROP = "persist.sys.sf.disable_blurs"; private static final String ENABLE_BLURS_ON_WINDOWS = "enable_blurs_on_windows"; private final boolean mBlurSupported; public EnableBlursPreferenceController(Context context) { this(context, SystemProperties .getBoolean("ro.surface_flinger.supports_background_blur", false)); this(context, CROSS_WINDOW_BLUR_SUPPORTED); } @VisibleForTesting Loading @@ -56,9 +54,9 @@ public final class EnableBlursPreferenceController extends DeveloperOptionsPrefe @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean isDisabled = !(Boolean) newValue; SystemProperties.set(DISABLE_BLURS_SYSPROP, isDisabled ? "1" : "0"); SystemPropPoker.getInstance().poke(); boolean enabled = (Boolean) newValue; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, enabled ? 0 : 1); return true; } Loading @@ -69,15 +67,16 @@ public final class EnableBlursPreferenceController extends DeveloperOptionsPrefe @Override public void updateState(Preference preference) { boolean isEnabled = !SystemProperties.getBoolean( DISABLE_BLURS_SYSPROP, false /* default */); boolean isEnabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0) == 0; ((SwitchPreference) mPreference).setChecked(isEnabled); } @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); SystemProperties.set(DISABLE_BLURS_SYSPROP, null); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0); updateState(null); } }
tests/robotests/src/com/android/settings/development/EnableBlursPreferenceControllerTest.java +11 −11 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.os.SystemProperties; import android.provider.Settings; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; Loading Loading @@ -65,26 +65,25 @@ public final class EnableBlursPreferenceControllerTest { public void onPreferenceChanged_settingEnabled_enableBlurs() { mController.onPreferenceChange(mPreference, true /* new value */); final boolean mode = SystemProperties .getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, false /* default */); assertThat(mode).isFalse(); final boolean blursDisabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0) == 1; assertThat(blursDisabled).isFalse(); } @Test public void onPreferenceChanged_settingDisabled_disableBlurs() { mController.onPreferenceChange(mPreference, false /* new value */); final boolean mode = SystemProperties .getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, false /* default */); final boolean blursDisabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0) == 1; assertThat(mode).isTrue(); assertThat(blursDisabled).isTrue(); } @Test public void updateState_settingEnabled_preferenceShouldNotBeChecked() { SystemProperties.set(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, "1"); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 1); mController.updateState(mPreference); verify(mPreference).setChecked(false); Loading @@ -92,7 +91,8 @@ public final class EnableBlursPreferenceControllerTest { @Test public void updateState_settingDisabled_preferenceShouldBeChecked() { SystemProperties.set(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, "0"); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, 0); mController.updateState(mPreference); verify(mPreference).setChecked(true); Loading