diff options
7 files changed, 69 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java index 19a6b0937a6f..1a616a058d00 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java +++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java @@ -105,7 +105,7 @@ public class AlternateRecentsComponent { final static int MSG_CLOSE_RECENTS = 4; final static int MSG_TOGGLE_RECENTS = 5; - final static int sMinToggleDelay = 475; + final static int sMinToggleDelay = 425; final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS"; final static String sRecentsPackage = "com.android.systemui"; @@ -139,6 +139,10 @@ public class AlternateRecentsComponent { /** Toggles the alternate recents activity */ public void onToggleRecents(Display display, int layoutDirection, View statusBarView) { + Console.logStartTracingTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey); + Console.logStartTracingTime(Constants.DebugFlags.App.TimeRecentsLaunchTask, + Constants.DebugFlags.App.TimeRecentsLaunchKey); Console.log(Constants.DebugFlags.App.RecentsComponent, "[RecentsComponent|toggleRecents]", "serviceIsBound: " + mServiceIsBound); mStatusBarView = statusBarView; @@ -304,6 +308,12 @@ public class AlternateRecentsComponent { Message msg = Message.obtain(null, MSG_TOGGLE_RECENTS, 0, 0); msg.setData(data); mService.send(msg); + + // Time this path + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey, "sendToggleRecents"); + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsLaunchTask, + Constants.DebugFlags.App.TimeRecentsLaunchKey, "sendToggleRecents"); } catch (RemoteException re) { re.printStackTrace(); } @@ -357,6 +367,9 @@ public class AlternateRecentsComponent { R.anim.recents_from_launcher_exit); startAlternateRecentsActivity(opts); } + + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey, "startRecentsActivity"); mLastToggleTime = System.currentTimeMillis(); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/Console.java b/packages/SystemUI/src/com/android/systemui/recents/Console.java index 614c4e7ab488..4b75c9931b6b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Console.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Console.java @@ -23,7 +23,14 @@ import android.util.Log; import android.view.MotionEvent; import android.widget.Toast; +import java.util.HashMap; +import java.util.Map; + + public class Console { + // Timer + public static final Map<Object, Long> mTimeLogs = new HashMap<Object, Long>(); + // Colors public static final String AnsiReset = "\u001B[0m"; public static final String AnsiBlack = "\u001B[30m"; @@ -80,6 +87,25 @@ public class Console { } } + /** Starts a time trace */ + public static void logStartTracingTime(boolean condition, String key) { + if (condition) { + long curTime = System.currentTimeMillis(); + mTimeLogs.put(key, curTime); + Console.log(condition, "[Recents|" + key + "]", + "started @ " + curTime); + } + } + + /** Continues a time trace */ + public static void logTraceTime(boolean condition, String key, String desc) { + if (condition) { + long timeDiff = System.currentTimeMillis() - mTimeLogs.get(key); + Console.log(condition, "[Recents|" + key + "|" + desc + "]", + "+" + timeDiff + "ms"); + } + } + /** Logs a stack trace */ public static void logStackTrace() { logStackTrace("", 99); diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java index 59a591ab79de..2dc4b88bbc03 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java @@ -32,6 +32,12 @@ public class Constants { // This disables the bitmap and icon caches to public static final boolean DisableBackgroundCache = false; + // Timing certain paths + public static final String TimeRecentsStartupKey = "startup"; + public static final String TimeRecentsLaunchKey = "launchTask"; + public static final boolean TimeRecentsStartup = false; + public static final boolean TimeRecentsLaunchTask = false; + public static final boolean RecentsComponent = false; public static final boolean TaskDataLoader = false; public static final boolean SystemUIHandshake = false; diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index 8408684f86ce..b65b8640b89d 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -101,6 +101,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView Console.logDivider(Constants.DebugFlags.App.SystemUIHandshake); Console.log(Constants.DebugFlags.App.SystemUIHandshake, "[RecentsActivity|onCreate]", getIntent().getAction() + " visible: " + mVisible, Console.AnsiRed); + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey, "onCreate"); // Initialize the loader and the configuration RecentsTaskLoader.initialize(this); @@ -135,13 +137,14 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); - // Reset the task launched flag if we encounter an onNewIntent() before onStop() mTaskLaunched = false; Console.logDivider(Constants.DebugFlags.App.SystemUIHandshake); Console.log(Constants.DebugFlags.App.SystemUIHandshake, "[RecentsActivity|onNewIntent]", intent.getAction() + " visible: " + mVisible, Console.AnsiRed); + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey, "onNewIntent"); // Initialize the loader and the configuration RecentsTaskLoader.initialize(this); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java index 485b136021c2..515cec139217 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java @@ -84,6 +84,12 @@ class SystemUIMessageHandler extends Handler { Intent intent = new Intent(RecentsService.ACTION_TOGGLE_RECENTS_ACTIVITY); intent.setPackage(context.getPackageName()); context.sendBroadcast(intent); + + // Time this path + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey, "receivedToggleRecents"); + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsLaunchTask, + Constants.DebugFlags.App.TimeRecentsLaunchKey, "receivedToggleRecents"); } } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index 9133f7d3274f..77b78f395f05 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -108,8 +108,11 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); + Console.log(Constants.DebugFlags.UI.MeasureAndLayout, "[RecentsView|measure]", "width: " + width + " height: " + height, Console.AnsiGreen); + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey, "RecentsView.onMeasure"); // We measure our stack views sans the status bar. It will handle the nav bar itself. RecentsConfiguration config = RecentsConfiguration.getInstance(); @@ -132,6 +135,9 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV protected void onLayout(boolean changed, int left, int top, int right, int bottom) { Console.log(Constants.DebugFlags.UI.MeasureAndLayout, "[RecentsView|layout]", new Rect(left, top, right, bottom) + " changed: " + changed, Console.AnsiGreen); + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup, + Constants.DebugFlags.App.TimeRecentsStartupKey, "RecentsView.onLayout"); + // We offset our stack views by the status bar height. It will handle the nav bar itself. RecentsConfiguration config = RecentsConfiguration.getInstance(); top += config.systemInsets.top; @@ -241,9 +247,15 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV } else { getContext().startActivityAsUser(i, UserHandle.CURRENT); } + + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsLaunchTask, + Constants.DebugFlags.App.TimeRecentsLaunchKey, "startActivity"); } }; + Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsLaunchTask, + Constants.DebugFlags.App.TimeRecentsLaunchKey, "onTaskLaunched"); + // Launch the app right away if there is no task view, otherwise, animate the icon out first if (tv == null || !Constants.Values.TaskView.AnimateFrontTaskIconOnLeavingRecents) { post(launchRunnable); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java index 9d4f92dc236f..f41171792d87 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -330,6 +330,7 @@ public class TaskView extends FrameLayout implements View.OnClickListener, Task. } else { mIconView.animate() .alpha(0f) + .setStartDelay(0) .setDuration(Constants.Values.TaskView.Animation.TaskIconOnLeavingDuration) .setInterpolator(new DecelerateInterpolator()) .setListener( |