From 51dfd53f36218ee277e735f76fd4f5308a23e053 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Thu, 3 Feb 2022 10:43:28 -0800 Subject: [PATCH] Only relayout when mIgnoredSlots changes This avoids relayouting sysui when calling add/removeIgnoredSlot has no effect. Bug: 190379081 Test: https://ui.perfetto.dev/#!/viewer?trace_id=c57e4aca-d306-66b0-df47-009944328158 Change-Id: I9e5d5c3bfe20c8df10b779e39cdab39ebf95573b --- .../statusbar/phone/StatusIconContainer.java | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java index 329293409dc20..d464acb7fe76e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java @@ -217,8 +217,10 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { * frameworks/base/core/res/res/values/config.xml */ public void addIgnoredSlot(String slotName) { - addIgnoredSlotInternal(slotName); - requestLayout(); + boolean added = addIgnoredSlotInternal(slotName); + if (added) { + requestLayout(); + } } /** @@ -226,17 +228,27 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { * @param slots names of the icons to ignore */ public void addIgnoredSlots(List slots) { + boolean willAddAny = false; for (String slot : slots) { - addIgnoredSlotInternal(slot); + willAddAny |= addIgnoredSlotInternal(slot); } - requestLayout(); + if (willAddAny) { + requestLayout(); + } } - private void addIgnoredSlotInternal(String slotName) { - if (!mIgnoredSlots.contains(slotName)) { - mIgnoredSlots.add(slotName); + /** + * + * @param slotName + * @return + */ + private boolean addIgnoredSlotInternal(String slotName) { + if (mIgnoredSlots.contains(slotName)) { + return false; } + mIgnoredSlots.add(slotName); + return true; } /** @@ -245,9 +257,10 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { * @param slotName name of the icon slot to remove from the ignored list */ public void removeIgnoredSlot(String slotName) { - mIgnoredSlots.remove(slotName); - - requestLayout(); + boolean removed = mIgnoredSlots.remove(slotName); + if (removed) { + requestLayout(); + } } /** @@ -256,11 +269,14 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { * @param slots name of the icon slots to remove from the ignored list */ public void removeIgnoredSlots(List slots) { + boolean removedAny = false; for (String slot : slots) { - mIgnoredSlots.remove(slot); + removedAny |= mIgnoredSlots.remove(slot); } - requestLayout(); + if (removedAny) { + requestLayout(); + } } /**