public final class PerfettoHandshake


Handshake implementation allowing to enable Perfetto SDK tracing in an app that enables it.

Summary

Public constructors

PerfettoHandshake(
    @NonNull String targetPackage,
    @NonNull Function1<@NonNull String, @NonNull Map<@NonNull String, @NonNull String>> parseJsonMap,
    @NonNull Function1<@NonNull String, @NonNull String> executeShellCommand
)

Public methods

final @NonNull PerfettoHandshake.EnableTracingResponse

Requests that tracing is enabled in the target app.

Public constructors

PerfettoHandshake

public PerfettoHandshake(
    @NonNull String targetPackage,
    @NonNull Function1<@NonNull String, @NonNull Map<@NonNull String, @NonNull String>> parseJsonMap,
    @NonNull Function1<@NonNull String, @NonNull String> executeShellCommand
)
Parameters
@NonNull String targetPackage

package name of the target app

@NonNull Function1<@NonNull String, @NonNull Map<@NonNull String, @NonNull String>> parseJsonMap

function parsing a flat map in a JSON format into a Map<String, String> e.g. "{ 'key 1': 'value 1', 'key 2': 'value 2' }" ->mapOf("key 1" to "value 1", "key 2" to "value 2")

@NonNull Function1<@NonNull String, @NonNull String> executeShellCommand

function allowing to execute adb shell commands on the target device

For error handling, note that parseJsonMap and executeShellCommand will be called on the same thread as enableTracing.

Public methods

enableTracing

public final @NonNull PerfettoHandshake.EnableTracingResponse enableTracing(
    PerfettoHandshake.ExternalLibraryProvider libraryProvider
)

Requests that tracing is enabled in the target app.

Parameters
PerfettoHandshake.ExternalLibraryProvider libraryProvider

optional provider of Perfetto SDK binaries allowing to sideload them if not already present in the target app