diff options
| author | 2023-10-27 18:17:07 +0000 | |
|---|---|---|
| committer | 2023-10-30 17:20:50 +0000 | |
| commit | 73173338080922bd8b3ae36fd63eb0a1a31e825c (patch) | |
| tree | 006e26a1d5cdfa8647e701a233bb20f57a344df1 | |
| parent | 1e754b115a3f7a98261dcebdad58065f05939eb4 (diff) | |
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
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) |