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

Commit 59c660c4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix Possible Stack Overflow" into main

parents cdac0a83 364ad3e6
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -34463,7 +34463,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    @FlaggedApi(android.app.jank.Flags.FLAG_DETAILED_APP_JANK_METRICS_API)
    public void reportAppJankStats(@NonNull AppJankStats appJankStats) {
        getRootView().reportAppJankStats(appJankStats);
        View rootView = getRootView();
        if (rootView == this) return;
        rootView.reportAppJankStats(appJankStats);
    }
    /**
@@ -34471,6 +34474,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @hide
     */
    public @Nullable JankTracker getJankTracker() {
        return getRootView().getJankTracker();
        View rootView = getRootView();
        if (rootView == this) {
            return null;
        }
        return rootView.getJankTracker();
    }
}
+14 −2
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ package android.app.jank.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import android.app.jank.Flags;
import android.app.jank.JankTracker;
import android.app.jank.StateTracker;
import android.content.Context;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -55,10 +57,9 @@ public class JankTrackerTest {
     * Start an empty activity so decore view is not null when creating the JankTracker instance.
     */
    private static ActivityScenario<EmptyActivity> sEmptyActivityRule;

    private static String sActivityName;

    private static View sActivityDecorView;
    private static Context sContext;

    @BeforeClass
    public static void classSetup() {
@@ -66,6 +67,7 @@ public class JankTrackerTest {
        sEmptyActivityRule.onActivity(activity -> {
            sActivityDecorView = activity.getWindow().getDecorView();
            sActivityName = activity.toString();
            sContext = activity.getApplicationContext();
        });
    }

@@ -168,4 +170,14 @@ public class JankTrackerTest {

        assertNotNull(jankTracker);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_DETAILED_APP_JANK_METRICS_API)
    public void jankTracker_IsNull_WhenViewNotInHierarchy() {
        TestWidget testWidget = new TestWidget(sContext);
        JankTracker jankTracker = testWidget.getJankTracker();

        assertNull(jankTracker);
    }

}