Do not call WM until we have a window token
Ensuring that we won't ask WM to set a zoom until we have a window token, also guarding against it on WallpaperManager. Test: atest NotificationShadeDepthControllerTest Fixes: 177637619 Change-Id: I0c775acf3a1045fc5b1b6540d981dea92fda91d6
This commit is contained in:
@@ -1962,14 +1962,20 @@ public class WallpaperManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current zoom out level of the wallpaper
|
||||
* Set the current zoom out level of the wallpaper.
|
||||
*
|
||||
* @param windowToken window requesting wallpaper zoom. Zoom level will only be applier while
|
||||
* such window is visible.
|
||||
* @param zoom from 0 to 1 (inclusive) where 1 means fully zoomed out, 0 means fully zoomed in
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setWallpaperZoomOut(IBinder windowToken, float zoom) {
|
||||
public void setWallpaperZoomOut(@NonNull IBinder windowToken, float zoom) {
|
||||
if (zoom < 0 || zoom > 1f) {
|
||||
throw new IllegalArgumentException("zoom must be between 0 and one: " + zoom);
|
||||
throw new IllegalArgumentException("zoom must be between 0 and 1: " + zoom);
|
||||
}
|
||||
if (windowToken == null) {
|
||||
throw new IllegalArgumentException("windowToken must not be null");
|
||||
}
|
||||
try {
|
||||
WindowManagerGlobal.getWindowSession().setWallpaperZoomOut(windowToken, zoom);
|
||||
|
||||
@@ -189,7 +189,7 @@ class NotificationShadeDepthController @Inject constructor(
|
||||
blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur)
|
||||
val zoomOut = blurUtils.ratioOfBlurRadius(blur)
|
||||
try {
|
||||
if (root.isAttachedToWindow) {
|
||||
if (root.isAttachedToWindow && root.windowToken != null) {
|
||||
wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut)
|
||||
} else {
|
||||
Log.i(TAG, "Won't set zoom. Window not attached $root")
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.statusbar
|
||||
|
||||
import android.app.WallpaperManager
|
||||
import android.os.IBinder
|
||||
import android.testing.AndroidTestingRunner
|
||||
import android.testing.TestableLooper.RunWithLooper
|
||||
import android.view.Choreographer
|
||||
@@ -64,6 +65,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
||||
@Mock private lateinit var dumpManager: DumpManager
|
||||
@Mock private lateinit var root: View
|
||||
@Mock private lateinit var viewRootImpl: ViewRootImpl
|
||||
@Mock private lateinit var windowToken: IBinder
|
||||
@Mock private lateinit var shadeSpring: NotificationShadeDepthController.DepthAnimation
|
||||
@Mock private lateinit var shadeAnimation: NotificationShadeDepthController.DepthAnimation
|
||||
@Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation
|
||||
@@ -80,6 +82,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
||||
@Before
|
||||
fun setup() {
|
||||
`when`(root.viewRootImpl).thenReturn(viewRootImpl)
|
||||
`when`(root.windowToken).thenReturn(windowToken)
|
||||
`when`(root.isAttachedToWindow).thenReturn(true)
|
||||
`when`(statusBarStateController.state).then { statusBarState }
|
||||
`when`(blurUtils.blurRadiusOfRatio(anyFloat())).then { answer ->
|
||||
|
||||
Reference in New Issue
Block a user