Skip to content

Commit 09b45a3

Browse files
committed
Add System Tracing capability to Sync Manager
This tracing code is enabled via "systrace.py --set-tags sync" Change-Id: Ia8bc01adbba345a568405b0ac8ade96e56b40cc1
1 parent 4380f95 commit 09b45a3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

core/java/android/content/AbstractThreadedSyncAdapter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.os.IBinder;
2222
import android.os.Process;
2323
import android.os.RemoteException;
24+
import android.os.Trace;
2425

2526
import java.util.HashMap;
2627
import java.util.concurrent.atomic.AtomicInteger;
@@ -233,9 +234,15 @@ private SyncThread(String name, SyncContext syncContext, String authority,
233234
mThreadsKey = toSyncKey(account);
234235
}
235236

237+
@Override
236238
public void run() {
237239
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
238240

241+
// Trace this sync instance. Note, conceptually this should be in
242+
// SyncStorageEngine.insertStartSyncEvent(), but the trace functions require unique
243+
// threads in order to track overlapping operations, so we'll do it here for now.
244+
Trace.traceBegin(Trace.TRACE_TAG_SYNC_MANAGER, mAuthority);
245+
239246
SyncResult syncResult = new SyncResult();
240247
ContentProviderClient provider = null;
241248
try {
@@ -250,6 +257,8 @@ public void run() {
250257
syncResult.databaseError = true;
251258
}
252259
} finally {
260+
Trace.traceEnd(Trace.TRACE_TAG_SYNC_MANAGER);
261+
253262
if (provider != null) {
254263
provider.release();
255264
}

core/java/android/os/Trace.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public final class Trace {
3636
public static final long TRACE_TAG_WEBVIEW = 1L << 4;
3737
public static final long TRACE_TAG_WINDOW_MANAGER = 1L << 5;
3838
public static final long TRACE_TAG_ACTIVITY_MANAGER = 1L << 6;
39+
public static final long TRACE_TAG_SYNC_MANAGER = 1L << 7;
3940

4041
private static final long sEnabledTags = nativeGetEnabledTags();
4142

0 commit comments

Comments
 (0)