Skip to content
Snippets Groups Projects
Commit 4ac4aa96 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Baseline `Trace` support for SysUI.

SysUI code relies on the tracing APIs, which are often used for
investigating performance-sensitive operations on physical devices.

As this tracing information is less useful under the Ravenwood
environment, we offer a baseline no-op implementation to support
existing code.  (There are no APIs to "read back" tracing
information for a test to inspect, which is another reason it's
okay to no-op for now.)

Bug: 319647875
Test: atest FrameworksCoreTestsRavenwood
Change-Id: I52865d7da4c38d350edc7e9dc0239fc1b130048d
parent ff93fc40
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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();
......
......@@ -67,6 +67,7 @@ android.os.ServiceSpecificException
android.os.SystemClock
android.os.ThreadLocalWorkSource
android.os.TimestampedValue
android.os.Trace
android.os.UidBatteryConsumer
android.os.UidBatteryConsumer$Builder
android.os.UserHandle
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment