Repurpose the blurs dev option for window blurs
Bug: 185580298 Test: make RunSettingsRoboTests ROBOTEST_FILTER=EnabledBlursPreferenceControllerTest Change-Id: I12e356c4a2997bf67580652e7d3fff9bb89483ac
This commit is contained in:
@@ -12896,9 +12896,7 @@
|
|||||||
<string name="hwui_force_dark_summary">Overrides the force-dark feature to be always-on</string>
|
<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] -->
|
<!-- If blurs are supported on SurfaceFlinger. [CHAR LIMIT=60] -->
|
||||||
<string name="enable_blurs_on_windows_title">Enable blurs</string>
|
<string name="enable_blurs_on_windows_title">Window-level 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>
|
|
||||||
|
|
||||||
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
|
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
|
||||||
<string name="privacy_dashboard_title">Privacy</string>
|
<string name="privacy_dashboard_title">Privacy</string>
|
||||||
|
@@ -492,8 +492,7 @@
|
|||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="enable_blurs_on_windows"
|
android:key="enable_blurs_on_windows"
|
||||||
android:title="@string/enable_blurs_on_windows_title"
|
android:title="@string/enable_blurs_on_windows_title"/>
|
||||||
android:summary="@string/enable_blurs_on_windows_summary" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="force_msaa"
|
android:key="force_msaa"
|
||||||
|
@@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import static android.view.CrossWindowBlurListeners.CROSS_WINDOW_BLUR_SUPPORTED;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemProperties;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -25,22 +27,18 @@ import androidx.preference.SwitchPreference;
|
|||||||
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
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
|
public final class EnableBlursPreferenceController extends DeveloperOptionsPreferenceController
|
||||||
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
|
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 static final String ENABLE_BLURS_ON_WINDOWS = "enable_blurs_on_windows";
|
||||||
private final boolean mBlurSupported;
|
private final boolean mBlurSupported;
|
||||||
|
|
||||||
public EnableBlursPreferenceController(Context context) {
|
public EnableBlursPreferenceController(Context context) {
|
||||||
this(context, SystemProperties
|
this(context, CROSS_WINDOW_BLUR_SUPPORTED);
|
||||||
.getBoolean("ro.surface_flinger.supports_background_blur", false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -56,9 +54,9 @@ public final class EnableBlursPreferenceController extends DeveloperOptionsPrefe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
final boolean isDisabled = !(Boolean) newValue;
|
boolean enabled = (Boolean) newValue;
|
||||||
SystemProperties.set(DISABLE_BLURS_SYSPROP, isDisabled ? "1" : "0");
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
SystemPropPoker.getInstance().poke();
|
Settings.Global.DISABLE_WINDOW_BLURS, enabled ? 0 : 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,15 +67,16 @@ public final class EnableBlursPreferenceController extends DeveloperOptionsPrefe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
boolean isEnabled = !SystemProperties.getBoolean(
|
boolean isEnabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
DISABLE_BLURS_SYSPROP, false /* default */);
|
Settings.Global.DISABLE_WINDOW_BLURS, 0) == 0;
|
||||||
((SwitchPreference) mPreference).setChecked(isEnabled);
|
((SwitchPreference) mPreference).setChecked(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDeveloperOptionsSwitchDisabled() {
|
protected void onDeveloperOptionsSwitchDisabled() {
|
||||||
super.onDeveloperOptionsSwitchDisabled();
|
super.onDeveloperOptionsSwitchDisabled();
|
||||||
SystemProperties.set(DISABLE_BLURS_SYSPROP, null);
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Global.DISABLE_WINDOW_BLURS, 0);
|
||||||
updateState(null);
|
updateState(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemProperties;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
@@ -65,26 +65,25 @@ public final class EnableBlursPreferenceControllerTest {
|
|||||||
public void onPreferenceChanged_settingEnabled_enableBlurs() {
|
public void onPreferenceChanged_settingEnabled_enableBlurs() {
|
||||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||||
|
|
||||||
final boolean mode = SystemProperties
|
final boolean blursDisabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
.getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP,
|
Settings.Global.DISABLE_WINDOW_BLURS, 0) == 1;
|
||||||
false /* default */);
|
assertThat(blursDisabled).isFalse();
|
||||||
assertThat(mode).isFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChanged_settingDisabled_disableBlurs() {
|
public void onPreferenceChanged_settingDisabled_disableBlurs() {
|
||||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||||
|
|
||||||
final boolean mode = SystemProperties
|
final boolean blursDisabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
.getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP,
|
Settings.Global.DISABLE_WINDOW_BLURS, 0) == 1;
|
||||||
false /* default */);
|
|
||||||
|
|
||||||
assertThat(mode).isTrue();
|
assertThat(blursDisabled).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingEnabled_preferenceShouldNotBeChecked() {
|
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);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(false);
|
verify(mPreference).setChecked(false);
|
||||||
@@ -92,7 +91,8 @@ public final class EnableBlursPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingDisabled_preferenceShouldBeChecked() {
|
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);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(true);
|
verify(mPreference).setChecked(true);
|
||||||
|
Reference in New Issue
Block a user