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<>());
private final Set<View> trackedLockedStatusBarIconSurfaces =
Collections.newSetFromMap(new WeakHashMap<>());
private final Set<View> lockedStatusBarIconSurfaceReadyRoots =
Collections.newSetFromMap(new WeakHashMap<>());
private final Set<View> pendingUnlockedAppearanceRefreshRoots =
Collections.newSetFromMap(new WeakHashMap<>());
private final Set<View> pendingUnlockedClockTextRefreshRoots =
@@ -1937,12 +1939,15 @@ final class StockLayoutCanvasController {
if (current.isUnlocked() && !previous.isUnlocked()) {
darkIconDispatcherGuard.restoreForcedStates();
trackedLockedStatusBarIconSurfaces.clear();
lockedStatusBarIconSurfaceReadyRoots.clear();
} else if (previous.isLockscreen() && current.isAod()) {
darkIconDispatcherGuard.restoreForcedStates();
hideTrackedLockedStatusBarIconSurfaces(null);
lockedStatusBarIconSurfaceReadyRoots.clear();
} else if (previous.isLockscreen() && !current.isLockscreen()) {
darkIconDispatcherGuard.restoreForcedStates();
restoreTrackedLockedStatusBarIconSurfaces(null);
lockedStatusBarIconSurfaceReadyRoots.clear();
}
boolean lockscreenEntry = current.isLockscreen();
if (lockscreenEntry) {
@@ -1983,6 +1988,7 @@ final class StockLayoutCanvasController {
}
unlockedIconRenderController.clearRoot(root);
dirtyUnlockedLayoutRoots.add(root);
lockedStatusBarIconSurfaceReadyRoots.remove(root);
if (isViewThread(root)) {
applyToRoot(root);
} else {
@@ -2935,9 +2941,16 @@ final class StockLayoutCanvasController {
}
private void hideOrDiscoverLockedStatusBarIconSurfaces(View root) {
hideTrackedLockedStatusBarIconSurfaces(root);
if (root != null) {
trackAndHideLockedStatusBarIconSurfaces(root);
if (root != null && lockedStatusBarIconSurfaceReadyRoots.contains(root)) {
return;
}
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()) {
return false;
}
boolean foundInRoot = false;
boolean foundActiveInRoot = false;
ArrayDeque<View> staleViews = new ArrayDeque<>();
for (View view : trackedLockedStatusBarIconSurfaces) {
if (view == null || !view.isAttachedToWindow()) {
staleViews.add(view);
continue;
}
if (root == null || isDescendantOf(view, root)) {
foundInRoot = true;
if (isAlreadySuppressedHiddenView(view)) {
continue;
}
}
boolean inRoot = root == null || isDescendantOf(view, root);
if (!isLockedStatusBarIconSurface(view)) {
restoreView(view);
staleViews.add(view);
continue;
}
if (root == null || isDescendantOf(view, root)) {
if (inRoot) {
foundActiveInRoot = true;
if (isAlreadySuppressedHiddenView(view)) {
continue;
}
hideView(view, isCarrierView(view));
}
}
removeStaleViews(trackedLockedStatusBarIconSurfaces, staleViews);
return foundInRoot;
return foundActiveInRoot;
}
private boolean isAlreadySuppressedHiddenView(View view) {
@@ -3130,6 +3142,11 @@ final class StockLayoutCanvasController {
}
}
removeStaleViews(trackedLockedStatusBarIconSurfaces, restoredViews);
if (root != null) {
lockedStatusBarIconSurfaceReadyRoots.remove(root);
} else {
lockedStatusBarIconSurfaceReadyRoots.clear();
}
}
private boolean hasTrackedStatusChipSources(View root) {
@@ -4345,6 +4362,7 @@ final class StockLayoutCanvasController {
}
clearTrackedStatusChipState();
trackedLockedStatusBarIconSurfaces.clear();
lockedStatusBarIconSurfaceReadyRoots.clear();
trackedUnlockedStockSurfaces.clear();
confirmedAodPluginViews.clear();
aodPluginVisualAlphaByView.clear();