Skip to content

Commit 69d3761

Browse files
committed
update kotlin snippet for handling callback
1 parent ba926c6 commit 69d3761

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

misc/src/main/java/com/example/snippets/profiling/ProfilingManagerKotlinSnippets.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,36 @@ class ProfilingManagerKotlinSnippets {
106106

107107
val resultCallback = Consumer<ProfilingResult> { profilingResult ->
108108
if (profilingResult.errorCode == ProfilingResult.ERROR_NONE) {
109-
Log.d(TAG, "Received profiling result. file: ${profilingResult.resultFilePath}")
109+
Log.d(
110+
"ProfileTest",
111+
"Received profiling result file=" + profilingResult.resultFilePath
112+
)
113+
setupUploadJob(profilingResult.resultFilePath)
114+
} else {
115+
Log.e(
116+
"ProfileTest",
117+
"Profiling failed errorcode=" + profilingResult.errorCode + " errormsg=" + profilingResult.errorMessage
118+
)
110119
}
111120
}
112121

113122
profilingManager.registerForAllProfilingResults(mainExecutor, resultCallback)
114123
profilingManager.addProfilingTriggers(triggers)
115124

125+
// [START_EXCLUDE silent]
116126
Choreographer.getInstance().postFrameCallback { frameTimeNanos ->
117127
// This will cause the TRIGGER_TYPE_APP_FULLY_DRAWN to be emitted.
118128
reportFullyDrawn()
119129
}
130+
// [END_EXCLUDE silent]
120131
}
121132
// [END android_profiling_manager_triggered_trace]
133+
134+
// [START android_profiling_manager_triggered_trace_setup_upload_job]
135+
fun setupUploadJob(resultFilePath: String?) {
136+
// Setup job to upload the profiling result file.
137+
}
138+
// [END android_profiling_manager_triggered_trace_setup_upload_job]
139+
122140
}
123141
}

0 commit comments

Comments
 (0)