diff options
| author | Winson Chung <winsonc@google.com> | 2020-06-15 20:42:35 -0700 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2020-06-15 22:14:00 -0700 |
| commit | c4b2426d8aced4a3c6ffbc2dca115bd8a34d64d8 (patch) | |
| tree | b8918834fc01d786ae67811953f41d196e0c137b | |
| parent | 8202b399dac76ba73aff6e85ecc790702c0744b3 (diff) | |
Add additional tracing for nav button backgrounds
- Add app systrace events
- Ensure we actually end the animations when jumping to current
state
Change-Id: I8712c019e655eb860e2f919e8d2eae47e380a235
Bug: 156744680
Test: Take systrace and verify events show
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java | 68 |
1 files changed, 51 insertions, 17 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java index c929243085d6..2d8784dc41bd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java @@ -28,7 +28,7 @@ import android.graphics.PixelFormat; import android.graphics.RecordingCanvas; import android.graphics.drawable.Drawable; import android.os.Handler; -import android.util.Log; +import android.os.Trace; import android.view.RenderNodeAnimator; import android.view.View; import android.view.ViewConfiguration; @@ -74,6 +74,11 @@ public class KeyButtonRipple extends Drawable { private final HashSet<Animator> mRunningAnimations = new HashSet<>(); private final ArrayList<Animator> mTmpArray = new ArrayList<>(); + private final TraceAnimatorListener mExitHwTraceAnimator = + new TraceAnimatorListener("exitHardware"); + private final TraceAnimatorListener mEnterHwTraceAnimator = + new TraceAnimatorListener("enterHardware"); + public enum Type { OVAL, ROUNDED_RECT @@ -221,7 +226,7 @@ public class KeyButtonRipple extends Drawable { @Override public void jumpToCurrentState() { - cancelAnimations("jumpToCurrentState"); + endAnimations("jumpToCurrentState", false /* cancel */); } @Override @@ -235,7 +240,6 @@ public class KeyButtonRipple extends Drawable { } public void setPressed(boolean pressed) { - Log.d("b/63783866", "KeyButtonRipple.setPressed: pressed=" + pressed); if (mDark != mLastDark && pressed) { mRipplePaint = null; mLastDark = mDark; @@ -255,14 +259,19 @@ public class KeyButtonRipple extends Drawable { mHandler.removeCallbacksAndMessages(null); } - private void cancelAnimations(String reason) { - Log.d("b/63783866", "KeyButtonRipple.cancelAnimations: reason=" + reason); + private void endAnimations(String reason, boolean cancel) { + Trace.beginSection("KeyButtonRipple.endAnim: reason=" + reason + " cancel=" + cancel); + Trace.endSection(); mVisible = false; mTmpArray.addAll(mRunningAnimations); int size = mTmpArray.size(); for (int i = 0; i < size; i++) { Animator a = mTmpArray.get(i); - a.cancel(); + if (cancel) { + a.cancel(); + } else { + a.end(); + } } mTmpArray.clear(); mRunningAnimations.clear(); @@ -287,7 +296,7 @@ public class KeyButtonRipple extends Drawable { } private void enterSoftware() { - cancelAnimations("enterSoftware"); + endAnimations("enterSoftware", true /* cancel */); mVisible = true; mGlowAlpha = getMaxGlowAlpha(); ObjectAnimator scaleAnimator = ObjectAnimator.ofFloat(this, "glowScale", @@ -373,8 +382,7 @@ public class KeyButtonRipple extends Drawable { } private void enterHardware() { - Log.d("b/63783866", "enterHardware"); - cancelAnimations("enterHardware"); + endAnimations("enterHardware", true /* cancel */); mVisible = true; mDrawingHardwareGlow = true; setExtendStart(CanvasProperty.createFloat(getExtendSize() / 2)); @@ -391,6 +399,7 @@ public class KeyButtonRipple extends Drawable { endAnim.setDuration(ANIMATION_DURATION_SCALE); endAnim.setInterpolator(mInterpolator); endAnim.addListener(mAnimatorListener); + endAnim.addListener(mEnterHwTraceAnimator); endAnim.setTarget(mTargetView); if (isHorizontal()) { @@ -426,13 +435,13 @@ public class KeyButtonRipple extends Drawable { } private void exitHardware() { - Log.d("b/63783866", "exitHardware"); mPaintProp = CanvasProperty.createPaint(getRipplePaint()); final RenderNodeAnimator opacityAnim = new RenderNodeAnimator(mPaintProp, RenderNodeAnimator.PAINT_ALPHA, 0); opacityAnim.setDuration(ANIMATION_DURATION_FADE); opacityAnim.setInterpolator(Interpolators.ALPHA_OUT); opacityAnim.addListener(mAnimatorListener); + opacityAnim.addListener(mExitHwTraceAnimator); opacityAnim.setTarget(mTargetView); opacityAnim.start(); @@ -443,16 +452,41 @@ public class KeyButtonRipple extends Drawable { private final AnimatorListenerAdapter mAnimatorListener = new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mRunningAnimations.remove(animation); + if (mRunningAnimations.isEmpty() && !mPressed) { + mVisible = false; + mDrawingHardwareGlow = false; + invalidateSelf(); + } + } + }; + + private static final class TraceAnimatorListener extends AnimatorListenerAdapter { + private final String mName; + TraceAnimatorListener(String name) { + mName = name; + } + + @Override + public void onAnimationStart(Animator animation) { + Trace.beginSection("KeyButtonRipple.start." + mName); + Trace.endSection(); + } + + @Override + public void onAnimationCancel(Animator animation) { + Trace.beginSection("KeyButtonRipple.cancel." + mName); + Trace.endSection(); + } + @Override public void onAnimationEnd(Animator animation) { - mRunningAnimations.remove(animation); - if (mRunningAnimations.isEmpty() && !mPressed) { - mVisible = false; - mDrawingHardwareGlow = false; - invalidateSelf(); - } + Trace.beginSection("KeyButtonRipple.end." + mName); + Trace.endSection(); } - }; + } /** * Interpolator with a smooth log deceleration |
