Repurpose the blurs dev option for window blurs
Bug: 185580298 Test: make RunSettingsRoboTests ROBOTEST_FILTER=EnabledBlursPreferenceControllerTest Change-Id: I12e356c4a2997bf67580652e7d3fff9bb89483ac
This commit is contained in:
@@ -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;
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user