BugreportManager


public final class BugreportManager
extends Object

java.lang.Object
   ↳ android.os.BugreportManager


Class that provides a privileged API to capture and consume bugreports.

This class may only be used by apps that currently have carrier privileges (see TelephonyManager.hasCarrierPrivileges()) on an active SIM or priv-apps explicitly allowed by the device manufacturer.

Only one bugreport can be generated by the system at a time.

Summary

Nested classes

class BugreportManager.BugreportCallback

An interface describing the callback for bugreport progress and status. 

Public methods

void cancelBugreport()

Cancels the currently running bugreport.

void startConnectivityBugreport(ParcelFileDescriptor bugreportFd, Executor executor, BugreportManager.BugreportCallback callback)

Starts a connectivity bugreport.

Inherited methods

Public methods

cancelBugreport

Added in API level 31
public void cancelBugreport ()

Cancels the currently running bugreport.

Apps are only able to cancel their own bugreports. App A cannot cancel a bugreport started by app B.

Requires permission: Manifest.permission.DUMP or that the calling app has carrier privileges (see TelephonyManager.hasCarrierPrivileges()) on any active subscription.
This method may take several seconds to complete, so it should only be called from a worker thread.

Throws
SecurityException if trying to cancel another app's bugreport in progress

startConnectivityBugreport

Added in API level 31
public void startConnectivityBugreport (ParcelFileDescriptor bugreportFd, 
                Executor executor, 
                BugreportManager.BugreportCallback callback)

Starts a connectivity bugreport.

The connectivity bugreport is a specialized version of bugreport that only includes information specifically for debugging connectivity-related issues (e.g. telephony, wi-fi, and IP networking issues). It is intended primarily for use by OEMs and network providers such as mobile network operators. In addition to generally excluding information that isn't targeted to connectivity debugging, this type of bugreport excludes PII and sensitive information that isn't strictly necessary for connectivity debugging.

The calling app MUST have a context-specific reason for requesting a connectivity bugreport, such as detecting a connectivity-related issue. This API SHALL NOT be used to perform random sampling from a fleet of public end-user devices.

Calling this API will cause the system to ask the user for consent every single time. The bugreport artifacts will be copied over to the given file descriptors only if the user consents to sharing with the calling app.

This starts a bugreport in the background. However the call itself can take several seconds to return in the worst case. callback will receive progress and status updates.

Requires that the calling app has carrier privileges (see TelephonyManager.hasCarrierPrivileges()) on any active subscription.
This method may take several seconds to complete, so it should only be called from a worker thread.

Parameters
bugreportFd ParcelFileDescriptor: file to write the bugreport. This should be opened in write-only, append mode. This value cannot be null.

executor Executor: This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

callback BugreportManager.BugreportCallback: callback for progress and status updates. This value cannot be null.