diff options
2 files changed, 51 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSection.kt index 62c5988ff42c..755549b5478b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSection.kt @@ -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) { - constraintLayout.removeView(deviceEntryIconViewId) + 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, diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSectionTest.kt index 5f22c7da3920..c7f7c3c3cecf 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSectionTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntryIconSectionTest.kt @@ -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) |