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

Commit cc183884 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Baseline `Trace` support for SysUI." into main

parents 7117f89a 4ac4aa96
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import dalvik.annotation.optimization.FastNative;
 * href="{@docRoot}tools/debugging/systrace.html">Analyzing Display and Performance
 * with Systrace</a>.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class Trace {
    /*
     * Writes trace events to the kernel trace buffer.  These trace events can be
@@ -123,10 +124,26 @@ public final class Trace {

    @UnsupportedAppUsage
    @CriticalNative
    @android.ravenwood.annotation.RavenwoodReplace
    private static native long nativeGetEnabledTags();
    @android.ravenwood.annotation.RavenwoodReplace
    private static native void nativeSetAppTracingAllowed(boolean allowed);
    @android.ravenwood.annotation.RavenwoodReplace
    private static native void nativeSetTracingEnabled(boolean allowed);

    private static long nativeGetEnabledTags$ravenwood() {
        // Tracing currently completely disabled under Ravenwood
        return 0;
    }

    private static void nativeSetAppTracingAllowed$ravenwood(boolean allowed) {
        // Tracing currently completely disabled under Ravenwood
    }

    private static void nativeSetTracingEnabled$ravenwood(boolean allowed) {
        // Tracing currently completely disabled under Ravenwood
    }

    @FastNative
    private static native void nativeTraceCounter(long tag, String name, long value);
    @FastNative
+47 −1
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import org.junit.runner.RunWith;
 * while tracing on the emulator and then run traceview to view the trace.
 */
@RunWith(AndroidJUnit4.class)
@IgnoreUnderRavenwood(blockedBy = Trace.class)
public class TraceTest {
    private static final String TAG = "TraceTest";

@@ -45,8 +44,52 @@ public class TraceTest {
    private int fMethodCalls = 0;
    private int gMethodCalls = 0;

    @Test
    public void testEnableDisable() {
        // Currently only verifying that we can invoke without crashing
        Trace.setTracingEnabled(true, 0);
        Trace.setTracingEnabled(false, 0);

        Trace.setAppTracingAllowed(true);
        Trace.setAppTracingAllowed(false);
    }

    @Test
    public void testBeginEnd() {
        // Currently only verifying that we can invoke without crashing
        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG);
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG, 42);
        Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG, 42);

        Trace.asyncTraceForTrackBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG, TAG, 42);
        Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG, 42);

        Trace.beginSection(TAG);
        Trace.endSection();

        Trace.beginAsyncSection(TAG, 42);
        Trace.endAsyncSection(TAG, 42);
    }

    @Test
    public void testCounter() {
        // Currently only verifying that we can invoke without crashing
        Trace.traceCounter(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG, 42);
        Trace.setCounter(TAG, 42);
    }

    @Test
    public void testInstant() {
        // Currently only verifying that we can invoke without crashing
        Trace.instant(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG);
        Trace.instantForTrack(Trace.TRACE_TAG_ACTIVITY_MANAGER, TAG, TAG);
    }

    @Test
    public void testNullStrings() {
        // Currently only verifying that we can invoke without crashing
        Trace.traceCounter(Trace.TRACE_TAG_ACTIVITY_MANAGER, null, 42);
        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, null);

@@ -62,6 +105,7 @@ public class TraceTest {

    @Test
    @SmallTest
    @IgnoreUnderRavenwood(blockedBy = Debug.class)
    public void testNativeTracingFromJava()
    {
        long start = System.currentTimeMillis();
@@ -82,6 +126,7 @@ public class TraceTest {
    
    // This should not run in the automated suite.
    @Suppress
    @IgnoreUnderRavenwood(blockedBy = Debug.class)
    public void disableTestNativeTracingFromC()
    {
        long start = System.currentTimeMillis();
@@ -97,6 +142,7 @@ public class TraceTest {
    @Test
    @LargeTest
    @Suppress  // Failing.
    @IgnoreUnderRavenwood(blockedBy = Debug.class)
    public void testMethodTracing()
    {
        long start = System.currentTimeMillis();
+1 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ android.os.SystemClock
android.os.SystemProperties
android.os.ThreadLocalWorkSource
android.os.TimestampedValue
android.os.Trace
android.os.UidBatteryConsumer
android.os.UidBatteryConsumer$Builder
android.os.UserHandle