From 3804d61f2acd9e499724f48df9e3300fb1dbc397 Mon Sep 17 00:00:00 2001 From: Galia Peycheva Date: Fri, 22 Jan 2021 13:50:16 +0000 Subject: [PATCH] Revert "Make window background blurs SystemApi" Revert "Add permission check for blurs in SurfaceFlinger" Revert "Remove public usages of FLAG_BLUR_BEHIND" Revert "Add pid and uid to SF::setClientStateLocked" Revert "Add USE_BACKGROUND_BLUR to cts expected permissions" Revert submission 13350963-blur_system_api Reason for revert: This topic made blurs a system api. API council voted against that and we will instead aim to make it public for S. None of these changes are relevant in that case. Reverted Changes: I3683db296:Remove public usages of FLAG_BLUR_BEHIND I23b21b603:Add USE_BACKGROUND_BLUR to cts expected permission... Id21f03793:Add pid and uid to SF::setClientStateLocked If5d8344a5:Add permission for blur SystemApi I70d1e1715:Add permission check for blurs in SurfaceFlinger Icf98c3607:Make window background blurs SystemApi I0b881ec6e:Make BackgroundBlurDrawable a SystemApi Bug: 177523043 Test: m Change-Id: I0f7bcf34db2986d8d5e08b115a611e8e07db5917 Merged-In: I0f7bcf34db2986d8d5e08b115a611e8e07db5917 --- core/api/current.txt | 15 +++++++------ core/api/system-current.txt | 4 ---- core/java/android/view/WindowManager.java | 16 ++++---------- .../android/internal/policy/PhoneWindow.java | 10 ++------- core/res/res/values/attrs.xml | 16 ++++---------- core/res/res/values/public.xml | 3 --- .../java/com/android/server/wm/Session.java | 4 ---- .../server/wm/WindowManagerService.java | 2 +- .../com/android/server/wm/WindowState.java | 22 +++++-------------- .../android/server/wm/DisplayAreaTest.java | 2 +- .../android/server/wm/WindowTestsBase.java | 5 ++--- 11 files changed, 28 insertions(+), 71 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 3efb78943bd72..276efeceb0c6d 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -657,7 +657,7 @@ package android { field @Deprecated public static final int fontProviderCerts = 16844125; // 0x101055d field @Deprecated public static final int fontProviderPackage = 16844119; // 0x1010557 field @Deprecated public static final int fontProviderQuery = 16844113; // 0x1010551 - field public static final int fontProviderSystemFontFamily = 16844322; // 0x1010622 + field public static final int fontProviderSystemFontFamily = 16844321; // 0x1010621 field public static final int fontStyle = 16844095; // 0x101053f field public static final int fontVariationSettings = 16844144; // 0x1010570 field public static final int fontWeight = 16844083; // 0x1010533 @@ -722,7 +722,7 @@ package android { field public static final int gwpAsanMode = 16844310; // 0x1010616 field public static final int hand_hour = 16843011; // 0x1010103 field public static final int hand_minute = 16843012; // 0x1010104 - field public static final int hand_second = 16844323; // 0x1010623 + field public static final int hand_second = 16844322; // 0x1010622 field public static final int handle = 16843354; // 0x101025a field public static final int handleProfiling = 16842786; // 0x1010022 field public static final int hapticFeedbackEnabled = 16843358; // 0x101025e @@ -1057,11 +1057,11 @@ package android { field public static final int parentActivityName = 16843687; // 0x10103a7 field @Deprecated public static final int password = 16843100; // 0x101015c field public static final int path = 16842794; // 0x101002a - field public static final int pathAdvancedPattern = 16844320; // 0x1010620 + field public static final int pathAdvancedPattern = 16844319; // 0x101061f field public static final int pathData = 16843781; // 0x1010405 field public static final int pathPattern = 16842796; // 0x101002c field public static final int pathPrefix = 16842795; // 0x101002b - field public static final int pathSuffix = 16844318; // 0x101061e + field public static final int pathSuffix = 16844317; // 0x101061d field public static final int patternPathData = 16843978; // 0x10104ca field public static final int permission = 16842758; // 0x1010006 field public static final int permissionFlags = 16843719; // 0x10103c7 @@ -1154,7 +1154,7 @@ package android { field public static final int reqNavigation = 16843306; // 0x101022a field public static final int reqTouchScreen = 16843303; // 0x1010227 field public static final int requestLegacyExternalStorage = 16844291; // 0x1010603 - field public static final int requireDeviceScreenOn = 16844317; // 0x101061d + field public static final int requireDeviceScreenOn = 16844316; // 0x101061c field public static final int requireDeviceUnlock = 16843756; // 0x10103ec field public static final int required = 16843406; // 0x101028e field public static final int requiredAccountType = 16843734; // 0x10103d6 @@ -1295,10 +1295,10 @@ package android { field public static final int spotShadowAlpha = 16843967; // 0x10104bf field public static final int src = 16843033; // 0x1010119 field public static final int ssp = 16843747; // 0x10103e3 - field public static final int sspAdvancedPattern = 16844321; // 0x1010621 + field public static final int sspAdvancedPattern = 16844320; // 0x1010620 field public static final int sspPattern = 16843749; // 0x10103e5 field public static final int sspPrefix = 16843748; // 0x10103e4 - field public static final int sspSuffix = 16844319; // 0x101061f + field public static final int sspSuffix = 16844318; // 0x101061e field public static final int stackFromBottom = 16843005; // 0x10100fd field public static final int stackViewStyle = 16843838; // 0x101043e field public static final int starStyle = 16842882; // 0x1010082 @@ -49586,6 +49586,7 @@ package android.view { field public static final int FLAGS_CHANGED = 4; // 0x4 field public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 1; // 0x1 field public static final int FLAG_ALT_FOCUSABLE_IM = 131072; // 0x20000 + field @Deprecated public static final int FLAG_BLUR_BEHIND = 4; // 0x4 field public static final int FLAG_DIM_BEHIND = 2; // 0x2 field @Deprecated public static final int FLAG_DISMISS_KEYGUARD = 4194304; // 0x400000 field @Deprecated public static final int FLAG_DITHER = 4096; // 0x1000 diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 0ae22f86c3cb1..0e33d1e766520 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -295,8 +295,6 @@ package android { field public static final int sdkVersion = 16844304; // 0x1010610 field public static final int supportsAmbientMode = 16844173; // 0x101058d field public static final int userRestriction = 16844164; // 0x1010584 - field public static final int windowBackgroundBlurEnabled = 16844316; // 0x101061c - field public static final int windowBackgroundBlurRadius = 16844315; // 0x101061b } public static final class R.bool { @@ -14090,10 +14088,8 @@ package android.view { method public boolean isSystemApplicationOverlay(); method @RequiresPermission(android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY) public void setSystemApplicationOverlay(boolean); method public final void setUserActivityTimeout(long); - field @RequiresPermission(android.Manifest.permission.USE_BACKGROUND_BLUR) public static final int FLAG_BLUR_BEHIND = 4; // 0x4 field @RequiresPermission(android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS) public static final int SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 524288; // 0x80000 field @RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) public static final int SYSTEM_FLAG_SHOW_FOR_ALL_USERS = 16; // 0x10 - field @RequiresPermission(android.Manifest.permission.USE_BACKGROUND_BLUR) public int backgroundBlurRadius; } @IntDef(flag=true, prefix={"SYSTEM_FLAG_"}, value={android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, android.view.WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) public static @interface WindowManager.LayoutParams.SystemFlags { diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 8319b74d9cdf5..63f1eedf1c500 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1511,13 +1511,9 @@ public interface WindowManager extends ViewManager { * Use {@link #dimAmount} to control the amount of dim. */ public static final int FLAG_DIM_BEHIND = 0x00000002; - /** Window flag: enable blurring behind this window. - * To set the amount of blur, use {@link #backgroundBlurRadius} - * - * @hide - */ - @RequiresPermission(permission.USE_BACKGROUND_BLUR) - @SystemApi + /** Window flag: blur everything behind this window. + * @deprecated Blurring is no longer supported. */ + @Deprecated public static final int FLAG_BLUR_BEHIND = 0x00000004; /** Window flag: this window won't ever get key input focus, so the @@ -3237,14 +3233,10 @@ public interface WindowManager extends ViewManager { public boolean preferMinimalPostProcessing = false; /** - * When {@link FLAG_BLUR_BEHIND} is set, this is the amount of blur in pixels that this - * window will use to blur behind itself. - * The range is from 0, which means no blur, to 150. + * Indicates that this window wants to have blurred content behind it. * * @hide */ - @SystemApi - @RequiresPermission(permission.USE_BACKGROUND_BLUR) public int backgroundBlurRadius = 0; /** diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 3be841cb2431d..141dc79f4c932 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -2540,14 +2540,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } - if (a.getBoolean(R.styleable.Window_windowBackgroundBlurEnabled, false)) { - if ((getForcedWindowFlags() & WindowManager.LayoutParams.FLAG_BLUR_BEHIND) == 0) { - params.flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND; - } - - params.backgroundBlurRadius = a.getDimensionPixelSize( - android.R.styleable.Window_windowBackgroundBlurRadius, 0); - } + params.backgroundBlurRadius = a.getDimensionPixelSize( + R.styleable.Window_windowBackgroundBlurRadius, 0); if (params.windowAnimations == 0) { params.windowAnimations = a.getResourceId( diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 07c3adfb4c698..26fb8b8b0c830 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -87,16 +87,6 @@ theme does not set this value, meaning it is based on whether the window is floating. --> - - - - - - @@ -1974,8 +1964,6 @@ - - @@ -2193,6 +2181,10 @@ the decor view. --> + + + + - - - diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java index 3d3e31da469c8..8d8bdcba7583e 100644 --- a/services/core/java/com/android/server/wm/Session.java +++ b/services/core/java/com/android/server/wm/Session.java @@ -22,7 +22,6 @@ import static android.Manifest.permission.HIDE_OVERLAY_WINDOWS; import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; import static android.Manifest.permission.START_TASKS_FROM_RECENTS; import static android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY; -import static android.Manifest.permission.USE_BACKGROUND_BLUR; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.content.ClipDescription.MIMETYPE_APPLICATION_ACTIVITY; import static android.content.ClipDescription.MIMETYPE_APPLICATION_SHORTCUT; @@ -111,7 +110,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { final boolean mCanCreateSystemApplicationOverlay; final boolean mCanHideNonSystemOverlayWindows; final boolean mCanAcquireSleepToken; - final boolean mCanUseBackgroundBlur; private AlertWindowNotification mAlertWindowNotification; private boolean mShowingAlertWindowNotificationAllowed; private boolean mClientDead = false; @@ -142,8 +140,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { && !mService.mAtmInternal.isCallerRecents(mUid); mCanAcquireSleepToken = service.mContext.checkCallingOrSelfPermission(DEVICE_POWER) == PERMISSION_GRANTED; - mCanUseBackgroundBlur = service.mContext.checkCallingOrSelfPermission(USE_BACKGROUND_BLUR) - == PERMISSION_GRANTED; mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications; mDragDropController = mService.mDragDropController; StringBuilder sb = new StringBuilder(); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 931f52933e2af..1cc623988af81 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1652,7 +1652,7 @@ public class WindowManagerService extends IWindowManager.Stub final WindowState win = new WindowState(this, session, client, token, parentWindow, appOp[0], attrs, viewVisibility, session.mUid, userId, - session.mCanAddInternalSystemWindow, session.mCanUseBackgroundBlur); + session.mCanAddInternalSystemWindow); if (win.mDeathRecipient == null) { // Client has apparently died, so there is no reason to // continue. diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 025037688c8cd..c6985915de688 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -45,7 +45,6 @@ import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON; import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; -import static android.view.WindowManager.LayoutParams.FLAG_BLUR_BEHIND; import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND; import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; @@ -297,8 +296,6 @@ class WindowState extends WindowContainer implements WindowManagerP final int mShowUserId; /** The owner has {@link android.Manifest.permission#INTERNAL_SYSTEM_WINDOW} */ final boolean mOwnerCanAddInternalSystemWindow; - /** The owner has {@link android.Manifest.permission#USE_BACKGROUND_BLUR} */ - final boolean mOwnerCanUseBackgroundBlur; final WindowId mWindowId; WindowToken mToken; // The same object as mToken if this is an app window and null for non-app windows. @@ -897,11 +894,9 @@ class WindowState extends WindowContainer implements WindowManagerP WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, WindowState parentWindow, int appOp, WindowManager.LayoutParams a, int viewVisibility, - int ownerId, int showUserId, boolean ownerCanAddInternalSystemWindow, - boolean ownerCanUseBackgroundBlur) { + int ownerId, int showUserId, boolean ownerCanAddInternalSystemWindow) { this(service, s, c, token, parentWindow, appOp, a, viewVisibility, ownerId, showUserId, - ownerCanAddInternalSystemWindow, ownerCanUseBackgroundBlur, - new PowerManagerWrapper() { + ownerCanAddInternalSystemWindow, new PowerManagerWrapper() { @Override public void wakeUp(long time, @WakeReason int reason, String details) { service.mPowerManager.wakeUp(time, reason, details); @@ -917,7 +912,7 @@ class WindowState extends WindowContainer implements WindowManagerP WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, WindowState parentWindow, int appOp, WindowManager.LayoutParams a, int viewVisibility, int ownerId, int showUserId, boolean ownerCanAddInternalSystemWindow, - boolean ownerCanUseBackgroundBlur, PowerManagerWrapper powerManagerWrapper) { + PowerManagerWrapper powerManagerWrapper) { super(service); mTmpTransaction = service.mTransactionFactory.get(); mSession = s; @@ -928,7 +923,6 @@ class WindowState extends WindowContainer implements WindowManagerP mOwnerUid = ownerId; mShowUserId = showUserId; mOwnerCanAddInternalSystemWindow = ownerCanAddInternalSystemWindow; - mOwnerCanUseBackgroundBlur = ownerCanUseBackgroundBlur; mWindowId = new WindowId(this); mAttrs.copyFrom(a); mLastSurfaceInsets.set(mAttrs.surfaceInsets); @@ -5275,7 +5269,7 @@ class WindowState extends WindowContainer implements WindowManagerP if (!mAnimatingExit && mAppDied) { mIsDimming = true; getDimmer().dimAbove(getSyncTransaction(), this, DEFAULT_DIM_AMOUNT_DEAD_WINDOW); - } else if (((mAttrs.flags & FLAG_DIM_BEHIND) != 0 || isBlurEnabled()) + } else if (((mAttrs.flags & FLAG_DIM_BEHIND) != 0 || mAttrs.backgroundBlurRadius != 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 @@ -5284,15 +5278,11 @@ class WindowState extends WindowContainer implements WindowManagerP // 4. The WS is not hidden. mIsDimming = true; final float dimAmount = (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? mAttrs.dimAmount : 0; - final int blurRadius = isBlurEnabled() ? mAttrs.backgroundBlurRadius : 0; - getDimmer().dimBelow(getSyncTransaction(), this, dimAmount, blurRadius); + getDimmer().dimBelow( + getSyncTransaction(), this, mAttrs.dimAmount, mAttrs.backgroundBlurRadius); } } - private boolean isBlurEnabled() { - return (mAttrs.flags & FLAG_BLUR_BEHIND) != 0 && mOwnerCanUseBackgroundBlur; - } - /** * Notifies SF about the priority of the window, if it changed. SF then uses this information * to decide which window's desired rendering rate should have a priority when deciding about diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java index 91fd7a2ad0c1f..89b962b96baf8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java @@ -541,7 +541,7 @@ public class DisplayAreaTest extends WindowTestsBase { return new WindowState(mWm, mock(Session.class), new TestIWindow(), token, null /* parentWindow */, 0 /* appOp */, new WindowManager.LayoutParams(), View.VISIBLE, 0 /* ownerId */, 0 /* showUserId */, - false /* ownerCanAddInternalSystemWindow */, false /* ownerCanUseBackgroundBlur */); + false /* ownerCanAddInternalSystemWindow */); } private WindowToken createWindowToken(int type) { diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java index 8b604a32c512e..3492d90cc0f32 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java @@ -340,7 +340,7 @@ class WindowTestsBase extends SystemServiceTestsBase { final WindowState w = new WindowState(service, session, iWindow, token, parent, OP_NONE, attrs, VISIBLE, ownerId, userId, - ownerCanAddInternalSystemWindow, false /* ownerCanUseBackgroundBlur */, + ownerCanAddInternalSystemWindow, powerManagerWrapper); // TODO: Probably better to make this call in the WindowState ctor to avoid errors with // adding it to the token... @@ -1213,8 +1213,7 @@ class WindowTestsBase extends SystemServiceTestsBase { TestWindowState(WindowManagerService service, Session session, IWindow window, WindowManager.LayoutParams attrs, WindowToken token) { super(service, session, window, token, null, OP_NONE, attrs, 0, 0, 0, - false /* ownerCanAddInternalSystemWindow */, - false /* ownerCanUseBackgroundBlur */); + false /* ownerCanAddInternalSystemWindow */); } @Override