Merge "Fixes updateOverlayVisibility and updates SideFpsControllerTest for natural orientation shift" into tm-qpr-dev am: 5bdad5d547
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20950396 Change-Id: I7b0a6c24f3d82092e82f704b572d8ffd4f1e3606 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -111,7 +111,7 @@ constructor(
|
|||||||
context.resources.getInteger(android.R.integer.config_mediumAnimTime).toLong()
|
context.resources.getInteger(android.R.integer.config_mediumAnimTime).toLong()
|
||||||
|
|
||||||
private val isReverseDefaultRotation =
|
private val isReverseDefaultRotation =
|
||||||
context.getResources().getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)
|
context.resources.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)
|
||||||
|
|
||||||
private var overlayHideAnimator: ViewPropertyAnimator? = null
|
private var overlayHideAnimator: ViewPropertyAnimator? = null
|
||||||
|
|
||||||
@@ -268,10 +268,12 @@ constructor(
|
|||||||
val isDefaultOrientation =
|
val isDefaultOrientation =
|
||||||
if (isReverseDefaultRotation) !isNaturalOrientation else isNaturalOrientation
|
if (isReverseDefaultRotation) !isNaturalOrientation else isNaturalOrientation
|
||||||
val size = windowManager.maximumWindowMetrics.bounds
|
val size = windowManager.maximumWindowMetrics.bounds
|
||||||
|
|
||||||
val displayWidth = if (isDefaultOrientation) size.width() else size.height()
|
val displayWidth = if (isDefaultOrientation) size.width() else size.height()
|
||||||
val displayHeight = if (isDefaultOrientation) size.height() else size.width()
|
val displayHeight = if (isDefaultOrientation) size.height() else size.width()
|
||||||
val boundsWidth = if (isDefaultOrientation) bounds.width() else bounds.height()
|
val boundsWidth = if (isDefaultOrientation) bounds.width() else bounds.height()
|
||||||
val boundsHeight = if (isDefaultOrientation) bounds.height() else bounds.width()
|
val boundsHeight = if (isDefaultOrientation) bounds.height() else bounds.width()
|
||||||
|
|
||||||
val sensorBounds =
|
val sensorBounds =
|
||||||
if (overlayOffsets.isYAligned()) {
|
if (overlayOffsets.isYAligned()) {
|
||||||
Rect(
|
Rect(
|
||||||
@@ -297,6 +299,7 @@ constructor(
|
|||||||
|
|
||||||
overlayViewParams.x = sensorBounds.left
|
overlayViewParams.x = sensorBounds.left
|
||||||
overlayViewParams.y = sensorBounds.top
|
overlayViewParams.y = sensorBounds.top
|
||||||
|
|
||||||
windowManager.updateViewLayout(overlayView, overlayViewParams)
|
windowManager.updateViewLayout(overlayView, overlayViewParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +309,12 @@ constructor(
|
|||||||
}
|
}
|
||||||
// hide after a few seconds if the sensor is oriented down and there are
|
// hide after a few seconds if the sensor is oriented down and there are
|
||||||
// large overlapping system bars
|
// large overlapping system bars
|
||||||
val rotation = context.display?.rotation
|
var rotation = context.display?.rotation
|
||||||
|
|
||||||
|
if (rotation != null) {
|
||||||
|
rotation = getRotationFromDefault(rotation)
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
windowManager.currentWindowMetrics.windowInsets.hasBigNavigationBar() &&
|
windowManager.currentWindowMetrics.windowInsets.hasBigNavigationBar() &&
|
||||||
((rotation == Surface.ROTATION_270 && overlayOffsets.isYAligned()) ||
|
((rotation == Surface.ROTATION_270 && overlayOffsets.isYAligned()) ||
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import androidx.test.filters.SmallTest
|
|||||||
import com.airbnb.lottie.LottieAnimationView
|
import com.airbnb.lottie.LottieAnimationView
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
|
import com.android.systemui.SysuiTestableContext
|
||||||
import com.android.systemui.dump.DumpManager
|
import com.android.systemui.dump.DumpManager
|
||||||
import com.android.systemui.recents.OverviewProxyService
|
import com.android.systemui.recents.OverviewProxyService
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor
|
import com.android.systemui.util.concurrency.FakeExecutor
|
||||||
@@ -106,8 +107,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
enum class DeviceConfig {
|
enum class DeviceConfig {
|
||||||
X_ALIGNED,
|
X_ALIGNED,
|
||||||
Y_ALIGNED_UNFOLDED,
|
Y_ALIGNED,
|
||||||
Y_ALIGNED_FOLDED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var deviceConfig: DeviceConfig
|
private lateinit var deviceConfig: DeviceConfig
|
||||||
@@ -143,6 +143,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
private fun testWithDisplay(
|
private fun testWithDisplay(
|
||||||
deviceConfig: DeviceConfig = DeviceConfig.X_ALIGNED,
|
deviceConfig: DeviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation: Boolean = false,
|
||||||
initInfo: DisplayInfo.() -> Unit = {},
|
initInfo: DisplayInfo.() -> Unit = {},
|
||||||
windowInsets: WindowInsets = insetsForSmallNavbar(),
|
windowInsets: WindowInsets = insetsForSmallNavbar(),
|
||||||
block: () -> Unit
|
block: () -> Unit
|
||||||
@@ -151,27 +152,21 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
when (deviceConfig) {
|
when (deviceConfig) {
|
||||||
DeviceConfig.X_ALIGNED -> {
|
DeviceConfig.X_ALIGNED -> {
|
||||||
displayWidth = 2560
|
displayWidth = 3000
|
||||||
displayHeight = 1600
|
displayHeight = 1500
|
||||||
sensorLocation = SensorLocationInternal("", 2325, 0, 0)
|
sensorLocation = SensorLocationInternal("", 2500, 0, 0)
|
||||||
boundsWidth = 160
|
boundsWidth = 200
|
||||||
boundsHeight = 84
|
boundsHeight = 100
|
||||||
}
|
}
|
||||||
DeviceConfig.Y_ALIGNED_UNFOLDED -> {
|
DeviceConfig.Y_ALIGNED -> {
|
||||||
displayWidth = 2208
|
displayWidth = 2500
|
||||||
displayHeight = 1840
|
displayHeight = 2000
|
||||||
sensorLocation = SensorLocationInternal("", 0, 510, 0)
|
sensorLocation = SensorLocationInternal("", 0, 300, 0)
|
||||||
boundsWidth = 110
|
boundsWidth = 100
|
||||||
boundsHeight = 210
|
boundsHeight = 200
|
||||||
}
|
|
||||||
DeviceConfig.Y_ALIGNED_FOLDED -> {
|
|
||||||
displayWidth = 1080
|
|
||||||
displayHeight = 2100
|
|
||||||
sensorLocation = SensorLocationInternal("", 0, 590, 0)
|
|
||||||
boundsWidth = 110
|
|
||||||
boundsHeight = 210
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
indicatorBounds = Rect(0, 0, boundsWidth, boundsHeight)
|
indicatorBounds = Rect(0, 0, boundsWidth, boundsHeight)
|
||||||
displayBounds = Rect(0, 0, displayWidth, displayHeight)
|
displayBounds = Rect(0, 0, displayWidth, displayHeight)
|
||||||
var locations = listOf(sensorLocation)
|
var locations = listOf(sensorLocation)
|
||||||
@@ -194,8 +189,10 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
val displayInfo = DisplayInfo()
|
val displayInfo = DisplayInfo()
|
||||||
displayInfo.initInfo()
|
displayInfo.initInfo()
|
||||||
|
|
||||||
val dmGlobal = mock(DisplayManagerGlobal::class.java)
|
val dmGlobal = mock(DisplayManagerGlobal::class.java)
|
||||||
val display = Display(dmGlobal, DISPLAY_ID, displayInfo, DEFAULT_DISPLAY_ADJUSTMENTS)
|
val display = Display(dmGlobal, DISPLAY_ID, displayInfo, DEFAULT_DISPLAY_ADJUSTMENTS)
|
||||||
|
|
||||||
whenEver(dmGlobal.getDisplayInfo(eq(DISPLAY_ID))).thenReturn(displayInfo)
|
whenEver(dmGlobal.getDisplayInfo(eq(DISPLAY_ID))).thenReturn(displayInfo)
|
||||||
whenEver(windowManager.defaultDisplay).thenReturn(display)
|
whenEver(windowManager.defaultDisplay).thenReturn(display)
|
||||||
whenEver(windowManager.maximumWindowMetrics)
|
whenEver(windowManager.maximumWindowMetrics)
|
||||||
@@ -203,9 +200,15 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
whenEver(windowManager.currentWindowMetrics)
|
whenEver(windowManager.currentWindowMetrics)
|
||||||
.thenReturn(WindowMetrics(displayBounds, windowInsets))
|
.thenReturn(WindowMetrics(displayBounds, windowInsets))
|
||||||
|
|
||||||
|
val sideFpsControllerContext = context.createDisplayContext(display) as SysuiTestableContext
|
||||||
|
sideFpsControllerContext.orCreateTestableResources.addOverride(
|
||||||
|
com.android.internal.R.bool.config_reverseDefaultRotation,
|
||||||
|
isReverseDefaultRotation
|
||||||
|
)
|
||||||
|
|
||||||
sideFpsController =
|
sideFpsController =
|
||||||
SideFpsController(
|
SideFpsController(
|
||||||
context.createDisplayContext(display),
|
sideFpsControllerContext,
|
||||||
layoutInflater,
|
layoutInflater,
|
||||||
fingerprintManager,
|
fingerprintManager,
|
||||||
windowManager,
|
windowManager,
|
||||||
@@ -299,108 +302,316 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar() =
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_0() =
|
||||||
testWithDisplay(deviceConfig = DeviceConfig.X_ALIGNED, { rotation = Surface.ROTATION_0 }) {
|
|
||||||
hidesWithTaskbar(visible = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun showsWithTaskbarOnY() =
|
|
||||||
testWithDisplay(
|
testWithDisplay(
|
||||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
{ rotation = Surface.ROTATION_0 }
|
{ rotation = Surface.ROTATION_0 }
|
||||||
) { hidesWithTaskbar(visible = true) }
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar90() =
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_90() =
|
||||||
testWithDisplay(deviceConfig = DeviceConfig.X_ALIGNED, { rotation = Surface.ROTATION_90 }) {
|
testWithDisplay(
|
||||||
hidesWithTaskbar(visible = true)
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_90 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_180 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarCollapsedDownForXAlignedSensor_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_180 },
|
||||||
|
windowInsets = insetsForSmallNavbar()
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun hidesSfpsIndicatorWhenOccludingTaskbarForXAlignedSensor_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_180 },
|
||||||
|
windowInsets = insetsForLargeNavbar()
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_270() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_270 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_0() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_0 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_90() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_90 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarCollapsedDownForXAlignedSensor_InReverseDefaultRotation_90() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_90 },
|
||||||
|
windowInsets = insetsForSmallNavbar()
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun hidesSfpsIndicatorWhenOccludingTaskbarForXAlignedSensor_InReverseDefaultRotation_90() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_90 },
|
||||||
|
windowInsets = insetsForLargeNavbar()
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_180 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_270() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_270 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_0() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_0 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_90() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_90 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_180 },
|
||||||
|
) {
|
||||||
|
verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar90OnY() =
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_270() =
|
||||||
testWithDisplay(
|
testWithDisplay(
|
||||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
{ rotation = Surface.ROTATION_90 }
|
isReverseDefaultRotation = false,
|
||||||
) { hidesWithTaskbar(visible = true) }
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun showsWithTaskbar180() =
|
|
||||||
testWithDisplay(
|
|
||||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
|
||||||
{ rotation = Surface.ROTATION_180 }
|
|
||||||
) { hidesWithTaskbar(visible = true) }
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun showsWithTaskbar270OnY() =
|
|
||||||
testWithDisplay(
|
|
||||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
|
||||||
{ rotation = Surface.ROTATION_270 }
|
{ rotation = Surface.ROTATION_270 }
|
||||||
) { hidesWithTaskbar(visible = true) }
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbarCollapsedDown() =
|
fun showsSfpsIndicatorWithTaskbarCollapsedDownForYAlignedSensor_270() =
|
||||||
testWithDisplay(
|
testWithDisplay(
|
||||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
{ rotation = Surface.ROTATION_270 },
|
{ rotation = Surface.ROTATION_270 },
|
||||||
windowInsets = insetsForSmallNavbar()
|
windowInsets = insetsForSmallNavbar()
|
||||||
) { hidesWithTaskbar(visible = true) }
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbarCollapsedDownOnY() =
|
fun hidesSfpsIndicatorWhenOccludingTaskbarForYAlignedSensor_270() =
|
||||||
testWithDisplay(
|
testWithDisplay(
|
||||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
{ rotation = Surface.ROTATION_180 },
|
isReverseDefaultRotation = false,
|
||||||
windowInsets = insetsForSmallNavbar()
|
|
||||||
) { hidesWithTaskbar(visible = true) }
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun hidesWithTaskbarDown() =
|
|
||||||
testWithDisplay(
|
|
||||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
|
||||||
{ rotation = Surface.ROTATION_180 },
|
|
||||||
windowInsets = insetsForLargeNavbar()
|
|
||||||
) { hidesWithTaskbar(visible = false) }
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun hidesWithTaskbarDownOnY() =
|
|
||||||
testWithDisplay(
|
|
||||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
|
||||||
{ rotation = Surface.ROTATION_270 },
|
{ rotation = Surface.ROTATION_270 },
|
||||||
windowInsets = insetsForLargeNavbar()
|
windowInsets = insetsForLargeNavbar()
|
||||||
) { hidesWithTaskbar(visible = true) }
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||||
|
|
||||||
private fun hidesWithTaskbar(visible: Boolean) {
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_0() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_0 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_90() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_90 },
|
||||||
|
) {
|
||||||
|
verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_180 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarCollapsedDownForYAlignedSensor_InReverseDefaultRotation_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_180 },
|
||||||
|
windowInsets = insetsForSmallNavbar()
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun hidesSfpsIndicatorWhenOccludingTaskbarForYAlignedSensor_InReverseDefaultRotation_180() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_180 },
|
||||||
|
windowInsets = insetsForLargeNavbar()
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_270() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_270 }
|
||||||
|
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||||
|
|
||||||
|
private fun verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible: Boolean) {
|
||||||
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
sideFpsController.overviewProxyListener.onTaskbarStatusUpdated(visible, false)
|
sideFpsController.overviewProxyListener.onTaskbarStatusUpdated(true, false)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(windowManager).addView(any(), any())
|
verify(windowManager).addView(any(), any())
|
||||||
verify(windowManager, never()).removeView(any())
|
verify(windowManager, never()).removeView(any())
|
||||||
verify(sideFpsView).visibility = if (visible) View.VISIBLE else View.GONE
|
verify(sideFpsView).visibility = if (sfpsViewVisible) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_0,
|
||||||
|
* and uses RotateUtils.rotateBounds to map to the correct indicator location given the device
|
||||||
|
* rotation. Assuming RotationUtils.rotateBounds works correctly, tests for indicator placement
|
||||||
|
* in other rotations have been omitted.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun testIndicatorPlacementForXAlignedSensor() =
|
fun verifiesIndicatorPlacementForXAlignedSensor_0() {
|
||||||
testWithDisplay(deviceConfig = DeviceConfig.X_ALIGNED) {
|
testWithDisplay(
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_0 }
|
||||||
|
) {
|
||||||
sideFpsController.overlayOffsets = sensorLocation
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
|
|
||||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||||
|
|
||||||
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||||
|
|
||||||
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(sensorLocation.sensorLocationX)
|
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(sensorLocation.sensorLocationX)
|
||||||
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(0)
|
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_270
|
||||||
|
* in reverse default rotation. It then uses RotateUtils.rotateBounds to map to the correct
|
||||||
|
* indicator location given the device rotation. Assuming RotationUtils.rotateBounds works
|
||||||
|
* correctly, tests for indicator placement in other rotations have been omitted.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun testIndicatorPlacementForYAlignedSensor() =
|
fun verifiesIndicatorPlacementForXAlignedSensor_InReverseDefaultRotation_270() {
|
||||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_270 }
|
||||||
|
) {
|
||||||
sideFpsController.overlayOffsets = sensorLocation
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
|
|
||||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||||
|
|
||||||
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
|
executor.runAllReady()
|
||||||
|
|
||||||
|
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||||
|
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(sensorLocation.sensorLocationX)
|
||||||
|
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_0,
|
||||||
|
* and uses RotateUtils.rotateBounds to map to the correct indicator location given the device
|
||||||
|
* rotation. Assuming RotationUtils.rotateBounds works correctly, tests for indicator placement
|
||||||
|
* in other rotations have been omitted.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun verifiesIndicatorPlacementForYAlignedSensor_0() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = false,
|
||||||
|
{ rotation = Surface.ROTATION_0 }
|
||||||
|
) {
|
||||||
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
|
|
||||||
|
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||||
|
|
||||||
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
|
executor.runAllReady()
|
||||||
|
|
||||||
|
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||||
|
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(displayWidth - boundsWidth)
|
||||||
|
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(sensorLocation.sensorLocationY)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_270
|
||||||
|
* in reverse default rotation. It then uses RotateUtils.rotateBounds to map to the correct
|
||||||
|
* indicator location given the device rotation. Assuming RotationUtils.rotateBounds works
|
||||||
|
* correctly, tests for indicator placement in other rotations have been omitted.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun verifiesIndicatorPlacementForYAlignedSensor_InReverseDefaultRotation_270() =
|
||||||
|
testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||||
|
isReverseDefaultRotation = true,
|
||||||
|
{ rotation = Surface.ROTATION_270 }
|
||||||
|
) {
|
||||||
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
|
|
||||||
|
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||||
|
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
@@ -412,7 +623,6 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun hasSideFpsSensor_withSensorProps_returnsTrue() = testWithDisplay {
|
fun hasSideFpsSensor_withSensorProps_returnsTrue() = testWithDisplay {
|
||||||
// By default all those tests assume the side fps sensor is available.
|
// By default all those tests assume the side fps sensor is available.
|
||||||
|
|
||||||
assertThat(fingerprintManager.hasSideFpsSensor()).isTrue()
|
assertThat(fingerprintManager.hasSideFpsSensor()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +635,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLayoutParams_isKeyguardDialogType() =
|
fun testLayoutParams_isKeyguardDialogType() =
|
||||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED) {
|
||||||
sideFpsController.overlayOffsets = sensorLocation
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
@@ -440,7 +650,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLayoutParams_hasNoMoveAnimationWindowFlag() =
|
fun testLayoutParams_hasNoMoveAnimationWindowFlag() =
|
||||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED) {
|
||||||
sideFpsController.overlayOffsets = sensorLocation
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
@@ -455,7 +665,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLayoutParams_hasTrustedOverlayWindowFlag() =
|
fun testLayoutParams_hasTrustedOverlayWindowFlag() =
|
||||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED) {
|
||||||
sideFpsController.overlayOffsets = sensorLocation
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
|
|||||||
Reference in New Issue
Block a user