Skip to content

For android, replace the usage of Thread.id with the compat method #1345

@atulgpt

Description

@atulgpt

In AnrWatcher, CrashReporter, CrashReportIntegrationTest & PeriodicWorkTest we are using the Thread.getId() which is deprecated.

I suggest to make a utility function in common module of the sdk in the package io.opentelemetry.android.common.internal.utils

package io.opentelemetry.android.common.internal.utils

import android.os.Build

inline val Thread.threadIdCompat: Long
    get() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) {
            threadId()
        } else {
            @Suppress("DEPRECATION")
            id
        }

and then replace all the usages in the above mentioned files

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions