From cc82f185bb0cb761379b4519d861123c1a77e134 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Thu, 27 Oct 2022 16:54:43 -0700 Subject: [PATCH] New trace sections for CoreStartables - Add trace sections for CoreStartables usage in SystemUIApplication - Convert methods to static when possible - Add trace section for ConfigurationController#onConfigurationChanged() Test: perfetto trace Bug: 253489562 Change-Id: Ie4a49302e90d8c8f6b18e286a00ffe5b9a3ffbe0 --- .../android/systemui/SystemUIApplication.java | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index 8415ef88f6a00..b888d54956cfd 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -45,6 +45,7 @@ import com.android.internal.protolog.common.ProtoLog; import com.android.systemui.dagger.GlobalRootComponent; import com.android.systemui.dagger.SysUIComponent; import com.android.systemui.dump.DumpManager; +import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.util.NotificationChannels; import java.util.Comparator; @@ -146,7 +147,7 @@ public class SystemUIApplication extends Application implements if (mServicesStarted) { final int N = mServices.length; for (int i = 0; i < N; i++) { - mServices[i].onBootCompleted(); + notifyBootCompleted(mServices[i]); } } } @@ -265,7 +266,7 @@ public class SystemUIApplication extends Application implements for (i = 0; i < mServices.length; i++) { if (mBootCompleteCache.isBootComplete()) { - mServices[i].onBootCompleted(); + notifyBootCompleted(mServices[i]); } mDumpManager.registerDumpable(mServices[i].getClass().getName(), mServices[i]); @@ -276,7 +277,13 @@ public class SystemUIApplication extends Application implements mServicesStarted = true; } - private void timeInitialization(String clsName, Runnable init, TimingsTraceLog log, + private static void notifyBootCompleted(CoreStartable coreStartable) { + Trace.beginSection(coreStartable.getClass().getSimpleName() + ".onBootCompleted()"); + coreStartable.onBootCompleted(); + Trace.endSection(); + } + + private static void timeInitialization(String clsName, Runnable init, TimingsTraceLog log, String metricsPrefix) { long ti = System.currentTimeMillis(); log.traceBegin(metricsPrefix + " " + clsName); @@ -290,11 +297,13 @@ public class SystemUIApplication extends Application implements } } - private CoreStartable startAdditionalStartable(String clsName) { + private static CoreStartable startAdditionalStartable(String clsName) { CoreStartable startable; if (DEBUG) Log.d(TAG, "loading: " + clsName); try { + Trace.beginSection(clsName + ".newInstance()"); startable = (CoreStartable) Class.forName(clsName).newInstance(); + Trace.endSection(); } catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) { @@ -304,14 +313,19 @@ public class SystemUIApplication extends Application implements return startStartable(startable); } - private CoreStartable startStartable(String clsName, Provider provider) { + private static CoreStartable startStartable(String clsName, Provider provider) { if (DEBUG) Log.d(TAG, "loading: " + clsName); - return startStartable(provider.get()); + Trace.beginSection("Provider<" + clsName + ">.get()"); + CoreStartable startable = provider.get(); + Trace.endSection(); + return startStartable(startable); } - private CoreStartable startStartable(CoreStartable startable) { + private static CoreStartable startStartable(CoreStartable startable) { if (DEBUG) Log.d(TAG, "running: " + startable); + Trace.beginSection(startable.getClass().getSimpleName() + ".start()"); startable.start(); + Trace.endSection(); return startable; } @@ -349,11 +363,18 @@ public class SystemUIApplication extends Application implements @Override public void onConfigurationChanged(Configuration newConfig) { if (mServicesStarted) { - mSysUIComponent.getConfigurationController().onConfigurationChanged(newConfig); + ConfigurationController configController = mSysUIComponent.getConfigurationController(); + Trace.beginSection( + configController.getClass().getSimpleName() + ".onConfigurationChanged()"); + configController.onConfigurationChanged(newConfig); + Trace.endSection(); int len = mServices.length; for (int i = 0; i < len; i++) { if (mServices[i] != null) { + Trace.beginSection( + mServices[i].getClass().getSimpleName() + ".onConfigurationChanged()"); mServices[i].onConfigurationChanged(newConfig); + Trace.endSection(); } } }