FileDocCategorySizeDatePackage
DropBoxManager.javaAPI DocAndroid 5.1 API13075Thu Mar 12 22:22:10 GMT 2015android.os

DropBoxManager

public class DropBoxManager extends Object
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".

You can obtain an instance of this class by calling {@link android.content.Context#getSystemService} with {@link android.content.Context#DROPBOX_SERVICE}.

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

Fields Summary
private static final String
TAG
private final com.android.internal.os.IDropBoxManagerService
mService
public static final int
IS_EMPTY
Flag value: Entry's content was deleted to save space.
public static final int
IS_TEXT
Flag value: Content is human-readable UTF-8 text (can be combined with IS_GZIPPED).
public static final int
IS_GZIPPED
Flag value: Content can be decompressed with {@link java.util.zip.GZIPOutputStream}.
private static final int
HAS_BYTE_ARRAY
Flag value for serialization only: Value is a byte array, not a file descriptor
public static final String
ACTION_DROPBOX_ENTRY_ADDED
Broadcast Action: This is broadcast when a new entry is added in the dropbox. You must hold the {@link android.Manifest.permission#READ_LOGS} permission in order to receive this broadcast.

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

public static final String
EXTRA_TAG
Extra for {@link android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED}: string containing the dropbox tag.
public static final String
EXTRA_TIME
Extra for {@link 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.
Constructors Summary
public DropBoxManager(com.android.internal.os.IDropBoxManagerService service)
{@hide}

 mService = service; 
protected DropBoxManager()
Create a dummy instance for testing. All methods will fail unless overridden with an appropriate mock implementation. To obtain a functional instance, use {@link android.content.Context#getSystemService}.

 mService = null; 
Methods Summary
public voidaddData(java.lang.String tag, byte[] data, int flags)
Stores binary data, which may be ignored or discarded as with {@link #addText}.

param
tag describing the type of entry being stored
param
data value to store
param
flags describing the data

        if (data == null) throw new NullPointerException("data == null");
        try { mService.add(new Entry(tag, 0, data, flags)); } catch (RemoteException e) {}
    
public voidaddFile(java.lang.String tag, java.io.File file, int flags)
Stores the contents of a file, which may be ignored or discarded as with {@link #addText}.

param
tag describing the type of entry being stored
param
file to read from
param
flags describing the data
throws
IOException if the file can't be opened

        if (file == null) throw new NullPointerException("file == null");
        Entry entry = new Entry(tag, 0, file, flags);
        try {
            mService.add(entry);
        } catch (RemoteException e) {
            // ignore
        } finally {
            entry.close();
        }
    
public voidaddText(java.lang.String tag, java.lang.String data)
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 {@link #isTagEnabled}).

param
tag describing the type of entry being stored
param
data value to store

        try { mService.add(new Entry(tag, 0, data)); } catch (RemoteException e) {}
    
public android.os.DropBoxManager$EntrygetNextEntry(java.lang.String tag, long msec)
Gets the next entry from the drop box after the specified time. Requires android.permission.READ_LOGS. You must always call {@link Entry#close()} on the return value!

param
tag of entry to look for, null for all tags
param
msec time of the last entry seen
return
the next entry, or null if there are no more entries

        try { return mService.getNextEntry(tag, msec); } catch (RemoteException e) { return null; }
    
public booleanisTagEnabled(java.lang.String tag)
Checks any blacklists (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.

param
tag that would be used in {@link #addText} or {@link #addFile}
return
whether events with that tag would be accepted

        try { return mService.isTagEnabled(tag); } catch (RemoteException e) { return false; }