Merge "Fix location of side-fps indicator" into tm-dev
This commit is contained in:
@@ -65,7 +65,6 @@ import com.android.internal.annotations.VisibleForTesting;
|
|||||||
import com.android.internal.os.SomeArgs;
|
import com.android.internal.os.SomeArgs;
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.systemui.CoreStartable;
|
import com.android.systemui.CoreStartable;
|
||||||
import com.android.systemui.assist.ui.DisplayUtils;
|
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.dagger.qualifiers.Background;
|
import com.android.systemui.dagger.qualifiers.Background;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
@@ -600,8 +599,14 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
|
|||||||
mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class);
|
mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getDisplayWidth() {
|
||||||
|
DisplayInfo displayInfo = new DisplayInfo();
|
||||||
|
mContext.getDisplay().getDisplayInfo(displayInfo);
|
||||||
|
return displayInfo.getNaturalWidth();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateFingerprintLocation() {
|
private void updateFingerprintLocation() {
|
||||||
int xLocation = DisplayUtils.getWidth(mContext) / 2;
|
int xLocation = getDisplayWidth() / 2;
|
||||||
try {
|
try {
|
||||||
xLocation = mContext.getResources().getDimensionPixelSize(
|
xLocation = mContext.getResources().getDimensionPixelSize(
|
||||||
com.android.systemui.R.dimen
|
com.android.systemui.R.dimen
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
|
|||||||
import android.hardware.fingerprint.ISidefpsController
|
import android.hardware.fingerprint.ISidefpsController
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.util.RotationUtils
|
||||||
import android.view.View.AccessibilityDelegate
|
import android.view.View.AccessibilityDelegate
|
||||||
import android.view.accessibility.AccessibilityEvent
|
import android.view.accessibility.AccessibilityEvent
|
||||||
import android.view.Display
|
import android.view.Display
|
||||||
@@ -116,7 +117,8 @@ class SidefpsController @Inject constructor(
|
|||||||
orientationListener.enable()
|
orientationListener.enable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private var overlayOffsets: SensorLocationInternal = SensorLocationInternal.DEFAULT
|
@VisibleForTesting
|
||||||
|
internal var overlayOffsets: SensorLocationInternal = SensorLocationInternal.DEFAULT
|
||||||
|
|
||||||
private val overlayViewParams = WindowManager.LayoutParams(
|
private val overlayViewParams = WindowManager.LayoutParams(
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||||
@@ -141,7 +143,7 @@ class SidefpsController @Inject constructor(
|
|||||||
|
|
||||||
private fun doShow() = mainExecutor.execute {
|
private fun doShow() = mainExecutor.execute {
|
||||||
if (overlayView == null) {
|
if (overlayView == null) {
|
||||||
overlayView = createOverlayForDisplay()
|
createOverlayForDisplay()
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "overlay already shown")
|
Log.v(TAG, "overlay already shown")
|
||||||
}
|
}
|
||||||
@@ -154,14 +156,14 @@ class SidefpsController @Inject constructor(
|
|||||||
|
|
||||||
private fun onOrientationChanged() {
|
private fun onOrientationChanged() {
|
||||||
if (overlayView != null) {
|
if (overlayView != null) {
|
||||||
overlayView = createOverlayForDisplay()
|
createOverlayForDisplay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createOverlayForDisplay(): View {
|
private fun createOverlayForDisplay() {
|
||||||
val view = layoutInflater.inflate(R.layout.sidefps_view, null, false)
|
val view = layoutInflater.inflate(R.layout.sidefps_view, null, false)
|
||||||
|
overlayView = view
|
||||||
val display = context.display!!
|
val display = context.display!!
|
||||||
|
|
||||||
val offsets = sensorProps.getLocation(display.uniqueId).let { location ->
|
val offsets = sensorProps.getLocation(display.uniqueId).let { location ->
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
Log.w(TAG, "No location specified for display: ${display.uniqueId}")
|
Log.w(TAG, "No location specified for display: ${display.uniqueId}")
|
||||||
@@ -172,13 +174,11 @@ class SidefpsController @Inject constructor(
|
|||||||
|
|
||||||
val lottie = view.findViewById(R.id.sidefps_animation) as LottieAnimationView
|
val lottie = view.findViewById(R.id.sidefps_animation) as LottieAnimationView
|
||||||
view.rotation = display.asSideFpsAnimationRotation(offsets.isYAligned())
|
view.rotation = display.asSideFpsAnimationRotation(offsets.isYAligned())
|
||||||
|
|
||||||
updateOverlayParams(display, lottie.composition?.bounds ?: Rect())
|
|
||||||
lottie.setAnimation(display.asSideFpsAnimation(offsets.isYAligned()))
|
lottie.setAnimation(display.asSideFpsAnimation(offsets.isYAligned()))
|
||||||
lottie.addLottieOnCompositionLoadedListener {
|
lottie.addLottieOnCompositionLoadedListener {
|
||||||
if (overlayView == view) {
|
// Check that view is not stale, and that overlayView has not been hidden/removed
|
||||||
|
if (overlayView != null && overlayView == view) {
|
||||||
updateOverlayParams(display, it.bounds)
|
updateOverlayParams(display, it.bounds)
|
||||||
windowManager.updateViewLayout(overlayView, overlayViewParams)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lottie.addOverlayDynamicColor(context)
|
lottie.addOverlayDynamicColor(context)
|
||||||
@@ -200,55 +200,47 @@ class SidefpsController @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateOverlayParams(display: Display, bounds: Rect) {
|
@VisibleForTesting
|
||||||
val isPortrait = display.isPortrait()
|
internal fun updateOverlayParams(display: Display, bounds: Rect) {
|
||||||
|
val isNaturalOrientation = display.isNaturalOrientation()
|
||||||
val size = windowManager.maximumWindowMetrics.bounds
|
val size = windowManager.maximumWindowMetrics.bounds
|
||||||
val displayWidth = if (isPortrait) size.width() else size.height()
|
val displayWidth = if (isNaturalOrientation) size.width() else size.height()
|
||||||
val displayHeight = if (isPortrait) size.height() else size.width()
|
val displayHeight = if (isNaturalOrientation) size.height() else size.width()
|
||||||
|
val boundsWidth = if (isNaturalOrientation) bounds.width() else bounds.height()
|
||||||
// ignore sensorRadius since it's assumed that the sensor is on the side and centered at
|
val boundsHeight = if (isNaturalOrientation) bounds.height() else bounds.width()
|
||||||
// either sensorLocationX or sensorLocationY (both should not be set)
|
val sensorBounds = if (overlayOffsets.isYAligned()) {
|
||||||
val (x, y) = if (overlayOffsets.isYAligned()) {
|
Rect(
|
||||||
when (display.rotation) {
|
displayWidth - boundsWidth,
|
||||||
Surface.ROTATION_90 ->
|
overlayOffsets.sensorLocationY,
|
||||||
Pair(overlayOffsets.sensorLocationY, 0)
|
displayWidth,
|
||||||
Surface.ROTATION_270 ->
|
overlayOffsets.sensorLocationY + boundsHeight
|
||||||
Pair(
|
)
|
||||||
displayHeight - overlayOffsets.sensorLocationY - bounds.width(),
|
|
||||||
displayWidth + bounds.height()
|
|
||||||
)
|
|
||||||
Surface.ROTATION_180 ->
|
|
||||||
Pair(0, displayHeight - overlayOffsets.sensorLocationY - bounds.height())
|
|
||||||
else ->
|
|
||||||
Pair(displayWidth, overlayOffsets.sensorLocationY)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
when (display.rotation) {
|
Rect(
|
||||||
Surface.ROTATION_90 ->
|
overlayOffsets.sensorLocationX,
|
||||||
Pair(0, displayWidth - overlayOffsets.sensorLocationX - bounds.height())
|
0,
|
||||||
Surface.ROTATION_270 ->
|
overlayOffsets.sensorLocationX + boundsWidth,
|
||||||
Pair(displayWidth, overlayOffsets.sensorLocationX - bounds.height())
|
boundsHeight
|
||||||
Surface.ROTATION_180 ->
|
)
|
||||||
Pair(
|
|
||||||
displayWidth - overlayOffsets.sensorLocationX - bounds.width(),
|
|
||||||
displayHeight
|
|
||||||
)
|
|
||||||
else ->
|
|
||||||
Pair(overlayOffsets.sensorLocationX, 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
overlayViewParams.x = x
|
|
||||||
overlayViewParams.y = y
|
RotationUtils.rotateBounds(
|
||||||
|
sensorBounds,
|
||||||
|
Rect(0, 0, displayWidth, displayHeight),
|
||||||
|
display.rotation
|
||||||
|
)
|
||||||
|
|
||||||
|
overlayViewParams.x = sensorBounds.left
|
||||||
|
overlayViewParams.y = sensorBounds.top
|
||||||
|
windowManager.updateViewLayout(overlayView, overlayViewParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateOverlayVisibility(view: View) {
|
private fun updateOverlayVisibility(view: View) {
|
||||||
if (view != overlayView) {
|
if (view != overlayView) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
val rotation = context.display?.rotation
|
||||||
@@ -304,7 +296,7 @@ private fun Display.asSideFpsAnimationRotation(yAligned: Boolean): Float = when
|
|||||||
|
|
||||||
private fun SensorLocationInternal.isYAligned(): Boolean = sensorLocationY != 0
|
private fun SensorLocationInternal.isYAligned(): Boolean = sensorLocationY != 0
|
||||||
|
|
||||||
private fun Display.isPortrait(): Boolean =
|
private fun Display.isNaturalOrientation(): Boolean =
|
||||||
rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180
|
rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180
|
||||||
|
|
||||||
private fun WindowInsets.hasBigNavigationBar(): Boolean =
|
private fun WindowInsets.hasBigNavigationBar(): Boolean =
|
||||||
|
|||||||
@@ -77,12 +77,6 @@ import org.mockito.junit.MockitoJUnit
|
|||||||
private const val DISPLAY_ID = 2
|
private const val DISPLAY_ID = 2
|
||||||
private const val SENSOR_ID = 1
|
private const val SENSOR_ID = 1
|
||||||
|
|
||||||
private const val DISPLAY_SIZE_X = 800
|
|
||||||
private const val DISPLAY_SIZE_Y = 900
|
|
||||||
|
|
||||||
private val X_LOCATION = SensorLocationInternal("", 540, 0, 20)
|
|
||||||
private val Y_LOCATION = SensorLocationInternal("", 0, 1500, 22)
|
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner::class)
|
@RunWith(AndroidTestingRunner::class)
|
||||||
@TestableLooper.RunWithLooper
|
@TestableLooper.RunWithLooper
|
||||||
@@ -116,6 +110,17 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
private lateinit var overlayController: ISidefpsController
|
private lateinit var overlayController: ISidefpsController
|
||||||
private lateinit var sideFpsController: SidefpsController
|
private lateinit var sideFpsController: SidefpsController
|
||||||
|
|
||||||
|
enum class DeviceConfig { X_ALIGNED, Y_ALIGNED_UNFOLDED, Y_ALIGNED_FOLDED }
|
||||||
|
|
||||||
|
private lateinit var deviceConfig: DeviceConfig
|
||||||
|
private lateinit var indicatorBounds: Rect
|
||||||
|
private lateinit var displayBounds: Rect
|
||||||
|
private lateinit var sensorLocation: SensorLocationInternal
|
||||||
|
private var displayWidth: Int = 0
|
||||||
|
private var displayHeight: Int = 0
|
||||||
|
private var boundsWidth: Int = 0
|
||||||
|
private var boundsHeight: Int = 0
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
context.addMockSystemService(DisplayManager::class.java, displayManager)
|
context.addMockSystemService(DisplayManager::class.java, displayManager)
|
||||||
@@ -135,17 +140,43 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`when`(windowManager.maximumWindowMetrics).thenReturn(
|
|
||||||
WindowMetrics(Rect(0, 0, DISPLAY_SIZE_X, DISPLAY_SIZE_Y), WindowInsets.CONSUMED)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun testWithDisplay(
|
private fun testWithDisplay(
|
||||||
|
deviceConfig: DeviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
initInfo: DisplayInfo.() -> Unit = {},
|
initInfo: DisplayInfo.() -> Unit = {},
|
||||||
locations: List<SensorLocationInternal> = listOf(X_LOCATION),
|
|
||||||
windowInsets: WindowInsets = insetsForSmallNavbar(),
|
windowInsets: WindowInsets = insetsForSmallNavbar(),
|
||||||
block: () -> Unit
|
block: () -> Unit
|
||||||
) {
|
) {
|
||||||
|
this.deviceConfig = deviceConfig
|
||||||
|
|
||||||
|
when (deviceConfig) {
|
||||||
|
DeviceConfig.X_ALIGNED -> {
|
||||||
|
displayWidth = 2560
|
||||||
|
displayHeight = 1600
|
||||||
|
sensorLocation = SensorLocationInternal("", 2325, 0, 0)
|
||||||
|
boundsWidth = 160
|
||||||
|
boundsHeight = 84
|
||||||
|
}
|
||||||
|
DeviceConfig.Y_ALIGNED_UNFOLDED -> {
|
||||||
|
displayWidth = 2208
|
||||||
|
displayHeight = 1840
|
||||||
|
sensorLocation = SensorLocationInternal("", 0, 510, 0)
|
||||||
|
boundsWidth = 110
|
||||||
|
boundsHeight = 210
|
||||||
|
}
|
||||||
|
DeviceConfig.Y_ALIGNED_FOLDED -> {
|
||||||
|
displayWidth = 1080
|
||||||
|
displayHeight = 2100
|
||||||
|
sensorLocation = SensorLocationInternal("", 0, 590, 0)
|
||||||
|
boundsWidth = 110
|
||||||
|
boundsHeight = 210
|
||||||
|
}
|
||||||
|
}
|
||||||
|
indicatorBounds = Rect(0, 0, boundsWidth, boundsHeight)
|
||||||
|
displayBounds = Rect(0, 0, displayWidth, displayHeight)
|
||||||
|
var locations = listOf(sensorLocation)
|
||||||
|
|
||||||
`when`(fingerprintManager.sensorPropertiesInternal).thenReturn(
|
`when`(fingerprintManager.sensorPropertiesInternal).thenReturn(
|
||||||
listOf(
|
listOf(
|
||||||
FingerprintSensorPropertiesInternal(
|
FingerprintSensorPropertiesInternal(
|
||||||
@@ -166,8 +197,11 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
val display = Display(dmGlobal, DISPLAY_ID, displayInfo, DEFAULT_DISPLAY_ADJUSTMENTS)
|
val display = Display(dmGlobal, DISPLAY_ID, displayInfo, DEFAULT_DISPLAY_ADJUSTMENTS)
|
||||||
`when`(dmGlobal.getDisplayInfo(eq(DISPLAY_ID))).thenReturn(displayInfo)
|
`when`(dmGlobal.getDisplayInfo(eq(DISPLAY_ID))).thenReturn(displayInfo)
|
||||||
`when`(windowManager.defaultDisplay).thenReturn(display)
|
`when`(windowManager.defaultDisplay).thenReturn(display)
|
||||||
|
`when`(windowManager.maximumWindowMetrics).thenReturn(
|
||||||
|
WindowMetrics(displayBounds, WindowInsets.CONSUMED)
|
||||||
|
)
|
||||||
`when`(windowManager.currentWindowMetrics).thenReturn(
|
`when`(windowManager.currentWindowMetrics).thenReturn(
|
||||||
WindowMetrics(Rect(0, 0, DISPLAY_SIZE_X, DISPLAY_SIZE_Y), windowInsets)
|
WindowMetrics(displayBounds, windowInsets)
|
||||||
)
|
)
|
||||||
|
|
||||||
sideFpsController = SidefpsController(
|
sideFpsController = SidefpsController(
|
||||||
@@ -260,46 +294,56 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar() = testWithDisplay({ rotation = Surface.ROTATION_0 }) {
|
fun showsWithTaskbar() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
{ rotation = Surface.ROTATION_0 }
|
||||||
|
) {
|
||||||
hidesWithTaskbar(visible = true)
|
hidesWithTaskbar(visible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbarOnY() = testWithDisplay(
|
fun showsWithTaskbarOnY() = testWithDisplay(
|
||||||
{ rotation = Surface.ROTATION_0 },
|
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||||
locations = listOf(Y_LOCATION)
|
{ rotation = Surface.ROTATION_0 }
|
||||||
) {
|
) {
|
||||||
hidesWithTaskbar(visible = true)
|
hidesWithTaskbar(visible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar90() = testWithDisplay({ rotation = Surface.ROTATION_90 }) {
|
fun showsWithTaskbar90() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
{ rotation = Surface.ROTATION_90 }
|
||||||
|
) {
|
||||||
hidesWithTaskbar(visible = true)
|
hidesWithTaskbar(visible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar90OnY() = testWithDisplay(
|
fun showsWithTaskbar90OnY() = testWithDisplay(
|
||||||
{ rotation = Surface.ROTATION_90 },
|
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||||
locations = listOf(Y_LOCATION)
|
{ rotation = Surface.ROTATION_90 }
|
||||||
) {
|
) {
|
||||||
hidesWithTaskbar(visible = true)
|
hidesWithTaskbar(visible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar180() = testWithDisplay({ rotation = Surface.ROTATION_180 }) {
|
fun showsWithTaskbar180() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
|
{ rotation = Surface.ROTATION_180 }
|
||||||
|
) {
|
||||||
hidesWithTaskbar(visible = true)
|
hidesWithTaskbar(visible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbar270OnY() = testWithDisplay(
|
fun showsWithTaskbar270OnY() = testWithDisplay(
|
||||||
{ rotation = Surface.ROTATION_270 },
|
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||||
locations = listOf(Y_LOCATION)
|
{ rotation = Surface.ROTATION_270 }
|
||||||
) {
|
) {
|
||||||
hidesWithTaskbar(visible = true)
|
hidesWithTaskbar(visible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbarCollapsedDown() = testWithDisplay(
|
fun showsWithTaskbarCollapsedDown() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
{ rotation = Surface.ROTATION_270 },
|
{ rotation = Surface.ROTATION_270 },
|
||||||
windowInsets = insetsForSmallNavbar()
|
windowInsets = insetsForSmallNavbar()
|
||||||
) {
|
) {
|
||||||
@@ -308,8 +352,8 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showsWithTaskbarCollapsedDownOnY() = testWithDisplay(
|
fun showsWithTaskbarCollapsedDownOnY() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||||
{ rotation = Surface.ROTATION_180 },
|
{ rotation = Surface.ROTATION_180 },
|
||||||
locations = listOf(Y_LOCATION),
|
|
||||||
windowInsets = insetsForSmallNavbar()
|
windowInsets = insetsForSmallNavbar()
|
||||||
) {
|
) {
|
||||||
hidesWithTaskbar(visible = true)
|
hidesWithTaskbar(visible = true)
|
||||||
@@ -317,8 +361,8 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun hidesWithTaskbarDown() = testWithDisplay(
|
fun hidesWithTaskbarDown() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||||
{ rotation = Surface.ROTATION_180 },
|
{ rotation = Surface.ROTATION_180 },
|
||||||
locations = listOf(X_LOCATION),
|
|
||||||
windowInsets = insetsForLargeNavbar()
|
windowInsets = insetsForLargeNavbar()
|
||||||
) {
|
) {
|
||||||
hidesWithTaskbar(visible = false)
|
hidesWithTaskbar(visible = false)
|
||||||
@@ -326,18 +370,18 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun hidesWithTaskbarDownOnY() = testWithDisplay(
|
fun hidesWithTaskbarDownOnY() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||||
{ rotation = Surface.ROTATION_270 },
|
{ rotation = Surface.ROTATION_270 },
|
||||||
locations = listOf(Y_LOCATION),
|
|
||||||
windowInsets = insetsForLargeNavbar()
|
windowInsets = insetsForLargeNavbar()
|
||||||
) {
|
) {
|
||||||
hidesWithTaskbar(visible = false)
|
hidesWithTaskbar(visible = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hidesWithTaskbar(visible: Boolean) {
|
private fun hidesWithTaskbar(visible: Boolean) {
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
sideFpsController.overviewProxyListener.onTaskbarStatusUpdated(true, false)
|
sideFpsController.overviewProxyListener.onTaskbarStatusUpdated(visible, false)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(windowManager).addView(any(), any())
|
verify(windowManager).addView(any(), any())
|
||||||
@@ -346,25 +390,38 @@ class SidefpsControllerTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setsXAlign() = testWithDisplay {
|
fun testIndicatorPlacementForXAlignedSensor() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.X_ALIGNED
|
||||||
|
) {
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
|
sideFpsController.updateOverlayParams(
|
||||||
|
windowManager.defaultDisplay,
|
||||||
|
indicatorBounds
|
||||||
|
)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(windowManager).addView(any(), overlayViewParamsCaptor.capture())
|
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||||
|
|
||||||
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(X_LOCATION.sensorLocationX)
|
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(sensorLocation.sensorLocationX)
|
||||||
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(0)
|
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setYAlign() = testWithDisplay(locations = listOf(Y_LOCATION)) {
|
fun testIndicatorPlacementForYAlignedSensor() = testWithDisplay(
|
||||||
|
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED
|
||||||
|
) {
|
||||||
|
sideFpsController.overlayOffsets = sensorLocation
|
||||||
|
sideFpsController.updateOverlayParams(
|
||||||
|
windowManager.defaultDisplay,
|
||||||
|
indicatorBounds
|
||||||
|
)
|
||||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(windowManager).addView(any(), overlayViewParamsCaptor.capture())
|
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||||
|
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(displayWidth - boundsWidth)
|
||||||
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(DISPLAY_SIZE_X)
|
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(sensorLocation.sensorLocationY)
|
||||||
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(Y_LOCATION.sensorLocationY)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,6 +430,7 @@ private fun insetsForLargeNavbar() = insetsWithBottom(100)
|
|||||||
private fun insetsWithBottom(bottom: Int) = WindowInsets.Builder()
|
private fun insetsWithBottom(bottom: Int) = WindowInsets.Builder()
|
||||||
.setInsets(WindowInsets.Type.navigationBars(), Insets.of(0, 0, 0, bottom))
|
.setInsets(WindowInsets.Type.navigationBars(), Insets.of(0, 0, 0, bottom))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private fun fpEnrollTask() = settingsTask(".biometrics.fingerprint.FingerprintEnrollEnrolling")
|
private fun fpEnrollTask() = settingsTask(".biometrics.fingerprint.FingerprintEnrollEnrolling")
|
||||||
private fun fpSettingsTask() = settingsTask(".biometrics.fingerprint.FingerprintSettings")
|
private fun fpSettingsTask() = settingsTask(".biometrics.fingerprint.FingerprintSettings")
|
||||||
private fun settingsTask(cls: String) = ActivityManager.RunningTaskInfo().apply {
|
private fun settingsTask(cls: String) = ActivityManager.RunningTaskInfo().apply {
|
||||||
|
|||||||
Reference in New Issue
Block a user