Skip to content

Commit e0e00fc

Browse files
committed
Deprecate all SafeTrace/SafeTraceFunctions APIs
1 parent 71e3b87 commit e0e00fc

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

papa-safetrace/src/main/java/papa/SafeTrace.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ object SafeTrace {
5454

5555
@Deprecated("Use forceShellProfileable instead", ReplaceWith("forceShellProfileable()"))
5656
@JvmStatic
57+
@Suppress("DEPRECATION")
5758
fun forceTraceable() = forceShellProfileable()
5859

5960
/**
6061
* @see isShellProfileable
6162
*/
63+
@Deprecated("Call forceEnableAppTracing/enableMainThreadMessageTracing instead")
6264
@JvmStatic
6365
fun forceShellProfileable() {
6466
androidx.tracing.Trace.forceEnableAppTracing()
@@ -93,6 +95,7 @@ object SafeTrace {
9395
* Writes a trace message to indicate that a given section of code has begun. This call must
9496
* be followed by a corresponding call to {@link #endSection()} on the same thread.
9597
*/
98+
@Deprecated("Call androidx.tracing.Trace.beginSection instead", ReplaceWith("beginSection", "androidx.tracing.Trace.beginSection"))
9699
@JvmStatic
97100
fun beginSection(label: String) {
98101
if (!isCurrentlyTracing) {
@@ -101,6 +104,7 @@ object SafeTrace {
101104
androidx.tracing.Trace.beginSection(label.take(MAX_LABEL_LENGTH))
102105
}
103106

107+
@Deprecated("Call androidx.tracing.Trace.beginSection instead", ReplaceWith("beginSection", "androidx.tracing.Trace.beginSection"))
104108
@JvmStatic
105109
inline fun beginSection(crossinline labelLambda: () -> String) {
106110
if (!isCurrentlyTracing) {
@@ -113,6 +117,7 @@ object SafeTrace {
113117
* Begins and ends a section immediately. Useful for reporting information in the trace.
114118
*/
115119
@JvmStatic
120+
@Deprecated("Call androidx.tracing.Trace.beginSection/endSection instead")
116121
fun logSection(label: String) {
117122
if (!isCurrentlyTracing) {
118123
return
@@ -124,6 +129,7 @@ object SafeTrace {
124129
/**
125130
* @see [logSection]
126131
*/
132+
@Deprecated("Call androidx.tracing.Trace.beginSection/endSection instead")
127133
@JvmStatic
128134
inline fun logSection(crossinline labelLambda: () -> String) {
129135
if (!isCurrentlyTracing) {
@@ -141,6 +147,7 @@ object SafeTrace {
141147
* ensure that beginSection / endSection pairs are properly nested and called from the same
142148
* thread.
143149
*/
150+
@Deprecated("Call androidx.tracing.Trace.endSection instead", ReplaceWith("endSection", "androidx.tracing.Trace.endSection"))
144151
@JvmStatic
145152
fun endSection() {
146153
if (!isCurrentlyTracing) {
@@ -152,6 +159,7 @@ object SafeTrace {
152159
/**
153160
* @see androidx.tracing.Trace.beginAsyncSection
154161
*/
162+
@Deprecated("Call androidx.tracing.Trace.beginAsyncSection instead", ReplaceWith("beginAsyncSection", "androidx.tracing.Trace.beginAsyncSection"))
155163
@JvmStatic
156164
inline fun beginAsyncSection(
157165
crossinline labelCookiePairLambda: () -> Pair<String, Int>
@@ -167,6 +175,7 @@ object SafeTrace {
167175
* [cookie] defaults to 0 (cookie is used for async traces that overlap)
168176
* @see androidx.tracing.Trace.beginAsyncSection
169177
*/
178+
@Deprecated("Call androidx.tracing.Trace.beginAsyncSection instead", ReplaceWith("beginAsyncSection", "androidx.tracing.Trace.beginAsyncSection"))
170179
@JvmStatic
171180
fun beginAsyncSection(
172181
label: String,
@@ -182,6 +191,7 @@ object SafeTrace {
182191
* [cookie] defaults to 0 (cookie is used for async traces that overlap)
183192
* @see androidx.tracing.Trace.endAsyncSection
184193
*/
194+
@Deprecated("Call androidx.tracing.Trace.endAsyncSection instead", ReplaceWith("endAsyncSection", "androidx.tracing.Trace.endAsyncSection"))
185195
@JvmStatic
186196
fun endAsyncSection(
187197
label: String,
@@ -196,6 +206,7 @@ object SafeTrace {
196206
/**
197207
* @see androidx.tracing.Trace.beginAsyncSection
198208
*/
209+
@Deprecated("Call androidx.tracing.Trace.endAsyncSection instead", ReplaceWith("endAsyncSection", "androidx.tracing.Trace.endAsyncSection"))
199210
@JvmStatic
200211
inline fun endAsyncSection(
201212
crossinline labelCookiePairLambda: () -> Pair<String, Int>

papa-safetrace/src/main/java/papa/SafeTraceFunctions.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import papa.SafeTrace.isTraceable
88
* [label] a string producing lambda if the label is computed dynamically. If the label isn't
99
* dynamic, use the [safeTrace] which directly takes a string instead.
1010
*/
11+
@Deprecated("Call androidx.tracing.trace instead", ReplaceWith("trace", "androidx.tracing.trace"))
12+
@Suppress("DEPRECATION")
1113
inline fun <T> safeTrace(
1214
crossinline label: () -> String,
1315
crossinline block: () -> T
@@ -26,6 +28,8 @@ inline fun <T> safeTrace(
2628
/**
2729
* Allows tracing of a block of code
2830
*/
31+
@Deprecated("Call androidx.tracing.trace instead", ReplaceWith("trace", "androidx.tracing.trace"))
32+
@Suppress("DEPRECATION")
2933
inline fun <T> safeTrace(
3034
label: String,
3135
crossinline block: () -> T

papa-safetrace/src/main/java/papa/SafeTraceSetup.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ object SafeTraceSetup {
1313

1414
fun init(application: Application) {
1515
this.application = application
16+
enableMainThreadMessageTracing()
17+
}
18+
19+
fun enableMainThreadMessageTracing() {
1620
SafeTraceMainThreadMessages.enableMainThreadMessageTracing()
1721
}
1822

papa-safetrace/src/main/java/papa/internal/SafeTraceMainThreadMessages.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ internal object SafeTraceMainThreadMessages {
3232
}
3333
}
3434

35+
@Suppress("DEPRECATION")
3536
private fun enableOnMainThread() {
3637
if (!enabled && SafeTrace.isShellProfileable && traceMainThreadMessages) {
3738
enabled = true

0 commit comments

Comments
 (0)