Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73173338 authored by Brad Hinegardner's avatar Brad Hinegardner
Browse files

Fix ambient indication displaying when MIGRATE_LOCK_ICON is on

The id of the lock icon was changed here, which can cause the ambient
indication to float to the top of the screen

Flag: MIGRATE_LOCK_ICON
Bug: 305234447
Test: atest DefaultDeviceEntryIconSectionTest.kt
Test: manual - enable MIGRATE_LOCK_ICON and MIGRATE_SPLIT_KEYGUARD_BOTTOM_AREA
Change-Id: I2162118172269e6ce2f3d798b52aca863905d22d
parent 1e754b11
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -60,8 +60,7 @@ constructor(
    private val deviceEntryIconViewId = R.id.device_entry_icon_view

    override fun addViews(constraintLayout: ConstraintLayout) {
        if (
            !featureFlags.isEnabled(Flags.MIGRATE_LOCK_ICON) &&
        if (!featureFlags.isEnabled(Flags.MIGRATE_LOCK_ICON) &&
                !featureFlags.isEnabled(Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS)
        ) {
            return
@@ -76,7 +75,7 @@ constructor(
                DeviceEntryIconView(context, null).apply { id = deviceEntryIconViewId }
            } else {
                // Flags.MIGRATE_LOCK_ICON
                LockIconView(context, null).apply { id = deviceEntryIconViewId }
                LockIconView(context, null).apply { id = R.id.lock_icon_view }
            }
        constraintLayout.addView(view)
    }
@@ -91,7 +90,7 @@ constructor(
                )
            }
        } else {
            constraintLayout.findViewById<LockIconView?>(deviceEntryIconViewId)?.let {
            constraintLayout.findViewById<LockIconView?>(R.id.lock_icon_view)?.let {
                lockIconViewController.get().setLockIconView(it)
            }
        }
@@ -133,7 +132,11 @@ constructor(
    }

    override fun removeViews(constraintLayout: ConstraintLayout) {
        if (featureFlags.isEnabled(Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS)) {
            constraintLayout.removeView(deviceEntryIconViewId)
        } else {
            constraintLayout.removeView(R.id.lock_icon_view)
        }
    }

    @VisibleForTesting
@@ -148,18 +151,25 @@ constructor(
                )
            }

        val iconId =
            if (featureFlags.isEnabled(Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS)) {
                deviceEntryIconViewId
            } else {
                R.id.lock_icon_view
            }

        constraintSet.apply {
            constrainWidth(deviceEntryIconViewId, sensorRect.right - sensorRect.left)
            constrainHeight(deviceEntryIconViewId, sensorRect.bottom - sensorRect.top)
            constrainWidth(iconId, sensorRect.right - sensorRect.left)
            constrainHeight(iconId, sensorRect.bottom - sensorRect.top)
            connect(
                deviceEntryIconViewId,
                iconId,
                ConstraintSet.TOP,
                ConstraintSet.PARENT_ID,
                ConstraintSet.TOP,
                sensorRect.top
            )
            connect(
                deviceEntryIconViewId,
                iconId,
                ConstraintSet.START,
                ConstraintSet.PARENT_ID,
                ConstraintSet.START,
+32 −2
Original line number Diff line number Diff line
@@ -106,7 +106,20 @@ class DefaultDeviceEntryIconSectionTest : SysuiTestCase() {
    }

    @Test
    fun applyConstraints() {
    fun applyConstraints_udfps_refactor_off() {
        featureFlags.set(Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS, false)
        val cs = ConstraintSet()
        underTest.applyConstraints(cs)

        val constraint = cs.getConstraint(R.id.lock_icon_view)

        assertThat(constraint.layout.topToTop).isEqualTo(ConstraintSet.PARENT_ID)
        assertThat(constraint.layout.startToStart).isEqualTo(ConstraintSet.PARENT_ID)
    }

    @Test
    fun applyConstraints_udfps_refactor_on() {
        featureFlags.set(Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS, true)
        val cs = ConstraintSet()
        underTest.applyConstraints(cs)

@@ -117,7 +130,24 @@ class DefaultDeviceEntryIconSectionTest : SysuiTestCase() {
    }

    @Test
    fun testCenterIcon() {
    fun testCenterIcon_udfps_refactor_off() {
        featureFlags.set(Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS, false)
        val cs = ConstraintSet()
        underTest.centerIcon(Point(5, 6), 1F, cs)

        val constraint = cs.getConstraint(R.id.lock_icon_view)

        assertThat(constraint.layout.mWidth).isEqualTo(2)
        assertThat(constraint.layout.mHeight).isEqualTo(2)
        assertThat(constraint.layout.topToTop).isEqualTo(ConstraintSet.PARENT_ID)
        assertThat(constraint.layout.startToStart).isEqualTo(ConstraintSet.PARENT_ID)
        assertThat(constraint.layout.topMargin).isEqualTo(5)
        assertThat(constraint.layout.startMargin).isEqualTo(4)
    }

    @Test
    fun testCenterIcon_udfps_refactor_on() {
        featureFlags.set(Flags.REFACTOR_UDFPS_KEYGUARD_VIEWS, true)
        val cs = ConstraintSet()
        underTest.centerIcon(Point(5, 6), 1F, cs)