diff options
6 files changed, 139 insertions, 7 deletions
diff --git a/core/java/com/android/internal/jank/InteractionJankMonitor.java b/core/java/com/android/internal/jank/InteractionJankMonitor.java index 7c10a0a4556f..e0f95544d588 100644 --- a/core/java/com/android/internal/jank/InteractionJankMonitor.java +++ b/core/java/com/android/internal/jank/InteractionJankMonitor.java @@ -16,12 +16,21 @@ package com.android.internal.jank; -import static com.android.internal.jank.FrameTracker.*; +import static com.android.internal.jank.FrameTracker.ChoreographerWrapper; +import static com.android.internal.jank.FrameTracker.SurfaceControlWrapper; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_CLOSE_TO_HOME; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_CLOSE_TO_PIP; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_LAUNCH_FROM_ICON; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_LAUNCH_FROM_RECENTS; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_QUICK_SWITCH; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PASSWORD_APPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PASSWORD_DISAPPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PATTERN_APPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PATTERN_DISAPPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PIN_APPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PIN_DISAPPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_TRANSITION_FROM_AOD; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_TRANSITION_TO_AOD; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__NOTIFICATION_SHADE_SWIPE; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_APP_LAUNCH; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_EXPAND_COLLAPSE_LOCK; @@ -44,7 +53,6 @@ import android.provider.DeviceConfig; import android.util.Log; import android.util.SparseArray; import android.view.Choreographer; -import android.view.SurfaceControl; import android.view.View; import com.android.internal.annotations.VisibleForTesting; @@ -97,6 +105,14 @@ public class InteractionJankMonitor { public static final int CUJ_NOTIFICATION_ADD = 14; public static final int CUJ_NOTIFICATION_REMOVE = 15; public static final int CUJ_NOTIFICATION_APP_START = 16; + public static final int CUJ_LOCKSCREEN_PASSWORD_APPEAR = 17; + public static final int CUJ_LOCKSCREEN_PATTERN_APPEAR = 18; + public static final int CUJ_LOCKSCREEN_PIN_APPEAR = 19; + public static final int CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR = 20; + public static final int CUJ_LOCKSCREEN_PATTERN_DISAPPEAR = 21; + public static final int CUJ_LOCKSCREEN_PIN_DISAPPEAR = 22; + public static final int CUJ_LOCKSCREEN_TRANSITION_FROM_AOD = 23; + public static final int CUJ_LOCKSCREEN_TRANSITION_TO_AOD = 24; private static final int NO_STATSD_LOGGING = -1; @@ -122,6 +138,14 @@ public class InteractionJankMonitor { UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_NOTIFICATION_ADD, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_NOTIFICATION_REMOVE, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_APP_LAUNCH, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PASSWORD_APPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PATTERN_APPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PIN_APPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PASSWORD_DISAPPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PATTERN_DISAPPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PIN_DISAPPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_TRANSITION_FROM_AOD, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_TRANSITION_TO_AOD, }; private static volatile InteractionJankMonitor sInstance; @@ -158,6 +182,14 @@ public class InteractionJankMonitor { CUJ_NOTIFICATION_ADD, CUJ_NOTIFICATION_REMOVE, CUJ_NOTIFICATION_APP_START, + CUJ_LOCKSCREEN_PASSWORD_APPEAR, + CUJ_LOCKSCREEN_PATTERN_APPEAR, + CUJ_LOCKSCREEN_PIN_APPEAR, + CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR, + CUJ_LOCKSCREEN_PATTERN_DISAPPEAR, + CUJ_LOCKSCREEN_PIN_DISAPPEAR, + CUJ_LOCKSCREEN_TRANSITION_FROM_AOD, + CUJ_LOCKSCREEN_TRANSITION_TO_AOD, }) @Retention(RetentionPolicy.SOURCE) public @interface CujType { @@ -366,7 +398,13 @@ public class InteractionJankMonitor { return getNameOfCuj(interactionType - 1); } - private static String getNameOfCuj(int cujType) { + /** + * A helper method to translate CUJ type to CUJ name. + * + * @param cujType the cuj type defined in this file + * @return the name of the cuj type + */ + public static String getNameOfCuj(int cujType) { switch (cujType) { case CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE: return "SHADE_EXPAND_COLLAPSE"; @@ -402,6 +440,22 @@ public class InteractionJankMonitor { return "NOTIFICATION_REMOVE"; case CUJ_NOTIFICATION_APP_START: return "NOTIFICATION_APP_START"; + case CUJ_LOCKSCREEN_PASSWORD_APPEAR: + return "CUJ_LOCKSCREEN_PASSWORD_APPEAR"; + case CUJ_LOCKSCREEN_PATTERN_APPEAR: + return "CUJ_LOCKSCREEN_PATTERN_APPEAR"; + case CUJ_LOCKSCREEN_PIN_APPEAR: + return "CUJ_LOCKSCREEN_PIN_APPEAR"; + case CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR: + return "CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR"; + case CUJ_LOCKSCREEN_PATTERN_DISAPPEAR: + return "CUJ_LOCKSCREEN_PATTERN_DISAPPEAR"; + case CUJ_LOCKSCREEN_PIN_DISAPPEAR: + return "CUJ_LOCKSCREEN_PIN_DISAPPEAR"; + case CUJ_LOCKSCREEN_TRANSITION_FROM_AOD: + return "CUJ_LOCKSCREEN_TRANSITION_FROM_AOD"; + case CUJ_LOCKSCREEN_TRANSITION_TO_AOD: + return "CUJ_LOCKSCREEN_TRANSITION_TO_AOD"; } return "UNKNOWN"; } diff --git a/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java index efac6bc3572d..43ec1e23daad 100644 --- a/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java @@ -219,8 +219,19 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> { } } + /** + * A static method to start translation y animation + */ public static void startTranslationYAnimation(View view, long delay, long duration, float endTranslationY, Interpolator interpolator) { + startTranslationYAnimation(view, delay, duration, endTranslationY, interpolator, null); + } + + /** + * A static method to start translation y animation + */ + public static void startTranslationYAnimation(View view, long delay, long duration, + float endTranslationY, Interpolator interpolator, Animator.AnimatorListener listener) { Animator translationAnim; if (view.isHardwareAccelerated()) { RenderNodeAnimator translationAnimRt = new RenderNodeAnimator( @@ -234,6 +245,9 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> { translationAnim.setInterpolator(interpolator); translationAnim.setDuration(duration); translationAnim.setStartDelay(delay); + if (listener != null) { + translationAnim.addListener(listener); + } translationAnim.start(); } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardInputView.java index d1494dfb107e..5e02e0440c3d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardInputView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardInputView.java @@ -16,6 +16,8 @@ package com.android.keyguard; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; @@ -23,6 +25,7 @@ import android.widget.LinearLayout; import androidx.annotation.Nullable; +import com.android.internal.jank.InteractionJankMonitor; import com.android.systemui.Gefingerpoken; import java.util.ArrayList; @@ -83,4 +86,30 @@ public abstract class KeyguardInputView extends LinearLayout { listener -> listener.onInterceptTouchEvent(event)) || super.onInterceptTouchEvent(event); } + + protected AnimatorListenerAdapter getAnimationListener(int cuj) { + return new AnimatorListenerAdapter() { + private boolean mIsCancel; + + @Override + public void onAnimationCancel(Animator animation) { + mIsCancel = true; + } + + @Override + public void onAnimationEnd(Animator animation) { + if (mIsCancel) { + InteractionJankMonitor.getInstance().cancel(cuj); + } else { + InteractionJankMonitor.getInstance().end(cuj); + } + } + + @Override + public void onAnimationStart(Animator animation) { + InteractionJankMonitor.getInstance().begin(KeyguardInputView.this, cuj); + } + }; + } + } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java index 580d7043a220..b7a2c64dd107 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java @@ -22,6 +22,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; +import com.android.internal.jank.InteractionJankMonitor; import com.android.settingslib.animation.AppearAnimationUtils; import com.android.settingslib.animation.DisappearAnimationUtils; import com.android.systemui.R; @@ -116,7 +117,8 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { setAlpha(1f); setTranslationY(mAppearAnimationUtils.getStartTranslation()); AppearAnimationUtils.startTranslationYAnimation(this, 0 /* delay */, 500 /* duration */, - 0, mAppearAnimationUtils.getInterpolator()); + 0, mAppearAnimationUtils.getInterpolator(), + getAnimationListener(InteractionJankMonitor.CUJ_LOCKSCREEN_PIN_APPEAR)); mAppearAnimationUtils.startAnimation2d(mViews, new Runnable() { @Override @@ -132,7 +134,8 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { enableClipping(false); setTranslationY(0); AppearAnimationUtils.startTranslationYAnimation(this, 0 /* delay */, 280 /* duration */, - mDisappearYTranslation, mDisappearAnimationUtils.getInterpolator()); + mDisappearYTranslation, mDisappearAnimationUtils.getInterpolator(), + getAnimationListener(InteractionJankMonitor.CUJ_LOCKSCREEN_PIN_DISAPPEAR)); DisappearAnimationUtils disappearAnimationUtils = needsSlowUnlockTransition ? mDisappearAnimationUtilsLocked : mDisappearAnimationUtils; diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java index bdcf467c2456..d4513384c569 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java @@ -26,6 +26,7 @@ import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; +import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.widget.LockPatternView; import com.android.settingslib.animation.AppearAnimationCreator; import com.android.settingslib.animation.AppearAnimationUtils; @@ -143,7 +144,8 @@ public class KeyguardPatternView extends KeyguardInputView setAlpha(1f); setTranslationY(mAppearAnimationUtils.getStartTranslation()); AppearAnimationUtils.startTranslationYAnimation(this, 0 /* delay */, 500 /* duration */, - 0, mAppearAnimationUtils.getInterpolator()); + 0, mAppearAnimationUtils.getInterpolator(), + getAnimationListener(InteractionJankMonitor.CUJ_LOCKSCREEN_PATTERN_APPEAR)); mAppearAnimationUtils.startAnimation2d( mLockPatternView.getCellStates(), () -> enableClipping(true), @@ -167,7 +169,8 @@ public class KeyguardPatternView extends KeyguardInputView AppearAnimationUtils.startTranslationYAnimation(this, 0 /* delay */, (long) (300 * durationMultiplier), -mDisappearAnimationUtils.getStartTranslation(), - mDisappearAnimationUtils.getInterpolator()); + mDisappearAnimationUtils.getInterpolator(), + getAnimationListener(InteractionJankMonitor.CUJ_LOCKSCREEN_PATTERN_DISAPPEAR)); DisappearAnimationUtils disappearAnimationUtils = needsSlowUnlockTransition ? mDisappearAnimationUtilsLocked : mDisappearAnimationUtils; diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index 42f3cc7069ba..cc59c39888a8 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -48,6 +48,7 @@ import androidx.annotation.VisibleForTesting; import androidx.dynamicanimation.animation.DynamicAnimation; import androidx.dynamicanimation.animation.SpringAnimation; +import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.widget.LockPatternUtils; @@ -112,6 +113,9 @@ public class KeyguardSecurityContainer extends FrameLayout { @Override public WindowInsetsAnimation.Bounds onStart(WindowInsetsAnimation animation, WindowInsetsAnimation.Bounds bounds) { + if (!mDisappearAnimRunning) { + beginJankInstrument(InteractionJankMonitor.CUJ_LOCKSCREEN_PASSWORD_APPEAR); + } mSecurityViewFlipper.getBoundsOnScreen(mFinalBounds); return bounds; } @@ -144,6 +148,7 @@ public class KeyguardSecurityContainer extends FrameLayout { @Override public void onEnd(WindowInsetsAnimation animation) { if (!mDisappearAnimRunning) { + endJankInstrument(InteractionJankMonitor.CUJ_LOCKSCREEN_PASSWORD_APPEAR); mSecurityViewFlipper.animateForIme(0, /* interpolatedFraction */ 1f); } } @@ -354,7 +359,17 @@ public class KeyguardSecurityContainer extends FrameLayout { }); anim.addListener(new AnimatorListenerAdapter() { @Override + public void onAnimationStart(Animator animation) { + beginJankInstrument( + InteractionJankMonitor + .CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR); + } + + @Override public void onAnimationEnd(Animator animation) { + endJankInstrument( + InteractionJankMonitor + .CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR); controller.finish(false); } }); @@ -372,11 +387,25 @@ public class KeyguardSecurityContainer extends FrameLayout { @Override public void onCancelled( @Nullable WindowInsetsAnimationController controller) { + cancelJankInstrument( + InteractionJankMonitor.CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR); } }); } } + private void beginJankInstrument(int cuj) { + InteractionJankMonitor.getInstance().begin(mSecurityViewFlipper.getSecurityView(), cuj); + } + + private void endJankInstrument(int cuj) { + InteractionJankMonitor.getInstance().end(cuj); + } + + private void cancelJankInstrument(int cuj) { + InteractionJankMonitor.getInstance().cancel(cuj); + } + /** * Enables/disables swipe up to retry on the bouncer. */ |