From 45e2d8faed70252f8c5535ed9dee903b45f60ac1 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 16 May 2017 14:23:19 +0200 Subject: [PATCH] Optimize latency when closing panel with animation The interpolator we chose had a very slow easy out where it generated out frame with mExpandedHeight=0.3 pixels. We add a check there and stop the animation immediately if this happens. Furthermore, we just use a simple post when closing the panel to not add to much latency. The frame will be shown in any case since we are already in animation/input callback, such that a post will be executed after the frame has been sent to RT. Test: Capture trace, unlock phone, make sure no delays Change-Id: I9fc45f4b081bd6143da1ba99e9bc652a9f64e4a7 Fixes: 38294347 --- .../android/systemui/statusbar/phone/PanelView.java | 13 ++++++++++--- .../statusbar/phone/PhoneStatusBarView.java | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index e378e871394cc..9d1d03859f815 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -34,10 +34,9 @@ import android.view.animation.Interpolator; import android.widget.FrameLayout; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.systemui.DejankUtils; -import com.android.systemui.EventLogTags; -import com.android.systemui.Interpolators; import com.android.keyguard.LatencyTracker; +import com.android.systemui.DejankUtils; +import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.classifier.FalsingManager; import com.android.systemui.doze.DozeLog; @@ -833,6 +832,14 @@ public abstract class PanelView extends FrameLayout { } } + // If we are closing the panel and we are almost there due to a slow decelerating + // interpolator, abort the animation. + if (mExpandedHeight < 1f && mExpandedHeight != 0f && mClosing) { + mExpandedHeight = 0f; + if (mHeightAnimator != null) { + mHeightAnimator.end(); + } + } mExpandedFraction = Math.min(1f, fhWithoutOverExpansion == 0 ? 0 : mExpandedHeight / fhWithoutOverExpansion); onHeightUpdated(mExpandedHeight); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 916b603f54fa6..970d1de251d5b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -121,12 +121,12 @@ public class PhoneStatusBarView extends PanelBar { public void onPanelCollapsed() { super.onPanelCollapsed(); // Close the status bar in the next frame so we can show the end of the animation. - DejankUtils.postAfterTraversal(mHideExpandedRunnable); + post(mHideExpandedRunnable); mIsFullyOpenedPanel = false; } public void removePendingHideExpandedRunnables() { - DejankUtils.removeCallbacks(mHideExpandedRunnable); + removeCallbacks(mHideExpandedRunnable); } @Override