Make WM.LP.blurBehindRadius a setter+getter

Bug: 181014794
Test: m && atest BlurTests
CTS-Coverage-Bug: 179990440
Change-Id: I3d8ceddcf1219df8decbbb0bf9a6bbb9d41799fb
This commit is contained in:
Galia Peycheva
2021-02-23 18:39:59 +01:00
parent fdcfd2a2d5
commit 7fe1a92c60
5 changed files with 54 additions and 18 deletions

View File

@@ -50181,12 +50181,14 @@ package android.view {
method public final int copyFrom(android.view.WindowManager.LayoutParams);
method public String debug(String);
method public int describeContents();
method public int getBlurBehindRadius();
method public int getColorMode();
method public int getFitInsetsSides();
method public int getFitInsetsTypes();
method public final CharSequence getTitle();
method public boolean isFitInsetsIgnoringVisibility();
method public static boolean mayUseInputMethod(int);
method public void setBlurBehindRadius(@IntRange(from=0) int);
method public void setColorMode(int);
method public void setFitInsetsIgnoringVisibility(boolean);
method public void setFitInsetsSides(int);
@@ -50297,7 +50299,6 @@ package android.view {
field @Deprecated public static final int TYPE_TOAST = 2005; // 0x7d5
field public static final int TYPE_WALLPAPER = 2013; // 0x7dd
field public float alpha;
field public int blurBehindRadius;
field public float buttonBrightness;
field public float dimAmount;
field public int flags;

View File

@@ -1716,13 +1716,14 @@ public abstract class Window {
* For the blur region to be visible, the window has to be translucent. See
* {@link android.R.styleable#Window_windowIsTranslucent}.
*
* Note the difference with {@link android.view.WindowManager.LayoutParams#blurBehindRadius},
* Note the difference with {@link WindowManager.LayoutParams#setBlurBehindRadius},
* which blurs the whole screen behind the window. Background blur blurs the screen behind
* only within the bounds of the window.
*
* @param blurRadius The blur radius to use for window background blur in pixels
*
* @see android.R.styleable#Window_windowBackgroundBlurRadius
* @see WindowManager.LayoutParams#setBlurBehindRadius
*/
public void setBackgroundBlurRadius(int blurRadius) {}

View File

@@ -82,6 +82,7 @@ import static android.view.WindowLayoutParamsProto.Y;
import android.Manifest.permission;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -3238,9 +3239,9 @@ public interface WindowManager extends ViewManager {
* The blur behind radius range starts at 0, which means no blur, and increases until 150
* for the densest blur.
*
* @see #FLAG_BLUR_BEHIND
* @see #setBlurBehindRadius
*/
public int blurBehindRadius = 0;
private int mBlurBehindRadius = 0;
/**
* The color mode requested by this window. The target display may
@@ -3534,6 +3535,40 @@ public interface WindowManager extends ViewManager {
return mColorMode;
}
/**
* Blurs the screen behind the window. The effect is similar to that of {@link #dimAmount},
* but instead of dimmed, the content behind the window will be blurred.
*
* The density of the blur is set by the blur radius. The radius defines the size
* of the neighbouring area, from which pixels will be averaged to form the final
* color for each pixel. The operation approximates a Gaussian blur.
* A radius of 0 means no blur. The higher the radius, the denser the blur.
*
* Note the difference with {@link android.view.Window#setBackgroundBlurRadius},
* which blurs only within the bounds of the window. Blur behind blurs the whole screen
* behind the window.
*
* Requires {@link #FLAG_BLUR_BEHIND} to be set.
*
* @param blurBehindRadius The blur radius to use for blur behind in pixels
*
* @see #FLAG_BLUR_BEHIND
* @see #getBlurBehindRadius
* @see Window#setBackgroundBlurRadius
*/
public void setBlurBehindRadius(@IntRange(from = 0) int blurBehindRadius) {
mBlurBehindRadius = blurBehindRadius;
}
/**
* Returns the blur behind radius of the window.
*
* @see #setBlurBehindRadius
*/
public int getBlurBehindRadius() {
return mBlurBehindRadius;
}
/** @hide */
@SystemApi
public final void setUserActivityTimeout(long timeout) {
@@ -3629,7 +3664,7 @@ public interface WindowManager extends ViewManager {
out.writeInt(mFitInsetsSides);
out.writeBoolean(mFitInsetsIgnoringVisibility);
out.writeBoolean(preferMinimalPostProcessing);
out.writeInt(blurBehindRadius);
out.writeInt(mBlurBehindRadius);
if (providesInsetsTypes != null) {
out.writeInt(providesInsetsTypes.length);
out.writeIntArray(providesInsetsTypes);
@@ -3698,7 +3733,7 @@ public interface WindowManager extends ViewManager {
mFitInsetsSides = in.readInt();
mFitInsetsIgnoringVisibility = in.readBoolean();
preferMinimalPostProcessing = in.readBoolean();
blurBehindRadius = in.readInt();
mBlurBehindRadius = in.readInt();
int insetsTypesLength = in.readInt();
if (insetsTypesLength > 0) {
providesInsetsTypes = new int[insetsTypesLength];
@@ -3752,7 +3787,7 @@ public interface WindowManager extends ViewManager {
/** {@hide} */
public static final int MINIMAL_POST_PROCESSING_PREFERENCE_CHANGED = 1 << 28;
/** {@hide} */
public static final int BACKGROUND_BLUR_RADIUS_CHANGED = 1 << 29;
public static final int BLUR_BEHIND_RADIUS_CHANGED = 1 << 29;
// internal buffer to backup/restore parameters under compatibility mode.
private int[] mCompatibilityParamsBackup = null;
@@ -3943,9 +3978,9 @@ public interface WindowManager extends ViewManager {
changes |= MINIMAL_POST_PROCESSING_PREFERENCE_CHANGED;
}
if (blurBehindRadius != o.blurBehindRadius) {
blurBehindRadius = o.blurBehindRadius;
changes |= BACKGROUND_BLUR_RADIUS_CHANGED;
if (mBlurBehindRadius != o.mBlurBehindRadius) {
mBlurBehindRadius = o.mBlurBehindRadius;
changes |= BLUR_BEHIND_RADIUS_CHANGED;
}
// This can't change, it's only set at window creation time.
@@ -4111,9 +4146,9 @@ public interface WindowManager extends ViewManager {
sb.append(" preferMinimalPostProcessing=");
sb.append(preferMinimalPostProcessing);
}
if (blurBehindRadius != 0) {
if (mBlurBehindRadius != 0) {
sb.append(" blurBehindRadius=");
sb.append(blurBehindRadius);
sb.append(mBlurBehindRadius);
}
sb.append(System.lineSeparator());
sb.append(prefix).append(" fl=").append(

View File

@@ -2556,8 +2556,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
params.flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
}
params.blurBehindRadius = a.getDimensionPixelSize(
android.R.styleable.Window_windowBlurBehindRadius, 0);
params.setBlurBehindRadius(a.getDimensionPixelSize(
android.R.styleable.Window_windowBlurBehindRadius, 0));
}
setBackgroundBlurRadius(a.getDimensionPixelSize(

View File

@@ -5268,16 +5268,15 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
} else if (((mAttrs.flags & FLAG_DIM_BEHIND) != 0 || (mAttrs.flags & FLAG_BLUR_BEHIND) != 0)
&& isVisibleNow() && !mHidden) {
// Only show the Dimmer when the following is satisfied:
// 1. The window has the flag FLAG_DIM_BEHIND or background blur is requested
// 1. The window has the flag FLAG_DIM_BEHIND or blur behind is requested
// 2. The WindowToken is not hidden so dims aren't shown when the window is exiting.
// 3. The WS is considered visible according to the isVisible() method
// 4. The WS is not hidden.
mIsDimming = true;
final float dimAmount = (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? mAttrs.dimAmount : 0;
final int blurRadius =
(mAttrs.flags & FLAG_BLUR_BEHIND) != 0 ? mAttrs.blurBehindRadius : 0;
getDimmer().dimBelow(
getSyncTransaction(), this, mAttrs.dimAmount, mAttrs.blurBehindRadius);
(mAttrs.flags & FLAG_BLUR_BEHIND) != 0 ? mAttrs.getBlurBehindRadius() : 0;
getDimmer().dimBelow(getSyncTransaction(), this, mAttrs.dimAmount, blurRadius);
}
}