From e39a3e1f43881d84e41cf2bfa77b220ade7423c2 Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Tue, 15 Nov 2022 13:45:51 +0000 Subject: [PATCH] Apply layout param to NotificationShelf only when needed Before, layout params were applied even when they stayed the same, causing a requestLayout that was propagating to the NotificationStackScrollLayout and remeasuring all notifications (even if it wasn't needed). Bug: 245268301 Bug: 243647188 Test: Manually verified in a perfetto trace that no RequestLayout was propagated to NSSL after this change from the shelf. Currently there are no ways of writing tests, but I'm working at a way to enable us to make such kind of assertions, so I'll consider adding one when possible. Change-Id: Ib3a360e705fe49cbff6f90ada0a52171ce9a5688 --- .../com/android/systemui/statusbar/NotificationShelf.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 815b86e0adb89..cd130854ff3f2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -132,8 +132,11 @@ public class NotificationShelf extends ActivatableNotificationView implements mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height); ViewGroup.LayoutParams layoutParams = getLayoutParams(); - layoutParams.height = res.getDimensionPixelOffset(R.dimen.notification_shelf_height); - setLayoutParams(layoutParams); + final int newShelfHeight = res.getDimensionPixelOffset(R.dimen.notification_shelf_height); + if (newShelfHeight != layoutParams.height) { + layoutParams.height = newShelfHeight; + setLayoutParams(layoutParams); + } final int padding = res.getDimensionPixelOffset(R.dimen.shelf_icon_container_padding); mShelfIcons.setPadding(padding, 0, padding, 0);