Merge "Use global setting instead of forceWindowBlurDisabled" into sc-dev

This commit is contained in:
Galia Peycheva
2021-04-26 11:42:49 +00:00
committed by Android (Google) Code Review
12 changed files with 65 additions and 62 deletions

View File

@@ -2102,6 +2102,7 @@ package android.provider {
field public static final String AUTOMATIC_POWER_SAVE_MODE = "automatic_power_save_mode";
field public static final String BATTERY_SAVER_CONSTANTS = "battery_saver_constants";
field public static final String DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW = "enable_non_resizable_multi_window";
field public static final String DISABLE_WINDOW_BLURS = "disable_window_blurs";
field public static final String DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD = "dynamic_power_savings_disable_threshold";
field public static final String DYNAMIC_POWER_SAVINGS_ENABLED = "dynamic_power_savings_enabled";
field public static final String HIDDEN_API_BLACKLIST_EXEMPTIONS = "hidden_api_blacklist_exemptions";
@@ -2779,7 +2780,6 @@ package android.view {
method public default void holdLock(android.os.IBinder, int);
method public default boolean isTaskSnapshotSupported();
method public default void setDisplayImePolicy(int, int);
method public default void setForceCrossWindowBlurDisabled(boolean);
method public default void setShouldShowSystemDecors(int, boolean);
method public default void setShouldShowWithInsecureKeyguard(int, boolean);
method public default boolean shouldShowSystemDecors(int);

View File

@@ -83,6 +83,7 @@ import android.util.ArraySet;
import android.util.Log;
import android.util.MemoryIntArray;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import com.android.internal.annotations.GuardedBy;
@@ -13371,6 +13372,19 @@ public final class Settings {
@Readable
public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
/**
* Setting to disable cross-window blurs. This includes window blur behind, (see
* {@link LayoutParams#setBlurBehindRadius}) and window background blur (see
* {@link Window#setBackgroundBlurRadius}).
*
* The value is a boolean (1 or 0).
* @hide
*/
@TestApi
@Readable
@SuppressLint("NoSettingsProvider")
public static final String DISABLE_WINDOW_BLURS = "disable_window_blurs";
/**
* Scaling factor for activity transition animations.
*

View File

@@ -857,7 +857,5 @@ interface IWindowManager
*/
void unregisterCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener);
void setForceCrossWindowBlurDisabled(boolean disable);
boolean isTaskSnapshotSupported();
}

View File

@@ -907,20 +907,6 @@ public interface WindowManager extends ViewManager {
default void removeCrossWindowBlurEnabledListener(@NonNull Consumer<Boolean> listener) {
}
/**
* Disables cross-window blurs device-wide. This includes window blur behind
* (see {@link LayoutParams#setBlurBehindRadius}) and window background blur
* (see {@link Window#setBackgroundBlurRadius}).
*
* @param disable specifies whether to disable the blur. Note that calling this
* with 'disable=false' will not enable blurs if there is something
* else disabling blurs.
* @hide
*/
@TestApi
default void setForceCrossWindowBlurDisabled(boolean disable) {
}
/**
* @hide
*/

View File

@@ -327,15 +327,6 @@ public final class WindowManagerImpl implements WindowManager {
CrossWindowBlurListeners.getInstance().removeListener(listener);
}
@Override
public void setForceCrossWindowBlurDisabled(boolean disable) {
try {
WindowManagerGlobal.getWindowManagerService()
.setForceCrossWindowBlurDisabled(disable);
} catch (RemoteException e) {
}
}
@Override
public boolean isTaskSnapshotSupported() {
try {

View File

@@ -285,6 +285,7 @@ message GlobalSettingsProto {
// Deprecated, use enable_non_resizable_multi_window
optional SettingProto enable_sizecompat_freeform = 7 [ (android.privacy).dest = DEST_AUTOMATIC, deprecated = true ];
optional SettingProto enable_non_resizable_multi_window = 8 [ (android.privacy).dest = DEST_AUTOMATIC ];
optional SettingProto disable_window_blurs = 9 [ (android.privacy).dest = DEST_AUTOMATIC ];
}
optional Development development = 39;

View File

@@ -138,6 +138,7 @@ public class GlobalSettingsValidators {
new InclusiveIntegerRangeValidator(
/* first= */Global.ONE_HANDED_KEYGUARD_SIDE_LEFT,
/* last= */Global.ONE_HANDED_KEYGUARD_SIDE_RIGHT));
VALIDATORS.put(Global.DISABLE_WINDOW_BLURS, BOOLEAN_VALIDATOR);
}
}

View File

@@ -553,6 +553,9 @@ class SettingsProtoDumpUtil {
dumpSetting(s, p,
Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW,
GlobalSettingsProto.Development.ENABLE_NON_RESIZABLE_MULTI_WINDOW);
dumpSetting(s, p,
Settings.Global.DISABLE_WINDOW_BLURS,
GlobalSettingsProto.Development.DISABLE_WINDOW_BLURS);
p.end(developmentToken);
final long deviceToken = p.start(GlobalSettingsProto.DEVICE);

View File

@@ -231,6 +231,7 @@ public class SettingsBackupTest {
Settings.Global.DEVELOPMENT_USE_BLAST_ADAPTER_VR,
Settings.Global.DEVELOPMENT_WM_DISPLAY_SETTINGS_PATH,
Settings.Global.DEVICE_DEMO_MODE,
Settings.Global.DISABLE_WINDOW_BLURS,
Settings.Global.BATTERY_SAVER_CONSTANTS,
Settings.Global.BATTERY_TIP_CONSTANTS,
Settings.Global.DEFAULT_SM_DP_PLUS,

View File

@@ -22,10 +22,12 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.net.ConnectivityManager;
import android.os.PowerManager;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.provider.Settings;
import android.view.ICrossWindowBlurEnabledListener;
import com.android.internal.annotations.GuardedBy;
@@ -36,7 +38,7 @@ import com.android.internal.annotations.GuardedBy;
* blur enabled state changes.
*/
final class BlurController {
private final PowerManager mPowerManager;
private final Context mContext;
private final RemoteCallbackList<ICrossWindowBlurEnabledListener>
mBlurEnabledListeners = new RemoteCallbackList<>();
// We don't use the WM global lock, because the BlurController is not involved in window
@@ -44,15 +46,11 @@ final class BlurController {
private final Object mLock = new Object();
@GuardedBy("mLock")
boolean mBlurEnabled;
@GuardedBy("mLock")
boolean mBlurForceDisabled;
@GuardedBy("mLock")
boolean mInBatterySaverMode;
private boolean mInPowerSaveMode;
private boolean mBlurDisabledSetting;
BlurController(Context context, PowerManager powerManager) {
mPowerManager = powerManager;
mInBatterySaverMode = mPowerManager.isPowerSaveMode();
updateBlurEnabledLocked();
mContext = context;
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
@@ -60,10 +58,30 @@ final class BlurController {
@Override
public void onReceive(Context context, Intent intent) {
if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(intent.getAction())) {
setBatterySaverEnabled(mPowerManager.isPowerSaveMode());
// onReceive always gets called on the same thread, so there is no
// multi-threaded execution here. Thus, we don't have to hold mLock here.
mInPowerSaveMode = powerManager.isPowerSaveMode();
updateBlurEnabled();
}
}
}, filter, null, null);
mInPowerSaveMode = powerManager.isPowerSaveMode();
context.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.DISABLE_WINDOW_BLURS), false,
new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
// onChange always gets called on the same thread, so there is no
// multi-threaded execution here. Thus, we don't have to hold mLock here.
mBlurDisabledSetting = getBlurDisabledSetting();
updateBlurEnabled();
}
});
mBlurDisabledSetting = getBlurDisabledSetting();
updateBlurEnabled();
}
boolean registerCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener) {
@@ -79,29 +97,16 @@ final class BlurController {
mBlurEnabledListeners.unregister(listener);
}
void setForceCrossWindowBlurDisabled(boolean disable) {
private void updateBlurEnabled() {
synchronized (mLock) {
mBlurForceDisabled = disable;
updateBlurEnabledLocked();
final boolean newEnabled = CROSS_WINDOW_BLUR_SUPPORTED && !mBlurDisabledSetting
&& !mInPowerSaveMode;
if (mBlurEnabled == newEnabled) {
return;
}
mBlurEnabled = newEnabled;
notifyBlurEnabledChangedLocked(newEnabled);
}
}
void setBatterySaverEnabled(boolean enabled) {
synchronized (mLock) {
mInBatterySaverMode = enabled;
updateBlurEnabledLocked();
}
}
private void updateBlurEnabledLocked() {
final boolean newEnabled = CROSS_WINDOW_BLUR_SUPPORTED && !mBlurForceDisabled
&& !mInBatterySaverMode;
if (mBlurEnabled == newEnabled) {
return;
}
mBlurEnabled = newEnabled;
notifyBlurEnabledChangedLocked(newEnabled);
}
private void notifyBlurEnabledChangedLocked(boolean enabled) {
@@ -117,4 +122,9 @@ final class BlurController {
}
mBlurEnabledListeners.finishBroadcast();
}
private boolean getBlurDisabledSetting() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DISABLE_WINDOW_BLURS, 0) == 1;
}
}

View File

@@ -5553,11 +5553,6 @@ public class WindowManagerService extends IWindowManager.Stub
mBlurController.unregisterCrossWindowBlurEnabledListener(listener);
}
@Override
public void setForceCrossWindowBlurDisabled(boolean disable) {
mBlurController.setForceCrossWindowBlurDisabled(disable);
}
// -------------------------------------------------------------
// Internals
// -------------------------------------------------------------

View File

@@ -31,6 +31,7 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ShellCommand;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.Display;
@@ -235,7 +236,9 @@ public class WindowManagerShellCommand extends ShellCommand {
return -1;
}
mInterface.setForceCrossWindowBlurDisabled(disableBlur);
Settings.Global.putInt(mInternal.mContext.getContentResolver(),
Settings.Global.DISABLE_WINDOW_BLURS, disableBlur ? 1 : 0);
return 0;
}