From 1a9eb5d8bc341433cdfd7a00a4d9e9e15837169e Mon Sep 17 00:00:00 2001 From: Ioana Alexandru Date: Thu, 11 Jan 2024 19:02:14 +0100 Subject: Only check if SLOW_MEASURE flag is enabled when needed. Fix: 319659059 Test: NotificationStackScrollLayoutTest GroupExpansionManagerTest (running locally on a debug build) Flag: NONE Change-Id: I3ef507d886d92540df875abafd5b6a8276f802db --- .../notification/row/ExpandableNotificationRow.java | 13 ++++++++----- .../stack/NotificationStackScrollLayoutTest.java | 8 -------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 31ca106d2bc9..e200e65a9f4a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -273,12 +273,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private final RefactorFlag mInlineReplyAnimation = RefactorFlag.forView(Flags.NOTIFICATION_INLINE_REPLY_ANIMATION); - private static final boolean mSimulateSlowMeasure = Compile.IS_DEBUG && RefactorFlag.forView( - Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE).isEnabled(); + private static boolean shouldSimulateSlowMeasure() { + return Compile.IS_DEBUG && RefactorFlag.forView( + Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE).isEnabled(); + } + private static final String SLOW_MEASURE_SIMULATE_DELAY_PROPERTY = "persist.notifications.extra_measure_delay_ms"; - private static final int SLOW_MEASURE_SIMULATE_DELAY_MS = mSimulateSlowMeasure ? - SystemProperties.getInt(SLOW_MEASURE_SIMULATE_DELAY_PROPERTY, 150) : 0; + private static final int SLOW_MEASURE_SIMULATE_DELAY_MS = + SystemProperties.getInt(SLOW_MEASURE_SIMULATE_DELAY_PROPERTY, 150); // Listener will be called when receiving a long click event. // Use #setLongPressPosition to optionally assign positional data with the long press. @@ -1886,7 +1889,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } super.onMeasure(widthMeasureSpec, heightMeasureSpec); - if (Compile.IS_DEBUG && mSimulateSlowMeasure) { + if (shouldSimulateSlowMeasure()) { simulateExtraMeasureDelay(); } Trace.endSection(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 83ba68460aa5..a1721208b2f2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -626,8 +626,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { @Test public void testClearNotifications_clearAllInProgress() { - mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false); - ExpandableNotificationRow row = createClearableRow(); when(row.getEntry().hasFinishedInitialization()).thenReturn(true); doReturn(true).when(mStackScroller).isVisible(row); @@ -672,8 +670,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { @Test public void testAddNotificationUpdatesSpeedBumpIndex() { - mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false); - // initial state calculated == 0 assertEquals(0, mStackScroller.getSpeedBumpIndex()); @@ -690,8 +686,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { @Test public void testAddAmbientNotificationNoSpeedBumpUpdate() { - mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false); - // initial state calculated == 0 assertEquals(0, mStackScroller.getSpeedBumpIndex()); @@ -708,8 +702,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { @Test public void testRemoveNotificationUpdatesSpeedBump() { - mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false); - // initial state calculated == 0 assertEquals(0, mStackScroller.getSpeedBumpIndex()); -- cgit v1.2.3-59-g8ed1b