Avoid drawing the first frame in launcher before animation completes
Currently Launcher reports the drawing of the first frame before the
fade-in animation runs to a completion. This CL pauses the pre-draw
until the animation concludes so that the performance metrics matches
what user actually sees.
Bug: 210527498
Test: 1) reboot verify things works 2) sign in to second user, verify
things works.
Change-Id: I0146c0408005c3de75098b9401089ed2bcbcb6d6
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 801a31d..7abdef8 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -106,6 +106,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.view.WindowManager.LayoutParams;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.OvershootInterpolator;
@@ -503,6 +504,23 @@
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
setContentView(getRootView());
+ getRootView().getViewTreeObserver().addOnPreDrawListener(
+ new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ // Checks the status of fade in animation.
+ final AlphaProperty property =
+ mDragLayer.getAlphaProperty(ALPHA_INDEX_LAUNCHER_LOAD);
+ if (property.getValue() == 0) {
+ // Animation haven't started yet; suspend.
+ return false;
+ } else {
+ // The animation is started; start drawing.
+ getRootView().getViewTreeObserver().removeOnPreDrawListener(this);
+ return true;
+ }
+ }
+ });
getRootView().dispatchInsets();
// Listen for broadcasts