Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62b7a6ba authored by Steven Terrell's avatar Steven Terrell
Browse files

Add Navigation Component

Add a navigationComponent field to AppJankStats. This field is intended
to be populated with a navigation destination, screen or pane name. This
iteration arose after a discussion with the Compose team where it was
identified that the concept of a Widget_Id does not really apply to
composable functions.

Bug: 385173526
Test: atest CoreAppJankTestCases
flag: android.app.jank.detailed_app_jank_metrics_api
Change-Id: I32ad7a398fcf73352eed7aa48a8210707d08a198
parent 623fd00c
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -9190,8 +9190,9 @@ package android.app.blob {
package android.app.jank {
package android.app.jank {
  @FlaggedApi("android.app.jank.detailed_app_jank_metrics_api") public final class AppJankStats {
  @FlaggedApi("android.app.jank.detailed_app_jank_metrics_api") public final class AppJankStats {
    ctor public AppJankStats(int, @NonNull String, @Nullable String, @Nullable String, long, long, @NonNull android.app.jank.RelativeFrameTimeHistogram);
    ctor public AppJankStats(int, @NonNull String, @Nullable String, @Nullable String, @Nullable String, long, long, @NonNull android.app.jank.RelativeFrameTimeHistogram);
    method public long getJankyFrameCount();
    method public long getJankyFrameCount();
    method @Nullable public String getNavigationComponent();
    method @NonNull public android.app.jank.RelativeFrameTimeHistogram getRelativeFrameTimeHistogram();
    method @NonNull public android.app.jank.RelativeFrameTimeHistogram getRelativeFrameTimeHistogram();
    method public long getTotalFrameCount();
    method public long getTotalFrameCount();
    method public int getUid();
    method public int getUid();
+15 −2
Original line number Original line Diff line number Diff line
@@ -57,6 +57,8 @@ public final class AppJankStats {
    // Histogram of relative frame times encoded in predetermined buckets.
    // Histogram of relative frame times encoded in predetermined buckets.
    private RelativeFrameTimeHistogram mRelativeFrameTimeHistogram;
    private RelativeFrameTimeHistogram mRelativeFrameTimeHistogram;


    // Navigation component associated to this stat.
    private String mNavigationComponent;


    /** Used to indicate no widget category has been set. */
    /** Used to indicate no widget category has been set. */
    public static final String WIDGET_CATEGORY_UNSPECIFIED = "unspecified";
    public static final String WIDGET_CATEGORY_UNSPECIFIED = "unspecified";
@@ -158,6 +160,8 @@ public final class AppJankStats {
     *
     *
     * @param appUid the Uid of the App that is collecting jank stats.
     * @param appUid the Uid of the App that is collecting jank stats.
     * @param widgetId the widget id that frames will be associated to.
     * @param widgetId the widget id that frames will be associated to.
     * @param navigationComponent the intended navigation target within the activity, this could be
     *                            a navigation destination, screen and/or pane.
     * @param widgetCategory a category used to organize widgets in a structured way that indicates
     * @param widgetCategory a category used to organize widgets in a structured way that indicates
     *                       they serve a similar purpose or perform related functions. Must be
     *                       they serve a similar purpose or perform related functions. Must be
     *                       prefixed with WIDGET_CATEGORY_ and have a suffix of one of the
     *                       prefixed with WIDGET_CATEGORY_ and have a suffix of one of the
@@ -172,14 +176,14 @@ public final class AppJankStats {
     * @param jankyFrames the total number of janky frames that were counted for this stat.
     * @param jankyFrames the total number of janky frames that were counted for this stat.
     * @param relativeFrameTimeHistogram the histogram with predefined buckets. See
     * @param relativeFrameTimeHistogram the histogram with predefined buckets. See
     * {@link #getRelativeFrameTimeHistogram()} for details.
     * {@link #getRelativeFrameTimeHistogram()} for details.
     *
     */
     */
    public AppJankStats(int appUid, @NonNull String widgetId,
    public AppJankStats(int appUid, @NonNull String widgetId, @Nullable String navigationComponent,
            @Nullable @WidgetCategory String widgetCategory,
            @Nullable @WidgetCategory String widgetCategory,
            @Nullable @WidgetState String widgetState, long totalFrames, long jankyFrames,
            @Nullable @WidgetState String widgetState, long totalFrames, long jankyFrames,
            @NonNull RelativeFrameTimeHistogram relativeFrameTimeHistogram) {
            @NonNull RelativeFrameTimeHistogram relativeFrameTimeHistogram) {
        mUid = appUid;
        mUid = appUid;
        mWidgetId = widgetId;
        mWidgetId = widgetId;
        mNavigationComponent = navigationComponent;
        mWidgetCategory = widgetCategory != null ? widgetCategory : WIDGET_CATEGORY_UNSPECIFIED;
        mWidgetCategory = widgetCategory != null ? widgetCategory : WIDGET_CATEGORY_UNSPECIFIED;
        mWidgetState = widgetState != null ? widgetState : WIDGET_STATE_UNSPECIFIED;
        mWidgetState = widgetState != null ? widgetState : WIDGET_STATE_UNSPECIFIED;
        mTotalFrames = totalFrames;
        mTotalFrames = totalFrames;
@@ -254,4 +258,13 @@ public final class AppJankStats {
    public @NonNull RelativeFrameTimeHistogram getRelativeFrameTimeHistogram() {
    public @NonNull RelativeFrameTimeHistogram getRelativeFrameTimeHistogram() {
        return mRelativeFrameTimeHistogram;
        return mRelativeFrameTimeHistogram;
    }
    }

    /**
     * Returns the navigation component if it exists that this stat applies to.
     *
     * @return the navigation component if it exists that this stat applies to.
     */
    public @Nullable String getNavigationComponent() {
        return mNavigationComponent;
    }
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ public class JankUtils {
        AppJankStats jankStats = new AppJankStats(
        AppJankStats jankStats = new AppJankStats(
                /*App Uid*/APP_ID,
                /*App Uid*/APP_ID,
                /*Widget Id*/"test widget id",
                /*Widget Id*/"test widget id",
                /*navigationComponent*/null,
                /*Widget Category*/AppJankStats.WIDGET_CATEGORY_SCROLL,
                /*Widget Category*/AppJankStats.WIDGET_CATEGORY_SCROLL,
                /*Widget State*/AppJankStats.WIDGET_STATE_SCROLLING,
                /*Widget State*/AppJankStats.WIDGET_STATE_SCROLLING,
                /*Total Frames*/100,
                /*Total Frames*/100,