ProfilingManager
class ProfilingManager
kotlin.Any | |
↳ | android.os.ProfilingManager |
API for apps to request and listen for app specific profiling.
Summary
Constants | |
---|---|
static Int |
Profiling type for |
static Int |
Profiling type for |
static Int |
Profiling type for |
static Int |
Profiling type for |
Public methods | |
---|---|
Unit |
registerForAllProfilingResults(executor: Executor, listener: Consumer<ProfilingResult!>) Register a listener to be called for all profiling results for this uid. |
Unit |
requestProfiling(profilingType: Int, parameters: Bundle?, tag: String?, cancellationSignal: CancellationSignal?, executor: Executor?, listener: Consumer<ProfilingResult!>?) Request system profiling. |
Unit |
unregisterForAllProfilingResults(listener: Consumer<ProfilingResult!>?) Unregister a listener that was to be called for all profiling results. |
Constants
PROFILING_TYPE_HEAP_PROFILE
static val PROFILING_TYPE_HEAP_PROFILE: Int
Profiling type for requestProfiling
to request a heap profile.
Value: 2
PROFILING_TYPE_JAVA_HEAP_DUMP
static val PROFILING_TYPE_JAVA_HEAP_DUMP: Int
Profiling type for requestProfiling
to request a java heap dump.
Value: 1
PROFILING_TYPE_STACK_SAMPLING
static val PROFILING_TYPE_STACK_SAMPLING: Int
Profiling type for requestProfiling
to request a stack sample.
Value: 3
PROFILING_TYPE_SYSTEM_TRACE
static val PROFILING_TYPE_SYSTEM_TRACE: Int
Profiling type for requestProfiling
to request a system trace.
Value: 4
Public methods
registerForAllProfilingResults
fun registerForAllProfilingResults(
executor: Executor,
listener: Consumer<ProfilingResult!>
): Unit
Register a listener to be called for all profiling results for this uid. Listeners set here will be called in addition to any provided with the request.
Note: If a callback attempt fails (for example, because your app is killed while a trace is in progress) re-delivery may be attempted using a listener added via this method.
Parameters | |
---|---|
executor |
Executor: The executor to call back with. This value cannot be null . |
listener |
Consumer<ProfilingResult!>: Listener to be triggered with result. This value cannot be null . |
requestProfiling
fun requestProfiling(
profilingType: Int,
parameters: Bundle?,
tag: String?,
cancellationSignal: CancellationSignal?,
executor: Executor?,
listener: Consumer<ProfilingResult!>?
): Unit
Request system profiling.
Note: use of this API directly is not recommended for most use cases. Consider using the higher level wrappers provided by AndroidX that will construct the request correctly, supporting available options with simplified request parameters
Both a listener and an executor must be set at the time of the request for the request to be considered for fulfillment. Listener/executor pairs can be set in this method, with registerForAllProfilingResults, or both. The listener and executor must be set together, in the same call. If no listener and executor combination is set, the request will be discarded and no callback will be received.
Requests will be rate limited and are not guaranteed to be filled.
There might be a delay before profiling begins. For continuous profiling types (system tracing, stack sampling, and heap profiling), we recommend starting the collection early and stopping it with cancellationSignal immediately after the area of interest to ensure that the section you want profiled is captured. For heap dumps, we recommend testing locally to ensure that the heap dump is collected at the proper time.
Parameters | |
---|---|
profilingType |
Int: Type of profiling to collect. Value is android.os.ProfilingManager#PROFILING_TYPE_JAVA_HEAP_DUMP , android.os.ProfilingManager#PROFILING_TYPE_HEAP_PROFILE , android.os.ProfilingManager#PROFILING_TYPE_STACK_SAMPLING , or android.os.ProfilingManager#PROFILING_TYPE_SYSTEM_TRACE |
parameters |
Bundle?: Bundle of request related parameters. If the bundle contains any unrecognized parameters, the request will be fail with #ProfilingResult. If the values for the parameters are out of supported range, the closest possible in range value will be chosen. Use of androidx wrappers is recommended over generating this directly. This value may be null . |
tag |
String?: Caller defined data to help identify the output. The first 20 alphanumeric characters, plus dashes, will be lowercased and included in the output filename. This value may be null . |
cancellationSignal |
CancellationSignal?: for caller requested cancellation. Results will be returned if available. If this is null, the requesting app will not be able to stop the collection. The collection will stop after timing out with either the provided configurations or with system defaults |
executor |
Executor?: The executor to call back with. Will only be used for the listener provided in this method. If this is null, and no global executor and listener combinations are registered at the time of the request, the request will be dropped. |
listener |
Consumer<ProfilingResult!>?: Listener to be triggered with result. Any global listeners registered via registerForAllProfilingResults will also be triggered. If this is null, and no global listener and executor combinations are registered at the time of the request, the request will be dropped. |
unregisterForAllProfilingResults
fun unregisterForAllProfilingResults(listener: Consumer<ProfilingResult!>?): Unit
Unregister a listener that was to be called for all profiling results. If no listener is provided, all listeners for this process that were not submitted with a profiling request will be removed.
Parameters | |
---|---|
listener |
Consumer<ProfilingResult!>?: Listener to unregister and no longer be triggered with the results. Null to remove all global listeners for this uid. This value may be null . |