Adding some tracing sections around launcher startup
Bug: 29007436
Change-Id: I53afd9130a2dc70a2223f1623e862faf44370f26
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index e24adf9..271c69b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -64,6 +64,7 @@
import android.os.Message;
import android.os.StrictMode;
import android.os.SystemClock;
+import android.os.Trace;
import android.os.UserHandle;
import android.text.Selection;
import android.text.SpannableStringBuilder;
@@ -146,7 +147,6 @@
public static final String TAG = "Launcher";
static final boolean LOGD = false;
- static final boolean PROFILE_STARTUP = false;
static final boolean DEBUG_WIDGETS = false;
static final boolean DEBUG_STRICT_MODE = false;
static final boolean DEBUG_RESUME_TIME = false;
@@ -398,6 +398,9 @@
.penaltyDeath()
.build());
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Launcher-onCreate");
+ }
if (mLauncherCallbacks != null) {
mLauncherCallbacks.preOnCreate();
@@ -433,11 +436,6 @@
// LauncherModel load.
mPaused = false;
- if (PROFILE_STARTUP) {
- android.os.Debug.startMethodTracing(
- Environment.getExternalStorageDirectory() + "/launcher");
- }
-
setContentView(R.layout.launcher);
setupViews();
@@ -453,8 +451,8 @@
mSavedState = savedInstanceState;
restoreState(mSavedState);
- if (PROFILE_STARTUP) {
- android.os.Debug.stopMethodTracing();
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
}
if (!mRestoring) {
@@ -3587,6 +3585,9 @@
* Implementation of the method from LauncherModel.Callbacks.
*/
public void startBinding() {
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Starting page bind");
+ }
setWorkspaceLoading(true);
// Clear the workspace because it's going to be rebound
@@ -3597,6 +3598,9 @@
if (mHotseat != null) {
mHotseat.resetLayout();
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
@Override
@@ -3962,6 +3966,9 @@
if (waitUntilResume(r)) {
return;
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Page bind completed");
+ }
if (mSavedState != null) {
if (!mWorkspace.hasFocus()) {
mWorkspace.getChildAt(mWorkspace.getCurrentPage()).requestFocus();
@@ -3996,6 +4003,9 @@
if (mLauncherCallbacks != null) {
mLauncherCallbacks.finishBindingItems(false);
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
private boolean canRunNewAppsAnimation() {
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index c2e7f1a..fe65b31 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -25,6 +25,7 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dynamicui.ExtractionUtils;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.util.ConfigMonitor;
@@ -35,6 +36,8 @@
public class LauncherAppState {
+ public static final boolean PROFILE_STARTUP = ProviderConfig.IS_DOGFOOD_BUILD;
+
private final AppFilter mAppFilter;
@Thunk final LauncherModel mModel;
private final IconCache mIconCache;
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index a5e703e..68a9c7e 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -37,6 +37,7 @@
import android.os.Parcelable;
import android.os.Process;
import android.os.SystemClock;
+import android.os.Trace;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.util.Log;
@@ -1542,6 +1543,9 @@
}
private void loadWorkspace() {
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Loading Workspace");
+ }
final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
final Context context = mContext;
@@ -2157,6 +2161,9 @@
}
}
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
/**
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 4e7d57b..f5b32ed 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -44,6 +44,7 @@
import android.os.Handler;
import android.os.Message;
import android.os.Process;
+import android.os.Trace;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
@@ -86,6 +87,9 @@
@Override
public boolean onCreate() {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
+ Log.d(TAG, "Launcher process started");
+ }
mListenerHandler = new Handler(mListenerWrapper);
LauncherAppState.setLauncherProvider(this);
@@ -115,6 +119,9 @@
*/
protected synchronized void createDbIfNotExists() {
if (mOpenHelper == null) {
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Opening workspace DB");
+ }
mOpenHelper = new DatabaseHelper(getContext(), mListenerHandler);
if (RestoreDbTask.isPending(getContext())) {
@@ -125,6 +132,10 @@
// executed again.
RestoreDbTask.setPending(getContext(), false);
}
+
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
}