From 2d7c9ee5e2ccf5844cb5fb9b0ef1297bb431475b Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Tue, 22 Nov 2022 15:24:04 -0800 Subject: [PATCH] Trace sections for ScreenDecorations Add new trace sections for ScreenDecorations for debugging jank. Test: manual Bug: 259677469 Change-Id: I539a87fc05788f8b01224b110c5afcc04e6c7909 --- .../android/systemui/ScreenDecorations.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index 45f9385a26208..5617fef6cd3f6 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -217,8 +217,10 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { (FaceScanningOverlay) getOverlayView(mFaceScanningViewId); if (faceScanningOverlay != null) { faceScanningOverlay.setHideOverlayRunnable(() -> { + Trace.beginSection("ScreenDecorations#hideOverlayRunnable"); updateOverlayWindowVisibilityIfViewExists( faceScanningOverlay.findViewById(mFaceScanningViewId)); + Trace.endSection(); }); faceScanningOverlay.enableShowProtection(false); } @@ -280,16 +282,18 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { if (mOverlays == null || !shouldOptimizeVisibility()) { return; } - + Trace.beginSection("ScreenDecorations#updateOverlayWindowVisibilityIfViewExists"); for (final OverlayWindow overlay : mOverlays) { if (overlay == null) { continue; } if (overlay.getView(view.getId()) != null) { overlay.getRootView().setVisibility(getWindowVisibility(overlay, true)); + Trace.endSection(); return; } } + Trace.endSection(); }); } @@ -379,6 +383,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { } private void startOnScreenDecorationsThread() { + Trace.beginSection("ScreenDecorations#startOnScreenDecorationsThread"); mWindowManager = mContext.getSystemService(WindowManager.class); mDisplayManager = mContext.getSystemService(DisplayManager.class); mContext.getDisplay().getDisplayInfo(mDisplayInfo); @@ -481,6 +486,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { mDisplayManager.registerDisplayListener(mDisplayListener, mHandler); updateConfiguration(); + Trace.endSection(); } @VisibleForTesting @@ -530,6 +536,12 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { } private void setupDecorations() { + Trace.beginSection("ScreenDecorations#setupDecorations"); + setupDecorationsInner(); + Trace.endSection(); + } + + private void setupDecorationsInner() { if (hasRoundedCorners() || shouldDrawCutout() || isPrivacyDotEnabled() || mFaceScanningFactory.getHasProviders()) { @@ -582,7 +594,11 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { return; } - mMainExecutor.execute(() -> mTunerService.addTunable(this, SIZE)); + mMainExecutor.execute(() -> { + Trace.beginSection("ScreenDecorations#addTunable"); + mTunerService.addTunable(this, SIZE); + Trace.endSection(); + }); // Watch color inversion and invert the overlay as needed. if (mColorInversionSetting == null) { @@ -605,7 +621,11 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { mExecutor, UserHandle.ALL); mIsRegistered = true; } else { - mMainExecutor.execute(() -> mTunerService.removeTunable(this)); + mMainExecutor.execute(() -> { + Trace.beginSection("ScreenDecorations#removeTunable"); + mTunerService.removeTunable(this); + Trace.endSection(); + }); if (mColorInversionSetting != null) { mColorInversionSetting.setListening(false); @@ -951,6 +971,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { } mExecutor.execute(() -> { + Trace.beginSection("ScreenDecorations#onConfigurationChanged"); int oldRotation = mRotation; mPendingConfigChange = false; updateConfiguration(); @@ -963,6 +984,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { // the updated rotation). updateLayoutParams(); } + Trace.endSection(); }); } @@ -1131,6 +1153,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { if (mOverlays == null || !SIZE.equals(key)) { return; } + Trace.beginSection("ScreenDecorations#onTuningChanged"); try { final int sizeFactor = Integer.parseInt(newValue); mRoundedCornerResDelegate.setTuningSizeFactor(sizeFactor); @@ -1144,6 +1167,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable { R.id.rounded_corner_bottom_right }); updateHwLayerRoundedCornerExistAndSize(); + Trace.endSection(); }); }