Merge "Set Shade opaqueness on devices that don't support blurs" into sc-v2-dev am: aa67cba3d9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16073973 Change-Id: I006fd7dd99f957d814e67a733f4e131c4c7d0bb4
This commit is contained in:
committed by
Automerger Merge Worker
commit
0052a4fd32
@@ -80,22 +80,23 @@ open class BlurUtils @Inject constructor(
|
|||||||
* @param opaque if surface is opaque, regardless or having blurs or no.
|
* @param opaque if surface is opaque, regardless or having blurs or no.
|
||||||
*/
|
*/
|
||||||
fun applyBlur(viewRootImpl: ViewRootImpl?, radius: Int, opaque: Boolean) {
|
fun applyBlur(viewRootImpl: ViewRootImpl?, radius: Int, opaque: Boolean) {
|
||||||
if (viewRootImpl == null || !viewRootImpl.surfaceControl.isValid ||
|
if (viewRootImpl == null || !viewRootImpl.surfaceControl.isValid) {
|
||||||
!supportsBlursOnWindows()) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
createTransaction().use {
|
createTransaction().use {
|
||||||
|
if (supportsBlursOnWindows()) {
|
||||||
it.setBackgroundBlurRadius(viewRootImpl.surfaceControl, radius)
|
it.setBackgroundBlurRadius(viewRootImpl.surfaceControl, radius)
|
||||||
it.setOpaque(viewRootImpl.surfaceControl, opaque)
|
|
||||||
if (lastAppliedBlur == 0 && radius != 0) {
|
if (lastAppliedBlur == 0 && radius != 0) {
|
||||||
it.setEarlyWakeupStart()
|
it.setEarlyWakeupStart()
|
||||||
}
|
}
|
||||||
if (lastAppliedBlur != 0 && radius == 0) {
|
if (lastAppliedBlur != 0 && radius == 0) {
|
||||||
it.setEarlyWakeupEnd()
|
it.setEarlyWakeupEnd()
|
||||||
}
|
}
|
||||||
|
lastAppliedBlur = radius
|
||||||
|
}
|
||||||
|
it.setOpaque(viewRootImpl.surfaceControl, opaque)
|
||||||
it.apply()
|
it.apply()
|
||||||
}
|
}
|
||||||
lastAppliedBlur = radius
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -27,9 +27,12 @@ import org.junit.Before
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
import org.mockito.Mockito.any
|
||||||
|
import org.mockito.Mockito.anyInt
|
||||||
import org.mockito.Mockito.clearInvocations
|
import org.mockito.Mockito.clearInvocations
|
||||||
import org.mockito.Mockito.eq
|
import org.mockito.Mockito.eq
|
||||||
import org.mockito.Mockito.mock
|
import org.mockito.Mockito.mock
|
||||||
|
import org.mockito.Mockito.never
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
@@ -40,12 +43,11 @@ class BlurUtilsTest : SysuiTestCase() {
|
|||||||
@Mock lateinit var dumpManager: DumpManager
|
@Mock lateinit var dumpManager: DumpManager
|
||||||
@Mock lateinit var transaction: SurfaceControl.Transaction
|
@Mock lateinit var transaction: SurfaceControl.Transaction
|
||||||
@Mock lateinit var crossWindowBlurListeners: CrossWindowBlurListeners
|
@Mock lateinit var crossWindowBlurListeners: CrossWindowBlurListeners
|
||||||
lateinit var blurUtils: BlurUtils
|
lateinit var blurUtils: TestableBlurUtils
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
`when`(crossWindowBlurListeners.isCrossWindowBlurEnabled).thenReturn(true)
|
|
||||||
blurUtils = TestableBlurUtils()
|
blurUtils = TestableBlurUtils()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +77,21 @@ class BlurUtilsTest : SysuiTestCase() {
|
|||||||
verify(transaction).apply()
|
verify(transaction).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testApplyBlur_blurDisabled() {
|
||||||
|
val radius = 10
|
||||||
|
val surfaceControl = mock(SurfaceControl::class.java)
|
||||||
|
val viewRootImpl = mock(ViewRootImpl::class.java)
|
||||||
|
`when`(viewRootImpl.surfaceControl).thenReturn(surfaceControl)
|
||||||
|
`when`(surfaceControl.isValid).thenReturn(true)
|
||||||
|
|
||||||
|
blurUtils.blursEnabled = false
|
||||||
|
blurUtils.applyBlur(viewRootImpl, radius, true /* opaque */)
|
||||||
|
verify(transaction).setOpaque(eq(surfaceControl), eq(true))
|
||||||
|
verify(transaction, never()).setBackgroundBlurRadius(any(), anyInt())
|
||||||
|
verify(transaction).apply()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testEarlyWakeUp() {
|
fun testEarlyWakeUp() {
|
||||||
val radius = 10
|
val radius = 10
|
||||||
@@ -89,9 +106,11 @@ class BlurUtilsTest : SysuiTestCase() {
|
|||||||
verify(transaction).setEarlyWakeupEnd()
|
verify(transaction).setEarlyWakeupEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class TestableBlurUtils() : BlurUtils(resources, crossWindowBlurListeners, dumpManager) {
|
inner class TestableBlurUtils : BlurUtils(resources, crossWindowBlurListeners, dumpManager) {
|
||||||
|
var blursEnabled = true
|
||||||
|
|
||||||
override fun supportsBlursOnWindows(): Boolean {
|
override fun supportsBlursOnWindows(): Boolean {
|
||||||
return true
|
return blursEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createTransaction(): SurfaceControl.Transaction {
|
override fun createTransaction(): SurfaceControl.Transaction {
|
||||||
|
|||||||
Reference in New Issue
Block a user