diff --git a/core/java/com/android/internal/jank/FrameTracker.java b/core/java/com/android/internal/jank/FrameTracker.java
index 4126801346101..f28c42a10978d 100644
--- a/core/java/com/android/internal/jank/FrameTracker.java
+++ b/core/java/com/android/internal/jank/FrameTracker.java
@@ -208,7 +208,6 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
*/
public synchronized void begin() {
mBeginVsyncId = mChoreographer.getVsyncId() + 1;
- mSession.setTimeStamp(System.nanoTime());
if (mSurfaceControl != null) {
postTraceStartMarker();
}
@@ -224,7 +223,11 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
}
}
- private void postTraceStartMarker() {
+ /**
+ * Start trace section at appropriate time.
+ */
+ @VisibleForTesting
+ public void postTraceStartMarker() {
mChoreographer.mChoreographer.postCallback(Choreographer.CALLBACK_INPUT, () -> {
synchronized (FrameTracker.this) {
if (mCancelled || mEndVsyncId != INVALID_ID) {
diff --git a/core/java/com/android/internal/jank/InteractionJankMonitor.java b/core/java/com/android/internal/jank/InteractionJankMonitor.java
index 7648b1641f448..28b325b15b9c9 100644
--- a/core/java/com/android/internal/jank/InteractionJankMonitor.java
+++ b/core/java/com/android/internal/jank/InteractionJankMonitor.java
@@ -39,6 +39,7 @@ import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_IN
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__LOCKSCREEN_UNLOCK_ANIMATION;
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__SETTINGS_PAGE_SCROLL;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_APP_LAUNCH;
@@ -62,6 +63,7 @@ import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
+import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.Choreographer;
@@ -91,6 +93,7 @@ import java.util.concurrent.TimeUnit;
*/
public class InteractionJankMonitor {
private static final String TAG = InteractionJankMonitor.class.getSimpleName();
+ private static final boolean DEBUG = false;
private static final String ACTION_PREFIX = InteractionJankMonitor.class.getCanonicalName();
private static final String DEFAULT_WORKER_NAME = TAG + "-Worker";
@@ -148,6 +151,7 @@ public class InteractionJankMonitor {
public static final int CUJ_LAUNCHER_ALL_APPS_SCROLL = 26;
public static final int CUJ_LAUNCHER_APP_LAUNCH_FROM_WIDGET = 27;
public static final int CUJ_SETTINGS_PAGE_SCROLL = 28;
+ public static final int CUJ_LOCKSCREEN_UNLOCK_ANIMATION = 29;
private static final int NO_STATSD_LOGGING = -1;
@@ -185,6 +189,7 @@ public class InteractionJankMonitor {
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_ALL_APPS_SCROLL,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_LAUNCH_FROM_WIDGET,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SETTINGS_PAGE_SCROLL,
+ UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_UNLOCK_ANIMATION,
};
private static volatile InteractionJankMonitor sInstance;
@@ -233,6 +238,7 @@ public class InteractionJankMonitor {
CUJ_LAUNCHER_ALL_APPS_SCROLL,
CUJ_LAUNCHER_APP_LAUNCH_FROM_WIDGET,
CUJ_SETTINGS_PAGE_SCROLL,
+ CUJ_LOCKSCREEN_UNLOCK_ANIMATION,
})
@Retention(RetentionPolicy.SOURCE)
public @interface CujType {
@@ -289,14 +295,17 @@ public class InteractionJankMonitor {
* @return instance of the FrameTracker
*/
@VisibleForTesting
- public FrameTracker createFrameTracker(View v, Session session) {
+ public FrameTracker createFrameTracker(Configuration conf, Session session) {
+ final View v = conf.mView;
final Context c = v.getContext().getApplicationContext();
+ final ThreadedRendererWrapper r = new ThreadedRendererWrapper(v.getThreadedRenderer());
+ final ViewRootWrapper vr = new ViewRootWrapper(v.getViewRootImpl());
+ final SurfaceControlWrapper sc = new SurfaceControlWrapper();
+ final ChoreographerWrapper cg = new ChoreographerWrapper(Choreographer.getInstance());
+
synchronized (this) {
FrameTrackerListener eventsListener = (s, act) -> handleCujEvents(c, act, s);
- return new FrameTracker(session, mWorker.getThreadHandler(),
- new ThreadedRendererWrapper(v.getThreadedRenderer()),
- new ViewRootWrapper(v.getViewRootImpl()), new SurfaceControlWrapper(),
- new ChoreographerWrapper(Choreographer.getInstance()), mMetrics,
+ return new FrameTracker(session, mWorker.getThreadHandler(), r, vr, sc, cg, mMetrics,
mTraceThresholdMissedFrames, mTraceThresholdFrameTimeMillis, eventsListener);
}
}
@@ -348,30 +357,47 @@ public class InteractionJankMonitor {
/**
* Begin a trace session.
*
+ * @param v an attached view.
* @param cujType the specific {@link InteractionJankMonitor.CujType}.
* @return boolean true if the tracker is started successfully, false otherwise.
*/
public boolean begin(View v, @CujType int cujType) {
- synchronized (this) {
- return begin(v, cujType, DEFAULT_TIMEOUT_MS);
+ try {
+ return beginInternal(
+ new Configuration.Builder(cujType)
+ .setView(v)
+ .build());
+ } catch (IllegalArgumentException ex) {
+ Log.d(TAG, "Build configuration failed!", ex);
+ return false;
}
}
/**
* Begin a trace session.
*
- * @param cujType the specific {@link InteractionJankMonitor.CujType}.
- * @param timeout the elapsed time in ms until firing the timeout action.
+ * @param builder the builder of the configurations for instrumenting the CUJ.
* @return boolean true if the tracker is started successfully, false otherwise.
*/
- public boolean begin(View v, @CujType int cujType, long timeout) {
+ public boolean begin(@NonNull Configuration.Builder builder) {
+ try {
+ return beginInternal(builder.build());
+ } catch (IllegalArgumentException ex) {
+ Log.d(TAG, "Build configuration failed!", ex);
+ return false;
+ }
+ }
+
+ private boolean beginInternal(@NonNull Configuration conf) {
synchronized (this) {
- if (!v.isAttachedToWindow()) {
- Log.d(TAG, "View not attached!", new Throwable());
- return false;
- }
+ int cujType = conf.mCujType;
boolean shouldSample = ThreadLocalRandom.current().nextInt() % mSamplingInterval == 0;
if (!mEnabled || !shouldSample) {
+ if (DEBUG) {
+ Log.d(TAG, "Skip monitoring cuj: " + getNameOfCuj(cujType)
+ + ", enable=" + mEnabled + ", debuggable=" + DEFAULT_ENABLED
+ + ", sample=" + shouldSample + ", interval=" + mSamplingInterval);
+ }
return false;
}
FrameTracker tracker = getTracker(cujType);
@@ -379,14 +405,14 @@ public class InteractionJankMonitor {
if (tracker != null) return false;
// begin a new trace session.
- tracker = createFrameTracker(v, new Session(cujType));
+ tracker = createFrameTracker(conf, new Session(cujType, conf.mTag));
mRunningTrackers.put(cujType, tracker);
tracker.begin();
// Cancel the trace if we don't get an end() call in specified duration.
Runnable timeoutAction = () -> cancel(cujType);
mTimeoutActions.put(cujType, timeoutAction);
- mWorker.getThreadHandler().postDelayed(timeoutAction, timeout);
+ mWorker.getThreadHandler().postDelayed(timeoutAction, conf.mTimeout);
return true;
}
}
@@ -526,47 +552,150 @@ public class InteractionJankMonitor {
case CUJ_NOTIFICATION_APP_START:
return "NOTIFICATION_APP_START";
case CUJ_LOCKSCREEN_PASSWORD_APPEAR:
- return "CUJ_LOCKSCREEN_PASSWORD_APPEAR";
+ return "LOCKSCREEN_PASSWORD_APPEAR";
case CUJ_LOCKSCREEN_PATTERN_APPEAR:
- return "CUJ_LOCKSCREEN_PATTERN_APPEAR";
+ return "LOCKSCREEN_PATTERN_APPEAR";
case CUJ_LOCKSCREEN_PIN_APPEAR:
- return "CUJ_LOCKSCREEN_PIN_APPEAR";
+ return "LOCKSCREEN_PIN_APPEAR";
case CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR:
- return "CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR";
+ return "LOCKSCREEN_PASSWORD_DISAPPEAR";
case CUJ_LOCKSCREEN_PATTERN_DISAPPEAR:
- return "CUJ_LOCKSCREEN_PATTERN_DISAPPEAR";
+ return "LOCKSCREEN_PATTERN_DISAPPEAR";
case CUJ_LOCKSCREEN_PIN_DISAPPEAR:
- return "CUJ_LOCKSCREEN_PIN_DISAPPEAR";
+ return "LOCKSCREEN_PIN_DISAPPEAR";
case CUJ_LOCKSCREEN_TRANSITION_FROM_AOD:
- return "CUJ_LOCKSCREEN_TRANSITION_FROM_AOD";
+ return "LOCKSCREEN_TRANSITION_FROM_AOD";
case CUJ_LOCKSCREEN_TRANSITION_TO_AOD:
- return "CUJ_LOCKSCREEN_TRANSITION_TO_AOD";
+ return "LOCKSCREEN_TRANSITION_TO_AOD";
case CUJ_LAUNCHER_OPEN_ALL_APPS :
- return "CUJ_LAUNCHER_OPEN_ALL_APPS";
+ return "LAUNCHER_OPEN_ALL_APPS";
case CUJ_LAUNCHER_ALL_APPS_SCROLL:
- return "CUJ_LAUNCHER_ALL_APPS_SCROLL";
+ return "LAUNCHER_ALL_APPS_SCROLL";
case CUJ_LAUNCHER_APP_LAUNCH_FROM_WIDGET:
return "LAUNCHER_APP_LAUNCH_FROM_WIDGET";
case CUJ_SETTINGS_PAGE_SCROLL:
return "SETTINGS_PAGE_SCROLL";
+ case CUJ_LOCKSCREEN_UNLOCK_ANIMATION:
+ return "LOCKSCREEN_UNLOCK_ANIMATION";
}
return "UNKNOWN";
}
+ /**
+ * Configurations used while instrumenting the CUJ.
+ * It may refer to an attached view, don't use static reference for any purpose.
+ */
+ public static class Configuration {
+ private final View mView;
+ private final long mTimeout;
+ private final String mTag;
+ private final @CujType int mCujType;
+
+ /**
+ * A builder for building Configuration.
+ * It may refer to an attached view, don't use static reference for any purpose.
+ */
+ public static class Builder {
+ private View mAttrView = null;
+ private long mAttrTimeout = DEFAULT_TIMEOUT_MS;
+ private String mAttrTag = "";
+ private @CujType int mAttrCujType;
+
+ /**
+ * @param cuj The enum defined in {@link InteractionJankMonitor.CujType}.
+ */
+ public Builder(@CujType int cuj) {
+ mAttrCujType = cuj;
+ }
+
+ /**
+ * @param view an attached view
+ * @return builder
+ */
+ public Builder setView(@NonNull View view) {
+ mAttrView = view;
+ return this;
+ }
+
+ /**
+ * @param timeout duration to cancel the instrumentation in ms
+ * @return builder
+ */
+ public Builder setTimeout(long timeout) {
+ mAttrTimeout = timeout;
+ return this;
+ }
+
+ /**
+ * @param tag The postfix of the CUJ in the output trace.
+ * It provides a brief description for the CUJ like the concrete class
+ * who is dealing with the CUJ or the important state with the CUJ, etc.
+ * @return builder
+ */
+ public Builder setTag(@NonNull String tag) {
+ mAttrTag = tag;
+ return this;
+ }
+
+ /**
+ * Build the {@link Configuration} instance
+ * @return the instance of {@link Configuration}
+ * @throws IllegalArgumentException if any invalid attribute is set
+ */
+ public Configuration build() throws IllegalArgumentException {
+ return new Configuration(mAttrCujType, mAttrView, mAttrTag, mAttrTimeout);
+ }
+ }
+
+ private Configuration(@CujType int cuj, View view, String tag, long timeout) {
+ mCujType = cuj;
+ mTag = tag;
+ mTimeout = timeout;
+ mView = view;
+ validate();
+ }
+
+ private void validate() {
+ boolean shouldThrow = false;
+ final StringBuilder msg = new StringBuilder();
+
+ if (mTag == null) {
+ shouldThrow = true;
+ msg.append("Invalid tag; ");
+ }
+ if (mTimeout < 0) {
+ shouldThrow = true;
+ msg.append("Invalid timeout value; ");
+ }
+ if (mView == null || !mView.isAttachedToWindow()) {
+ shouldThrow = true;
+ msg.append("Null view or view is not attached yet; ");
+ }
+ if (shouldThrow) {
+ throw new IllegalArgumentException(msg.toString());
+ }
+ }
+ }
+
/**
* A class to represent a session.
*/
public static class Session {
@CujType
- private int mCujType;
- private long mTimeStamp;
+ private final int mCujType;
+ private final long mTimeStamp;
@FrameTracker.Reasons
private int mReason = FrameTracker.REASON_END_UNKNOWN;
- private boolean mShouldNotify;
+ private final boolean mShouldNotify;
+ private final String mName;
- public Session(@CujType int cujType) {
+ public Session(@CujType int cujType, @NonNull String postfix) {
mCujType = cujType;
+ mTimeStamp = System.nanoTime();
mShouldNotify = SystemProperties.getBoolean(PROP_NOTIFY_CUJ_EVENT, false);
+ mName = TextUtils.isEmpty(postfix)
+ ? String.format("J<%s>", getNameOfCuj(mCujType))
+ : String.format("J<%s::%s>", getNameOfCuj(mCujType), postfix);
}
@CujType
@@ -588,11 +717,7 @@ public class InteractionJankMonitor {
}
public String getName() {
- return "J<" + getNameOfCuj(mCujType) + ">";
- }
-
- public void setTimeStamp(long timeStamp) {
- mTimeStamp = timeStamp;
+ return mName;
}
public long getTimeStamp() {
diff --git a/core/java/com/android/internal/util/LatencyTracker.java b/core/java/com/android/internal/util/LatencyTracker.java
index 358e6ef874297..f040462dafdcd 100644
--- a/core/java/com/android/internal/util/LatencyTracker.java
+++ b/core/java/com/android/internal/util/LatencyTracker.java
@@ -105,6 +105,11 @@ public class LatencyTracker {
*/
public static final int ACTION_ROTATE_SCREEN_CAMERA_CHECK = 10;
+ /**
+ * Time it takes to start unlock animation .
+ */
+ public static final int ACTION_LOCKSCREEN_UNLOCK = 11;
+
private static final int[] ACTIONS_ALL = {
ACTION_EXPAND_PANEL,
ACTION_TOGGLE_RECENTS,
@@ -116,7 +121,8 @@ public class LatencyTracker {
ACTION_FACE_WAKE_AND_UNLOCK,
ACTION_START_RECENTS_ANIMATION,
ACTION_ROTATE_SCREEN_SENSOR,
- ACTION_ROTATE_SCREEN_CAMERA_CHECK
+ ACTION_ROTATE_SCREEN_CAMERA_CHECK,
+ ACTION_LOCKSCREEN_UNLOCK
};
/** @hide */
@@ -131,7 +137,8 @@ public class LatencyTracker {
ACTION_FACE_WAKE_AND_UNLOCK,
ACTION_START_RECENTS_ANIMATION,
ACTION_ROTATE_SCREEN_SENSOR,
- ACTION_ROTATE_SCREEN_CAMERA_CHECK
+ ACTION_ROTATE_SCREEN_CAMERA_CHECK,
+ ACTION_LOCKSCREEN_UNLOCK
})
@Retention(RetentionPolicy.SOURCE)
public @interface Action {
@@ -148,7 +155,8 @@ public class LatencyTracker {
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_FACE_WAKE_AND_UNLOCK,
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_START_RECENTS_ANIMATION,
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_SENSOR,
- FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_CAMERA_CHECK
+ FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_CAMERA_CHECK,
+ FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_LOCKSCREEN_UNLOCK
};
private static LatencyTracker sLatencyTracker;
@@ -229,6 +237,8 @@ public class LatencyTracker {
return "ACTION_ROTATE_SCREEN_CAMERA_CHECK";
case 11:
return "ACTION_ROTATE_SCREEN_SENSOR";
+ case 12:
+ return "ACTION_LOCKSCREEN_UNLOCK";
default:
throw new IllegalArgumentException("Invalid action");
}
diff --git a/core/tests/coretests/src/com/android/internal/jank/FrameTrackerTest.java b/core/tests/coretests/src/com/android/internal/jank/FrameTrackerTest.java
index 6d85c7f5c5670..c8f8ca9fd5b08 100644
--- a/core/tests/coretests/src/com/android/internal/jank/FrameTrackerTest.java
+++ b/core/tests/coretests/src/com/android/internal/jank/FrameTrackerTest.java
@@ -62,6 +62,7 @@ import java.util.concurrent.TimeUnit;
@SmallTest
public class FrameTrackerTest {
+ private static final String CUJ_POSTFIX = "";
private ViewAttachTestActivity mActivity;
@Rule
@@ -100,15 +101,17 @@ public class FrameTrackerTest {
mListenerCapture.capture(), any());
doNothing().when(mSurfaceControlWrapper).removeJankStatsListener(
mListenerCapture.capture());
+
mChoreographer = mock(ChoreographerWrapper.class);
- Session session = new Session(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ Session session = new Session(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE, CUJ_POSTFIX);
mTracker = Mockito.spy(
new FrameTracker(session, handler, mRenderer, mViewRootWrapper,
mSurfaceControlWrapper, mChoreographer, mWrapper,
/*traceThresholdMissedFrames=*/ 1, /*traceThresholdFrameTimeMillis=*/ -1,
null));
doNothing().when(mTracker).triggerPerfetto();
+ doNothing().when(mTracker).postTraceStartMarker();
}
@Test
diff --git a/core/tests/coretests/src/com/android/internal/jank/InteractionJankMonitorTest.java b/core/tests/coretests/src/com/android/internal/jank/InteractionJankMonitorTest.java
index 5f4b854d872d2..8ec1559861f3c 100644
--- a/core/tests/coretests/src/com/android/internal/jank/InteractionJankMonitorTest.java
+++ b/core/tests/coretests/src/com/android/internal/jank/InteractionJankMonitorTest.java
@@ -62,6 +62,7 @@ import java.util.stream.Collectors;
@SmallTest
public class InteractionJankMonitorTest {
+ private static final String CUJ_POSTFIX = "";
private ViewAttachTestActivity mActivity;
private View mView;
private HandlerThread mWorker;
@@ -90,7 +91,7 @@ public class InteractionJankMonitorTest {
InteractionJankMonitor monitor = spy(new InteractionJankMonitor(mWorker));
verify(mWorker).start();
- Session session = new Session(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ Session session = new Session(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE, CUJ_POSTFIX);
FrameTracker tracker = spy(new FrameTracker(session, mWorker.getThreadHandler(),
new ThreadedRendererWrapper(mView.getThreadedRenderer()),
new ViewRootWrapper(mView.getViewRootImpl()), new SurfaceControlWrapper(),
@@ -137,7 +138,7 @@ public class InteractionJankMonitorTest {
ArgumentCaptor captor = ArgumentCaptor.forClass(Message.class);
- Session session = new Session(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ Session session = new Session(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE, CUJ_POSTFIX);
FrameTracker tracker = spy(new FrameTracker(session, mWorker.getThreadHandler(),
new ThreadedRendererWrapper(mView.getThreadedRenderer()),
new ViewRootWrapper(mView.getViewRootImpl()), new SurfaceControlWrapper(),
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/InteractionJankMonitorWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/InteractionJankMonitorWrapper.java
index d40b94c0e20c0..42d2333587b43 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/InteractionJankMonitorWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/InteractionJankMonitorWrapper.java
@@ -20,11 +20,14 @@ import android.annotation.IntDef;
import android.view.View;
import com.android.internal.jank.InteractionJankMonitor;
+import com.android.internal.jank.InteractionJankMonitor.Configuration;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public final class InteractionJankMonitorWrapper {
+ private static final String TAG = "JankMonitorWrapper";
+
// Launcher journeys.
public static final int CUJ_APP_LAUNCH_FROM_RECENTS =
InteractionJankMonitor.CUJ_LAUNCHER_APP_LAUNCH_FROM_RECENTS;
@@ -60,7 +63,11 @@ public final class InteractionJankMonitorWrapper {
}
public static boolean begin(View v, @CujType int cujType, long timeout) {
- return InteractionJankMonitor.getInstance().begin(v, cujType, timeout);
+ Configuration.Builder builder =
+ new Configuration.Builder(cujType)
+ .setView(v)
+ .setTimeout(timeout);
+ return InteractionJankMonitor.getInstance().begin(builder);
}
public static boolean end(@CujType int cujType) {
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java
index e41d5a3e34a75..1c4559eb03641 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java
@@ -172,6 +172,7 @@ public abstract class KeyguardAbsKeyInputViewController {
if (finishedCallback == null) {
+ InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
return;
}
@@ -2227,6 +2244,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException");
+ } finally {
+ InteractionJankMonitor.getInstance()
+ .end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
}
@@ -2236,6 +2256,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException");
+ } finally {
+ InteractionJankMonitor.getInstance()
+ .cancel(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
}
});
@@ -2259,6 +2282,12 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
sendUserPresentBroadcast();
}
+ private Configuration.Builder createInteractionJankMonitorConf(String tag) {
+ return new Configuration.Builder(CUJ_LOCKSCREEN_UNLOCK_ANIMATION)
+ .setView(mKeyguardViewControllerLazy.get().getViewRootImpl().getView())
+ .setTag(tag);
+ }
+
/**
* Whether we're currently animating between the keyguard and the app/launcher surface behind
* it, or will be shortly (which happens if we started a fling to dismiss the keyguard).
@@ -2304,6 +2333,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
finishSurfaceBehindRemoteAnimation();
mSurfaceBehindRemoteAnimationRequested = false;
mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation();
+ InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
index 3e2bcf9562b04..61f6ad54bc269 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
@@ -32,6 +32,7 @@ import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
import com.android.internal.jank.InteractionJankMonitor;
+import com.android.internal.jank.InteractionJankMonitor.Configuration;
import com.android.settingslib.Utils;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
@@ -542,8 +543,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
@Override
public void onAnimationStart(Animator animation) {
mWasCancelled = false;
- InteractionJankMonitor.getInstance().begin(ActivatableNotificationView.this,
- getCujType(isAppearing));
+ Configuration.Builder builder = new Configuration.Builder(getCujType(isAppearing))
+ .setView(ActivatableNotificationView.this);
+ InteractionJankMonitor.getInstance().begin(builder);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
index a3efcd2263461..798e8953b1704 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
@@ -26,7 +26,6 @@ import static java.lang.Float.isNaN;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -42,7 +41,6 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.Interpolator;
-import android.view.animation.PathInterpolator;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -336,8 +334,7 @@ public abstract class PanelViewController {
protected void startExpandMotion(float newX, float newY, boolean startTracking,
float expandedHeight) {
if (!mHandlingPointerUp) {
- InteractionJankMonitor.getInstance().begin(mView,
- CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ beginJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
}
mInitialOffsetOnTouch = expandedHeight;
mInitialTouchY = newY;
@@ -533,7 +530,7 @@ public abstract class PanelViewController {
protected void flingToHeight(float vel, boolean expand, float target,
float collapseSpeedUpFactor, boolean expandBecauseOfFalsing) {
if (target == mExpandedHeight || getOverExpansionAmount() > 0f && expand) {
- InteractionJankMonitor.getInstance().end(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ endJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
mKeyguardStateController.notifyPanelFlingEnd();
notifyExpandingFinished();
return;
@@ -579,8 +576,7 @@ public abstract class PanelViewController {
@Override
public void onAnimationStart(Animator animation) {
- InteractionJankMonitor.getInstance()
- .begin(mView, CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ beginJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
}
@Override
@@ -632,12 +628,10 @@ public abstract class PanelViewController {
setAnimator(null);
mKeyguardStateController.notifyPanelFlingEnd();
if (!cancelled) {
- InteractionJankMonitor.getInstance()
- .end(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ endJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
notifyExpandingFinished();
} else {
- InteractionJankMonitor.getInstance()
- .cancel(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ cancelJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
}
notifyBarPanelExpansionChanged();
}
@@ -847,8 +841,7 @@ public abstract class PanelViewController {
mView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (mAnimateAfterExpanding) {
notifyExpandingStarted();
- InteractionJankMonitor.getInstance().begin(mView,
- CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ beginJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
fling(0, true /* expand */);
} else {
setExpandedFraction(1f);
@@ -1304,11 +1297,10 @@ public abstract class PanelViewController {
endMotionEvent(event, x, y, false /* forceCancel */);
// mHeightAnimator is null, there is no remaining frame, ends instrumenting.
if (mHeightAnimator == null) {
- InteractionJankMonitor monitor = InteractionJankMonitor.getInstance();
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
- monitor.end(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ endJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
} else {
- monitor.cancel(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
+ cancelJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
}
}
break;
@@ -1338,4 +1330,20 @@ public abstract class PanelViewController {
loadDimens();
}
}
+
+ private void beginJankMonitoring(int cuj) {
+ InteractionJankMonitor.Configuration.Builder builder =
+ new InteractionJankMonitor.Configuration.Builder(cuj)
+ .setView(mView)
+ .setTag(isFullyCollapsed() ? "Expand" : "Collapse");
+ InteractionJankMonitor.getInstance().begin(builder);
+ }
+
+ private void endJankMonitoring(int cuj) {
+ InteractionJankMonitor.getInstance().end(cuj);
+ }
+
+ private void cancelJankMonitoring(int cuj) {
+ InteractionJankMonitor.getInstance().cancel(cuj);
+ }
}