FileDocCategorySizeDatePackage
ClientData.javaAPI DocAndroid 1.5 API16129Wed May 06 22:41:08 BST 2009com.android.ddmlib

ClientData

public class ClientData extends Object
Contains the data of a {@link Client}.

Fields Summary
private static final String
PRE_INITIALIZED
Temporary name of VM to be ignored.
public static final int
DEBUGGER_DEFAULT
Debugger connection status: not waiting on one, not connected to one, but accepting new connections. This is the default value.
public static final int
DEBUGGER_WAITING
Debugger connection status: the application's VM is paused, waiting for a debugger to connect to it before resuming.
public static final int
DEBUGGER_ATTACHED
Debugger connection status : Debugger is connected
public static final int
DEBUGGER_ERROR
Debugger connection status: The listening port for debugger connection failed to listen. No debugger will be able to connect.
public static final int
ALLOCATION_TRACKING_UNKNOWN
Allocation tracking status: unknown.

This happens right after a {@link Client} is discovered by the {@link AndroidDebugBridge}, and before the {@link Client} answered the query regarding its allocation tracking status.

public static final int
ALLOCATION_TRACKING_OFF
Allocation tracking status: the {@link Client} is not tracking allocations.
public static final int
ALLOCATION_TRACKING_ON
Allocation tracking status: the {@link Client} is tracking allocations.
public static final String
HEAP_MAX_SIZE_BYTES
Name of the value representing the max size of the heap, in the {@link Map} returned by {@link #getVmHeapInfo(int)}
public static final String
HEAP_SIZE_BYTES
Name of the value representing the size of the heap, in the {@link Map} returned by {@link #getVmHeapInfo(int)}
public static final String
HEAP_BYTES_ALLOCATED
Name of the value representing the number of allocated bytes of the heap, in the {@link Map} returned by {@link #getVmHeapInfo(int)}
public static final String
HEAP_OBJECTS_ALLOCATED
Name of the value representing the number of objects in the heap, in the {@link Map} returned by {@link #getVmHeapInfo(int)}
private boolean
mIsDdmAware
private final int
mPid
private String
mVmIdentifier
private String
mClientDescription
private int
mDebuggerInterest
private TreeMap
mThreadMap
private final HeapData
mHeapData
VM Heap data
private final HeapData
mNativeHeapData
Native Heap data
private HashMap
mHeapInfoMap
private ArrayList
mNativeLibMapInfo
library map info. Stored here since the backtrace data is computed on a need to display basis.
private ArrayList
mNativeAllocationList
Native Alloc info list
private int
mNativeTotalMemory
private AllocationInfo[]
mAllocations
private int
mAllocationStatus
Constructors Summary
ClientData(int pid)
Generic constructor.

        mPid = pid;

        mDebuggerInterest = DEBUGGER_DEFAULT;
        mThreadMap = new TreeMap<Integer,ThreadInfo>();
    
Methods Summary
synchronized voidaddNativeAllocation(NativeAllocationInfo allocInfo)
adds a new {@link NativeAllocationInfo} to the {@link Client}

param
allocInfo The {@link NativeAllocationInfo} to add.

        mNativeAllocationList.add(allocInfo);
    
synchronized voidaddNativeLibraryMapInfo(long startAddr, long endAddr, java.lang.String library)

        mNativeLibMapInfo.add(new NativeLibraryMapInfo(startAddr, endAddr, library));
    
synchronized voidaddThread(int threadId, java.lang.String threadName)
Adds a new thread to the list.

        ThreadInfo attr = new ThreadInfo(threadId, threadName);
        mThreadMap.put(threadId, attr);
    
synchronized voidclearNativeAllocationInfo()
Clear the current malloc info.

        mNativeAllocationList.clear();
    
synchronized voidclearThreads()

        mThreadMap.clear();
    
public synchronized intgetAllocationStatus()
Returns the allocation tracking status.

see
Client#requestAllocationStatus()

        return mAllocationStatus;
    
public synchronized AllocationInfo[]getAllocations()
Returns the list of tracked allocations.

see
Client#requestAllocationDetails()

        return mAllocations;
    
public java.lang.StringgetClientDescription()
Returns the client description.

This is generally the name of the package defined in the AndroidManifest.xml.

return
the client description or null if not the description was not yet sent by the client.

        return mClientDescription;
    
public intgetDebuggerConnectionStatus()
Returns the debugger connection status. Possible values are {@link #DEBUGGER_DEFAULT}, {@link #DEBUGGER_WAITING}, {@link #DEBUGGER_ATTACHED}, and {@link #DEBUGGER_ERROR}.

        return mDebuggerInterest;
    
public synchronized java.util.ListgetNativeAllocationList()
Returns the list of {@link NativeAllocationInfo}.

see
Client#requestNativeHeapInformation()

        return Collections.unmodifiableList(mNativeAllocationList);
    
com.android.ddmlib.ClientData$HeapDatagetNativeHeapData()
Returns the {@link HeapData} object for the native code.

        return mNativeHeapData;
    
public synchronized java.util.IteratorgetNativeLibraryMapInfo()
Returns an {@link Iterator} on {@link NativeLibraryMapInfo} objects.

The caller must synchronize on the {@link ClientData} object while iterating.

        return mNativeLibMapInfo.iterator();
    
public intgetPid()
Returns the process ID.

        return mPid;
    
synchronized ThreadInfogetThread(int threadId)
Returns the {@link ThreadInfo} by thread id.

        return mThreadMap.get(threadId);
    
public synchronized ThreadInfo[]getThreads()
Returns the list of threads as {@link ThreadInfo} objects.

The list is empty until a thread update was requested with {@link Client#requestThreadUpdate()}.

        Collection<ThreadInfo> threads = mThreadMap.values();
        return threads.toArray(new ThreadInfo[threads.size()]);
    
public synchronized intgetTotalNativeMemory()
Returns the total native memory.

see
Client#requestNativeHeapInformation()

        return mNativeTotalMemory;
    
public com.android.ddmlib.ClientData$HeapDatagetVmHeapData()
Returns the {@link HeapData} object for the VM.

        return mHeapData;
    
public synchronized java.util.IteratorgetVmHeapIds()
Returns an iterator over the list of known VM heap ids.

The caller must synchronize on the {@link ClientData} object while iterating.

return
an iterator over the list of heap ids

        return mHeapInfoMap.keySet().iterator();
    
public synchronized java.util.MapgetVmHeapInfo(int heapId)
Returns the most-recent info values for the specified VM heap.

param
heapId The heap whose info should be returned
return
a map containing the info values for the specified heap. Returns null if the heap ID is unknown.

        return mHeapInfoMap.get(heapId);
    
public java.lang.StringgetVmIdentifier()
Returns the Client's VM identifier.

        return mVmIdentifier;
    
public booleanisDdmAware()
Returns whether the process is DDM-aware.

        return mIsDdmAware;
    
voidisDdmAware(boolean aware)
Sets DDM-aware status.

        mIsDdmAware = aware;
    
synchronized voidremoveThread(int threadId)
Removes a thread from the list.

        mThreadMap.remove(threadId);
    
synchronized voidsetAllocationStatus(boolean enabled)

        mAllocationStatus = enabled ? ALLOCATION_TRACKING_ON : ALLOCATION_TRACKING_OFF;
    
synchronized voidsetAllocations(AllocationInfo[] allocs)

        mAllocations = allocs;
    
voidsetClientDescription(java.lang.String description)
Sets client description. There may be a race between HELO and APNM. Rather than try to enforce ordering on the device, we just don't allow an empty name to replace a specified one.

        if (mClientDescription == null && description.length() > 0) {
            /*
             * The application VM is first named <pre-initialized> before being assigned
             * its real name.
             * Depending on the timing, we can get an APNM chunk setting this name before
             * another one setting the final actual name. So if we get a SetClientDescription
             * with this value we ignore it.
             */
            if (PRE_INITIALIZED.equals(description) == false) {
                mClientDescription = description;
            }
        }
    
voidsetDebuggerConnectionStatus(int val)
Sets debugger connection status.

        mDebuggerInterest = val;
    
synchronized voidsetHeapInfo(int heapId, long maxSizeInBytes, long sizeInBytes, long bytesAllocated, long objectsAllocated)
Sets the current heap info values for the specified heap.

param
heapId The heap whose info to update
param
sizeInBytes The size of the heap, in bytes
param
bytesAllocated The number of bytes currently allocated in the heap
param
objectsAllocated The number of objects currently allocated in the heap

        HashMap<String, Long> heapInfo = new HashMap<String, Long>();
        heapInfo.put(HEAP_MAX_SIZE_BYTES, maxSizeInBytes);
        heapInfo.put(HEAP_SIZE_BYTES, sizeInBytes);
        heapInfo.put(HEAP_BYTES_ALLOCATED, bytesAllocated);
        heapInfo.put(HEAP_OBJECTS_ALLOCATED, objectsAllocated);
        mHeapInfoMap.put(heapId, heapInfo);
    
synchronized voidsetTotalNativeMemory(int totalMemory)

        mNativeTotalMemory = totalMemory;
    
voidsetVmIdentifier(java.lang.String ident)
Sets VM identifier.

        mVmIdentifier = ident;