From 682782c232972a5437199f579e3b1acda482a70a Mon Sep 17 00:00:00 2001 From: ajp_anton Date: Sat, 11 Jul 2026 12:12:28 +0000 Subject: [PATCH] Reduce draw-only statusbar work --- .../clock/DrawerClockTextController.java | 26 +++++++++++++ .../layout/StockLayoutCanvasController.java | 39 +++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/app/src/main/java/se/ajpanton/statusbartweak/runtime/features/clock/DrawerClockTextController.java b/app/src/main/java/se/ajpanton/statusbartweak/runtime/features/clock/DrawerClockTextController.java index 4472a27..9f4710c 100644 --- a/app/src/main/java/se/ajpanton/statusbartweak/runtime/features/clock/DrawerClockTextController.java +++ b/app/src/main/java/se/ajpanton/statusbartweak/runtime/features/clock/DrawerClockTextController.java @@ -104,6 +104,10 @@ final class DrawerClockTextController { untrackDisabledRoles(clockEnabled, dateEnabled); SurfaceMode surfaceMode = scene != null ? scene.surfaceMode() : null; + if (!root.isLayoutRequested() + && hasAttachedCachedCandidates(root, clockEnabled, dateEnabled, surfaceMode)) { + return; + } if (hasValidTrackedCandidates(root, clockEnabled, dateEnabled, surfaceMode)) { return; } @@ -200,6 +204,28 @@ final class DrawerClockTextController { return false; } + private boolean hasAttachedCachedCandidates( + View root, + boolean clockEnabled, + boolean dateEnabled, + SurfaceMode surfaceMode + ) { + CandidateCache cache = candidateCacheByRoot.get(root); + if (cache == null || cache.surfaceMode != surfaceMode) { + return false; + } + return (!clockEnabled || isAttachedCachedCandidate(cache.clockView, Role.CLOCK)) + && (!dateEnabled || isAttachedCachedCandidate(cache.dateView, Role.DATE)); + } + + private boolean isAttachedCachedCandidate(WeakReference reference, Role role) { + TextView textView = reference != null ? reference.get() : null; + return textView != null + && textView.isAttachedToWindow() + && trackedRoles.get(textView) == role + && ownedTexts.contains(textView); + } + private void track(TextView textView, Role role) { if (textView == null || role == null) { return; diff --git a/app/src/main/java/se/ajpanton/statusbartweak/runtime/layout/StockLayoutCanvasController.java b/app/src/main/java/se/ajpanton/statusbartweak/runtime/layout/StockLayoutCanvasController.java index 32f2c0d..6e7d57a 100644 --- a/app/src/main/java/se/ajpanton/statusbartweak/runtime/layout/StockLayoutCanvasController.java +++ b/app/src/main/java/se/ajpanton/statusbartweak/runtime/layout/StockLayoutCanvasController.java @@ -2402,6 +2402,16 @@ final class StockLayoutCanvasController { boolean unlockedScene = activeScene != null && activeScene.isUnlocked(); boolean aodScene = activeScene != null && activeScene.isAod(); boolean rootDirty = dirtyUnlockedLayoutRoots.remove(root); + if (canSkipStableDrawOnlyApply(root, activeScene, rootDirty)) { + if (unlockedScene) { + syncUnlockedHostsToStockStatusBar(root, activeScene); + hideTrackedUnlockedStockSurfaces(root); + hideTrackedStatusChipSources(root); + } else { + bringUnlockedHostsAndDebugOverlayToFront(root); + } + return; + } boolean aodLayoutRoot = aodScene && isAodLayoutRoot(root, activeScene); boolean hasAodLayoutPlan = aodScene && unlockedIconRenderController.hasLayoutPlan(root); boolean layoutRoot = aodScene ? aodLayoutRoot : statusBarRoot; @@ -2551,6 +2561,35 @@ final class StockLayoutCanvasController { }); } + private boolean canSkipStableDrawOnlyApply( + View root, + SceneKey scene, + boolean rootDirty + ) { + if (root == null + || scene == null + || (!scene.isUnlocked() && !scene.isLockscreen()) + || root.isLayoutRequested()) { + return false; + } + if (rootDirty) { + return false; + } + if (!hasDirectUnlockedLayoutHost(root)) { + return false; + } + if (!unlockedIconRenderController.hasLayoutPlan(root)) { + return false; + } + if (isKnownRootGeometryChanged(root)) { + return false; + } + if (scene.isUnlocked() && !hasTrackedUnlockedStockSurfaces(root)) { + return false; + } + return true; + } + private void hideTrackedUnlockedStockSurfaces(View root) { if (root == null || trackedUnlockedStockSurfaces.isEmpty()) { return;