Added in API level 8

DropBoxManager


open class DropBoxManager
kotlin.Any
   ↳ android.os.DropBoxManager

Enqueues chunks of data (from various sources -- application crashes, kernel log records, etc.). The queue is size bounded and will drop old data if the enqueued data exceeds the maximum size. You can think of this as a persistent, system-wide, blob-oriented "logcat".

DropBoxManager entries are not sent anywhere directly, but other system services and debugging tools may scan and upload entries for processing.

Summary

Nested classes
open

A single entry retrieved from the drop box.

Constants
static String

Broadcast Action: This is broadcast when a new entry is added in the dropbox.

static String

Extra for android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED: integer value containing number of broadcasts dropped due to rate limiting on this android.os.DropBoxManager#EXTRA_TAG

static String

Extra for android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED: string containing the dropbox tag.

static String

Extra for android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED: long integer value containing time (in milliseconds since January 1, 1970 00:00:00 UTC) when the entry was created.

static Int

Flag value: Entry's content was deleted to save space.

static Int

Flag value: Content can be decompressed with java.

static Int

Flag value: Content is human-readable UTF-8 text (can be combined with IS_GZIPPED).

Protected constructors

Create an instance for testing.

Public methods
open Unit
addData(tag: String, data: ByteArray?, flags: Int)

Stores binary data, which may be ignored or discarded as with addText.

open Unit
addFile(tag: String, file: File, flags: Int)

Stores the contents of a file, which may be ignored or discarded as with addText.

open Unit
addText(tag: String, data: String)

Stores human-readable text.

open DropBoxManager.Entry?
getNextEntry(tag: String!, msec: Long)

Gets the next entry from the drop box after the specified time.

open Boolean

Checks any denylists (set in system settings) to see whether a certain tag is allowed.

Constants

ACTION_DROPBOX_ENTRY_ADDED

Added in API level 11
static val ACTION_DROPBOX_ENTRY_ADDED: String

Broadcast Action: This is broadcast when a new entry is added in the dropbox. For apps targeting 35 and later, For apps targeting Android versions lower than 35, you must hold android.Manifest.permission#READ_LOGS. This broadcast can be rate limited for low priority entries

This is a protected intent that can only be sent by the system.

Value: "android.intent.action.DROPBOX_ENTRY_ADDED"

EXTRA_DROPPED_COUNT

Added in API level 29
static val EXTRA_DROPPED_COUNT: String

Extra for android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED: integer value containing number of broadcasts dropped due to rate limiting on this android.os.DropBoxManager#EXTRA_TAG

Value: "android.os.extra.DROPPED_COUNT"

EXTRA_TAG

Added in API level 11
static val EXTRA_TAG: String

Extra for android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED: string containing the dropbox tag.

Value: "tag"

EXTRA_TIME

Added in API level 11
static val EXTRA_TIME: String

Extra for android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED: long integer value containing time (in milliseconds since January 1, 1970 00:00:00 UTC) when the entry was created.

Value: "time"

IS_EMPTY

Added in API level 8
static val IS_EMPTY: Int

Flag value: Entry's content was deleted to save space.

Value: 1

IS_GZIPPED

Added in API level 8
static val IS_GZIPPED: Int

Flag value: Content can be decompressed with java.util.zip.GZIPOutputStream.

Value: 4

IS_TEXT

Added in API level 8
static val IS_TEXT: Int

Flag value: Content is human-readable UTF-8 text (can be combined with IS_GZIPPED).

Value: 2

Protected constructors

DropBoxManager

Added in API level 8
protected DropBoxManager()

Create an instance for testing. All methods will fail unless overridden with an appropriate mock implementation. To obtain a functional instance, use android.content.Context#getSystemService.

Public methods

addData

Added in API level 8
open fun addData(
    tag: String,
    data: ByteArray?,
    flags: Int
): Unit

Stores binary data, which may be ignored or discarded as with addText.

Parameters
tag String: describing the type of entry being stored This value cannot be null.
data ByteArray?: value to store This value may be null.
flags Int: describing the data Value is either 0 or a combination of android.os.DropBoxManager#IS_EMPTY, android.os.DropBoxManager#IS_TEXT, and android.os.DropBoxManager#IS_GZIPPED

addFile

Added in API level 8
open fun addFile(
    tag: String,
    file: File,
    flags: Int
): Unit

Stores the contents of a file, which may be ignored or discarded as with addText.

Parameters
tag String: describing the type of entry being stored This value cannot be null.
file File: to read from This value cannot be null.
flags Int: describing the data Value is either 0 or a combination of android.os.DropBoxManager#IS_EMPTY, android.os.DropBoxManager#IS_TEXT, and android.os.DropBoxManager#IS_GZIPPED
Exceptions
java.io.IOException if the file can't be opened

addText

Added in API level 8
open fun addText(
    tag: String,
    data: String
): Unit

Stores human-readable text. The data may be discarded eventually (or even immediately) if space is limited, or ignored entirely if the tag has been blocked (see isTagEnabled).

Parameters
tag String: describing the type of entry being stored This value cannot be null.
data String: value to store This value cannot be null.

getNextEntry

Added in API level 8
open fun getNextEntry(
    tag: String!,
    msec: Long
): DropBoxManager.Entry?

Gets the next entry from the drop box after the specified time. You must always call android.os.DropBoxManager.Entry#close() on the return value! android.Manifest.permission#READ_LOGS permission is required for apps targeting Android versions lower than 35.
Requires android.Manifest.permission#READ_DROPBOX_DATA and android.Manifest.permission#PACKAGE_USAGE_STATS

Parameters
tag String!: of entry to look for, null for all tags
msec Long: time of the last entry seen
Return
DropBoxManager.Entry? the next entry, or null if there are no more entries

isTagEnabled

Added in API level 8
open fun isTagEnabled(tag: String!): Boolean

Checks any denylists (set in system settings) to see whether a certain tag is allowed. Entries with disabled tags will be dropped immediately, so you can save the work of actually constructing and sending the data.

Parameters
tag String!: that would be used in addText or addFile
Return
Boolean whether events with that tag would be accepted