Reduce lockscreen stock surface cleanup work

This commit is contained in:
ajp_anton
2026-06-23 18:05:36 +00:00
parent 2249212ae3
commit 2fe90ce3fc
@@ -138,6 +138,8 @@ final class StockLayoutCanvasController {
Collections.newSetFromMap(new WeakHashMap<>()); Collections.newSetFromMap(new WeakHashMap<>());
private final Set<View> trackedLockedStatusBarIconSurfaces = private final Set<View> trackedLockedStatusBarIconSurfaces =
Collections.newSetFromMap(new WeakHashMap<>()); Collections.newSetFromMap(new WeakHashMap<>());
private final Set<View> lockedStatusBarIconSurfaceReadyRoots =
Collections.newSetFromMap(new WeakHashMap<>());
private final Set<View> pendingUnlockedAppearanceRefreshRoots = private final Set<View> pendingUnlockedAppearanceRefreshRoots =
Collections.newSetFromMap(new WeakHashMap<>()); Collections.newSetFromMap(new WeakHashMap<>());
private final Set<View> pendingUnlockedClockTextRefreshRoots = private final Set<View> pendingUnlockedClockTextRefreshRoots =
@@ -1937,12 +1939,15 @@ final class StockLayoutCanvasController {
if (current.isUnlocked() && !previous.isUnlocked()) { if (current.isUnlocked() && !previous.isUnlocked()) {
darkIconDispatcherGuard.restoreForcedStates(); darkIconDispatcherGuard.restoreForcedStates();
trackedLockedStatusBarIconSurfaces.clear(); trackedLockedStatusBarIconSurfaces.clear();
lockedStatusBarIconSurfaceReadyRoots.clear();
} else if (previous.isLockscreen() && current.isAod()) { } else if (previous.isLockscreen() && current.isAod()) {
darkIconDispatcherGuard.restoreForcedStates(); darkIconDispatcherGuard.restoreForcedStates();
hideTrackedLockedStatusBarIconSurfaces(null); hideTrackedLockedStatusBarIconSurfaces(null);
lockedStatusBarIconSurfaceReadyRoots.clear();
} else if (previous.isLockscreen() && !current.isLockscreen()) { } else if (previous.isLockscreen() && !current.isLockscreen()) {
darkIconDispatcherGuard.restoreForcedStates(); darkIconDispatcherGuard.restoreForcedStates();
restoreTrackedLockedStatusBarIconSurfaces(null); restoreTrackedLockedStatusBarIconSurfaces(null);
lockedStatusBarIconSurfaceReadyRoots.clear();
} }
boolean lockscreenEntry = current.isLockscreen(); boolean lockscreenEntry = current.isLockscreen();
if (lockscreenEntry) { if (lockscreenEntry) {
@@ -1983,6 +1988,7 @@ final class StockLayoutCanvasController {
} }
unlockedIconRenderController.clearRoot(root); unlockedIconRenderController.clearRoot(root);
dirtyUnlockedLayoutRoots.add(root); dirtyUnlockedLayoutRoots.add(root);
lockedStatusBarIconSurfaceReadyRoots.remove(root);
if (isViewThread(root)) { if (isViewThread(root)) {
applyToRoot(root); applyToRoot(root);
} else { } else {
@@ -2935,9 +2941,16 @@ final class StockLayoutCanvasController {
} }
private void hideOrDiscoverLockedStatusBarIconSurfaces(View root) { private void hideOrDiscoverLockedStatusBarIconSurfaces(View root) {
hideTrackedLockedStatusBarIconSurfaces(root); if (root != null && lockedStatusBarIconSurfaceReadyRoots.contains(root)) {
if (root != null) { return;
trackAndHideLockedStatusBarIconSurfaces(root); }
boolean hasTrackedSurfacesInRoot = hideTrackedLockedStatusBarIconSurfaces(root);
int discovered = 0;
if (!hasTrackedSurfacesInRoot && root != null) {
discovered = trackAndHideLockedStatusBarIconSurfaces(root);
}
if (root != null && (hasTrackedSurfacesInRoot || discovered > 0)) {
lockedStatusBarIconSurfaceReadyRoots.add(root);
} }
} }
@@ -2945,30 +2958,29 @@ final class StockLayoutCanvasController {
if (trackedLockedStatusBarIconSurfaces.isEmpty()) { if (trackedLockedStatusBarIconSurfaces.isEmpty()) {
return false; return false;
} }
boolean foundInRoot = false; boolean foundActiveInRoot = false;
ArrayDeque<View> staleViews = new ArrayDeque<>(); ArrayDeque<View> staleViews = new ArrayDeque<>();
for (View view : trackedLockedStatusBarIconSurfaces) { for (View view : trackedLockedStatusBarIconSurfaces) {
if (view == null || !view.isAttachedToWindow()) { if (view == null || !view.isAttachedToWindow()) {
staleViews.add(view); staleViews.add(view);
continue; continue;
} }
if (root == null || isDescendantOf(view, root)) { boolean inRoot = root == null || isDescendantOf(view, root);
foundInRoot = true;
if (isAlreadySuppressedHiddenView(view)) {
continue;
}
}
if (!isLockedStatusBarIconSurface(view)) { if (!isLockedStatusBarIconSurface(view)) {
restoreView(view); restoreView(view);
staleViews.add(view); staleViews.add(view);
continue; continue;
} }
if (root == null || isDescendantOf(view, root)) { if (inRoot) {
foundActiveInRoot = true;
if (isAlreadySuppressedHiddenView(view)) {
continue;
}
hideView(view, isCarrierView(view)); hideView(view, isCarrierView(view));
} }
} }
removeStaleViews(trackedLockedStatusBarIconSurfaces, staleViews); removeStaleViews(trackedLockedStatusBarIconSurfaces, staleViews);
return foundInRoot; return foundActiveInRoot;
} }
private boolean isAlreadySuppressedHiddenView(View view) { private boolean isAlreadySuppressedHiddenView(View view) {
@@ -3130,6 +3142,11 @@ final class StockLayoutCanvasController {
} }
} }
removeStaleViews(trackedLockedStatusBarIconSurfaces, restoredViews); removeStaleViews(trackedLockedStatusBarIconSurfaces, restoredViews);
if (root != null) {
lockedStatusBarIconSurfaceReadyRoots.remove(root);
} else {
lockedStatusBarIconSurfaceReadyRoots.clear();
}
} }
private boolean hasTrackedStatusChipSources(View root) { private boolean hasTrackedStatusChipSources(View root) {
@@ -4345,6 +4362,7 @@ final class StockLayoutCanvasController {
} }
clearTrackedStatusChipState(); clearTrackedStatusChipState();
trackedLockedStatusBarIconSurfaces.clear(); trackedLockedStatusBarIconSurfaces.clear();
lockedStatusBarIconSurfaceReadyRoots.clear();
trackedUnlockedStockSurfaces.clear(); trackedUnlockedStockSurfaces.clear();
confirmedAodPluginViews.clear(); confirmedAodPluginViews.clear();
aodPluginVisualAlphaByView.clear(); aodPluginVisualAlphaByView.clear();