|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.android.ddmlib.AndroidDebugBridge
public final class AndroidDebugBridge
A connection to the host-side android debug bridge (adb)
This is the central point to communicate with any devices, emulators, or the applications running on them.init(boolean)
must be called before anything is done.
Nested Class Summary | |
---|---|
static interface |
AndroidDebugBridge.IClientChangeListener
Classes which implement this interface provide methods that deal with Client changes. |
static interface |
AndroidDebugBridge.IDebugBridgeChangeListener
Classes which implement this interface provide a method that deals with AndroidDebugBridge changes. |
static interface |
AndroidDebugBridge.IDeviceChangeListener
Classes which implement this interface provide methods that deal with IDevice addition, deletion, and changes. |
Method Summary | |
---|---|
static void |
addClientChangeListener(AndroidDebugBridge.IClientChangeListener listener)
Adds the listener to the collection of listeners who will be notified when a Client
property changed, by sending it one of the messages defined in the
AndroidDebugBridge.IClientChangeListener interface. |
static void |
addDebugBridgeChangeListener(AndroidDebugBridge.IDebugBridgeChangeListener listener)
Adds the listener to the collection of listeners who will be notified when a new AndroidDebugBridge is connected, by sending it one of the messages defined
in the AndroidDebugBridge.IDebugBridgeChangeListener interface. |
static void |
addDeviceChangeListener(AndroidDebugBridge.IDeviceChangeListener listener)
Adds the listener to the collection of listeners who will be notified when a IDevice
is connected, disconnected, or when its properties or its Client list changed,
by sending it one of the messages defined in the AndroidDebugBridge.IDeviceChangeListener interface. |
static AndroidDebugBridge |
createBridge()
Creates a AndroidDebugBridge that is not linked to any particular executable. |
static AndroidDebugBridge |
createBridge(java.lang.String osLocation,
boolean forceNewBridge)
Creates a new debug bridge from the location of the command line tool. |
static void |
disconnectBridge()
Disconnects the current debug bridge, and destroy the object. |
static AndroidDebugBridge |
getBridge()
Returns the current debug bridge. |
int |
getConnectionAttemptCount()
Returns the number of times the AndroidDebugBridge object attempted to connect
to the adb daemon. |
IDevice[] |
getDevices()
Returns the devices. |
int |
getRestartAttemptCount()
Returns the number of times the AndroidDebugBridge object attempted to restart
the adb daemon. |
static java.net.InetSocketAddress |
getSocketAddress()
Returns the socket address of the ADB server on the host. |
boolean |
hasInitialDeviceList()
Returns whether the bridge has acquired the initial list from adb after being created. |
static void |
init(boolean clientSupport)
Initializes the ddm library. |
static void |
initIfNeeded(boolean clientSupport)
Initialized the library only if needed. |
boolean |
isConnected()
Returns whether the AndroidDebugBridge object is still connected to the adb daemon. |
static void |
removeClientChangeListener(AndroidDebugBridge.IClientChangeListener listener)
Removes the listener from the collection of listeners who will be notified when a Client property changed. |
static void |
removeDebugBridgeChangeListener(AndroidDebugBridge.IDebugBridgeChangeListener listener)
Removes the listener from the collection of listeners who will be notified when a new AndroidDebugBridge is started. |
static void |
removeDeviceChangeListener(AndroidDebugBridge.IDeviceChangeListener listener)
Removes the listener from the collection of listeners who will be notified when a IDevice is connected, disconnected, or when its properties or its Client
list changed. |
boolean |
restart()
Restarts adb, but not the services around it. |
void |
setSelectedClient(Client selectedClient)
Sets the client to accept debugger connection on the custom "Selected debug port". |
static void |
terminate()
Terminates the ddm library. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void initIfNeeded(boolean clientSupport)
clientSupport
- Indicates whether the library should enable the monitoring and
interaction with applications running on the devices.init(boolean)
public static void init(boolean clientSupport)
ddm
library.
This must be called once before any call to
createBridge(String, boolean)
.
The library can be initialized in 2 ways:
true
.false
.ddmlib
to connect a debugger to them.ddmlib
which acts as a proxy between the debuggers and
the applications to debug. See Client.getDebuggerListenPort()
.
The preferences of ddmlib
should also be initialized with whatever default
values were changed from the default values.
When the application quits, terminate()
should be called.
clientSupport
- Indicates whether the library should enable the monitoring and
interaction with applications running on the devices.createBridge(String, boolean)
,
DdmPreferences
public static void terminate()
public static java.net.InetSocketAddress getSocketAddress()
public static AndroidDebugBridge createBridge()
AndroidDebugBridge
that is not linked to any particular executable.
This bridge will expect adb to be running. It will not be able to start/stop/restart
adb.
If a bridge has already been started, it is directly returned with no changes (similar
to calling getBridge()
).
public static AndroidDebugBridge createBridge(java.lang.String osLocation, boolean forceNewBridge)
forceNewBridge
is set to false.
osLocation
- the location of the command line tool 'adb'forceNewBridge
- force creation of a new bridge even if one with the same location
already exists.
public static AndroidDebugBridge getBridge()
null
if none were created.
public static void disconnectBridge()
createBridge(String, boolean)
.
public static void addDebugBridgeChangeListener(AndroidDebugBridge.IDebugBridgeChangeListener listener)
AndroidDebugBridge
is connected, by sending it one of the messages defined
in the AndroidDebugBridge.IDebugBridgeChangeListener
interface.
listener
- The listener which should be notified.public static void removeDebugBridgeChangeListener(AndroidDebugBridge.IDebugBridgeChangeListener listener)
AndroidDebugBridge
is started.
listener
- The listener which should no longer be notified.public static void addDeviceChangeListener(AndroidDebugBridge.IDeviceChangeListener listener)
IDevice
is connected, disconnected, or when its properties or its Client
list changed,
by sending it one of the messages defined in the AndroidDebugBridge.IDeviceChangeListener
interface.
listener
- The listener which should be notified.public static void removeDeviceChangeListener(AndroidDebugBridge.IDeviceChangeListener listener)
IDevice
is connected, disconnected, or when its properties or its Client
list changed.
listener
- The listener which should no longer be notified.public static void addClientChangeListener(AndroidDebugBridge.IClientChangeListener listener)
Client
property changed, by sending it one of the messages defined in the
AndroidDebugBridge.IClientChangeListener
interface.
listener
- The listener which should be notified.public static void removeClientChangeListener(AndroidDebugBridge.IClientChangeListener listener)
Client
property changed.
listener
- The listener which should no longer be notified.public IDevice[] getDevices()
hasInitialDeviceList()
public boolean hasInitialDeviceList()
getDevices()
right after createBridge(String, boolean)
will
generally result in an empty list. This is due to the internal asynchronous communication
mechanism with adb
that does not guarantee that the IDevice
list has been
built before the call to getDevices()
.
The recommended way to get the list of IDevice
objects is to create a
AndroidDebugBridge.IDeviceChangeListener
object.
public void setSelectedClient(Client selectedClient)
selectedClient
- the client. Can be null.public boolean isConnected()
AndroidDebugBridge
object is still connected to the adb daemon.
public int getConnectionAttemptCount()
AndroidDebugBridge
object attempted to connect
to the adb daemon.
public int getRestartAttemptCount()
AndroidDebugBridge
object attempted to restart
the adb daemon.
public boolean restart()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |