am d06f8e2f: Merge change 1730 into donut
Merge commit 'd06f8e2f4cb97b5a397793ba7b53e62ab73925f8' * commit 'd06f8e2f4cb97b5a397793ba7b53e62ab73925f8': Make the ddmlib API use IDevice instead of Device
This commit is contained in:
committed by
The Android Open Source Project
commit
47d9b4efb2
@@ -29,7 +29,7 @@ import java.nio.channels.SocketChannel;
|
||||
/**
|
||||
* Helper class to handle requests and connections to adb.
|
||||
* <p/>{@link DebugBridgeServer} is the public API to connection to adb, while {@link AdbHelper}
|
||||
* does the low level stuff.
|
||||
* does the low level stuff.
|
||||
* <p/>This currently uses spin-wait non-blocking I/O. A Selector would be more efficient,
|
||||
* but seems like overkill for what we're doing here.
|
||||
*/
|
||||
@@ -272,14 +272,14 @@ final class AdbHelper {
|
||||
try {
|
||||
adbChan = SocketChannel.open(adbSockAddr);
|
||||
adbChan.configureBlocking(false);
|
||||
|
||||
|
||||
// if the device is not -1, then we first tell adb we're looking to talk
|
||||
// to a specific device
|
||||
setDevice(adbChan, device);
|
||||
|
||||
|
||||
if (write(adbChan, request) == false)
|
||||
throw new IOException("failed asking for frame buffer");
|
||||
|
||||
|
||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||
if (!resp.ioSuccess || !resp.okay) {
|
||||
Log.w("ddms", "Got timeout or unhappy response from ADB fb req: "
|
||||
@@ -287,7 +287,7 @@ final class AdbHelper {
|
||||
adbChan.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
reply = new byte[16];
|
||||
if (read(adbChan, reply) == false) {
|
||||
Log.w("ddms", "got partial reply from ADB fb:");
|
||||
@@ -297,19 +297,19 @@ final class AdbHelper {
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.wrap(reply);
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
|
||||
imageParams.bpp = buf.getInt();
|
||||
imageParams.size = buf.getInt();
|
||||
imageParams.width = buf.getInt();
|
||||
imageParams.height = buf.getInt();
|
||||
|
||||
|
||||
Log.d("ddms", "image params: bpp=" + imageParams.bpp + ", size="
|
||||
+ imageParams.size + ", width=" + imageParams.width
|
||||
+ ", height=" + imageParams.height);
|
||||
|
||||
|
||||
if (write(adbChan, nudge) == false)
|
||||
throw new IOException("failed nudging");
|
||||
|
||||
|
||||
reply = new byte[imageParams.size];
|
||||
if (read(adbChan, reply) == false) {
|
||||
Log.w("ddms", "got truncated reply from ADB fb data");
|
||||
@@ -416,34 +416,34 @@ final class AdbHelper {
|
||||
public static void runLogService(InetSocketAddress adbSockAddr, Device device, String logName,
|
||||
LogReceiver rcvr) throws IOException {
|
||||
SocketChannel adbChan = null;
|
||||
|
||||
|
||||
try {
|
||||
adbChan = SocketChannel.open(adbSockAddr);
|
||||
adbChan.configureBlocking(false);
|
||||
|
||||
|
||||
// if the device is not -1, then we first tell adb we're looking to talk
|
||||
// to a specific device
|
||||
setDevice(adbChan, device);
|
||||
|
||||
|
||||
byte[] request = formAdbRequest("log:" + logName);
|
||||
if (write(adbChan, request) == false) {
|
||||
throw new IOException("failed to submit the log command");
|
||||
}
|
||||
|
||||
|
||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||
if (!resp.ioSuccess || !resp.okay) {
|
||||
throw new IOException("Device rejected log command: " + resp.message);
|
||||
}
|
||||
|
||||
|
||||
byte[] data = new byte[16384];
|
||||
ByteBuffer buf = ByteBuffer.wrap(data);
|
||||
while (true) {
|
||||
int count;
|
||||
|
||||
|
||||
if (rcvr != null && rcvr.isCancelled()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
count = adbChan.read(buf);
|
||||
if (count < 0) {
|
||||
break;
|
||||
@@ -465,7 +465,7 @@ final class AdbHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a port forwarding between a local and a remote port.
|
||||
* @param adbSockAddr the socket address to connect to adb
|
||||
@@ -473,7 +473,7 @@ final class AdbHelper {
|
||||
* @param localPort the local port to forward
|
||||
* @param remotePort the remote port.
|
||||
* @return <code>true</code> if success.
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static boolean createForward(InetSocketAddress adbSockAddr, Device device, int localPort,
|
||||
int remotePort) throws IOException {
|
||||
@@ -482,15 +482,15 @@ final class AdbHelper {
|
||||
try {
|
||||
adbChan = SocketChannel.open(adbSockAddr);
|
||||
adbChan.configureBlocking(false);
|
||||
|
||||
|
||||
byte[] request = formAdbRequest(String.format(
|
||||
"host-serial:%1$s:forward:tcp:%2$d;tcp:%3$d", //$NON-NLS-1$
|
||||
device.serialNumber, localPort, remotePort));
|
||||
|
||||
device.getSerialNumber(), localPort, remotePort));
|
||||
|
||||
if (write(adbChan, request) == false) {
|
||||
throw new IOException("failed to submit the forward command.");
|
||||
}
|
||||
|
||||
|
||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||
if (!resp.ioSuccess || !resp.okay) {
|
||||
throw new IOException("Device rejected command: " + resp.message);
|
||||
@@ -500,7 +500,7 @@ final class AdbHelper {
|
||||
adbChan.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -520,15 +520,15 @@ final class AdbHelper {
|
||||
try {
|
||||
adbChan = SocketChannel.open(adbSockAddr);
|
||||
adbChan.configureBlocking(false);
|
||||
|
||||
|
||||
byte[] request = formAdbRequest(String.format(
|
||||
"host-serial:%1$s:killforward:tcp:%2$d;tcp:%3$d", //$NON-NLS-1$
|
||||
device.serialNumber, localPort, remotePort));
|
||||
|
||||
device.getSerialNumber(), localPort, remotePort));
|
||||
|
||||
if (!write(adbChan, request)) {
|
||||
throw new IOException("failed to submit the remove forward command.");
|
||||
}
|
||||
|
||||
|
||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||
if (!resp.ioSuccess || !resp.okay) {
|
||||
throw new IOException("Device rejected command: " + resp.message);
|
||||
@@ -563,7 +563,7 @@ final class AdbHelper {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads from the socket until the array is filled, or no more data is coming (because
|
||||
* the socket closed or the timeout expired).
|
||||
@@ -572,7 +572,7 @@ final class AdbHelper {
|
||||
* mode for timeouts to work
|
||||
* @param data the buffer to store the read data into.
|
||||
* @return "true" if all data was read.
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
static boolean read(SocketChannel chan, byte[] data) {
|
||||
try {
|
||||
@@ -581,7 +581,7 @@ final class AdbHelper {
|
||||
Log.d("ddms", "readAll: IOException: " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ final class AdbHelper {
|
||||
* @param data the buffer to store the read data into.
|
||||
* @param length the length to read or -1 to fill the data buffer completely
|
||||
* @param timeout The timeout value. A timeout of zero means "wait forever".
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
static void read(SocketChannel chan, byte[] data, int length, int timeout) throws IOException {
|
||||
ByteBuffer buf = ByteBuffer.wrap(data, 0, length != -1 ? length : data.length);
|
||||
@@ -653,7 +653,7 @@ final class AdbHelper {
|
||||
* @param data the buffer to send.
|
||||
* @param length the length to write or -1 to send the whole buffer.
|
||||
* @param timeout The timeout value. A timeout of zero means "wait forever".
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
static void write(SocketChannel chan, byte[] data, int length, int timeout)
|
||||
throws IOException {
|
||||
@@ -697,7 +697,7 @@ final class AdbHelper {
|
||||
// if the device is not -1, then we first tell adb we're looking to talk
|
||||
// to a specific device
|
||||
if (device != null) {
|
||||
String msg = "host:transport:" + device.serialNumber; //$NON-NLS-1$
|
||||
String msg = "host:transport:" + device.getSerialNumber(); //$NON-NLS-1$
|
||||
byte[] device_query = formAdbRequest(msg);
|
||||
|
||||
if (write(adbChan, device_query) == false)
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class AndroidDebugBridge {
|
||||
|
||||
/**
|
||||
* Classes which implement this interface provide methods that deal
|
||||
* with {@link Device} addition, deletion, and changes.
|
||||
* with {@link IDevice} addition, deletion, and changes.
|
||||
*/
|
||||
public interface IDeviceChangeListener {
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ public final class AndroidDebugBridge {
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*/
|
||||
public void deviceConnected(Device device);
|
||||
public void deviceConnected(IDevice device);
|
||||
|
||||
/**
|
||||
* Sent when the a device is connected to the {@link AndroidDebugBridge}.
|
||||
@@ -124,7 +124,7 @@ public final class AndroidDebugBridge {
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*/
|
||||
public void deviceDisconnected(Device device);
|
||||
public void deviceDisconnected(IDevice device);
|
||||
|
||||
/**
|
||||
* Sent when a device data changed, or when clients are started/terminated on the device.
|
||||
@@ -132,10 +132,10 @@ public final class AndroidDebugBridge {
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the device that was updated.
|
||||
* @param changeMask the mask describing what changed. It can contain any of the following
|
||||
* values: {@link Device#CHANGE_BUILD_INFO}, {@link Device#CHANGE_STATE},
|
||||
* {@link Device#CHANGE_CLIENT_LIST}
|
||||
* values: {@link IDevice#CHANGE_BUILD_INFO}, {@link IDevice#CHANGE_STATE},
|
||||
* {@link IDevice#CHANGE_CLIENT_LIST}
|
||||
*/
|
||||
public void deviceChanged(Device device, int changeMask);
|
||||
public void deviceChanged(IDevice device, int changeMask);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +215,7 @@ public final class AndroidDebugBridge {
|
||||
|
||||
/**
|
||||
* Returns whether the ddmlib is setup to support monitoring and interacting with
|
||||
* {@link Client}s running on the {@link Device}s.
|
||||
* {@link Client}s running on the {@link IDevice}s.
|
||||
*/
|
||||
static boolean getClientSupport() {
|
||||
return sClientSupport;
|
||||
@@ -391,7 +391,7 @@ public final class AndroidDebugBridge {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listener to the collection of listeners who will be notified when a {@link Device}
|
||||
* Adds the listener to the collection of listeners who will be notified when a {@link IDevice}
|
||||
* is connected, disconnected, or when its properties or its {@link Client} list changed,
|
||||
* by sending it one of the messages defined in the {@link IDeviceChangeListener} interface.
|
||||
* @param listener The listener which should be notified.
|
||||
@@ -406,7 +406,7 @@ public final class AndroidDebugBridge {
|
||||
|
||||
/**
|
||||
* Removes the listener from the collection of listeners who will be notified when a
|
||||
* {@link Device} is connected, disconnected, or when its properties or its {@link Client}
|
||||
* {@link IDevice} is connected, disconnected, or when its properties or its {@link Client}
|
||||
* list changed.
|
||||
* @param listener The listener which should no longer be notified.
|
||||
*/
|
||||
@@ -446,23 +446,23 @@ public final class AndroidDebugBridge {
|
||||
* Returns the devices.
|
||||
* @see #hasInitialDeviceList()
|
||||
*/
|
||||
public Device[] getDevices() {
|
||||
public IDevice[] getDevices() {
|
||||
synchronized (sLock) {
|
||||
if (mDeviceMonitor != null) {
|
||||
return mDeviceMonitor.getDevices();
|
||||
}
|
||||
}
|
||||
|
||||
return new Device[0];
|
||||
return new IDevice[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the bridge has acquired the initial list from adb after being created.
|
||||
* <p/>Calling {@link #getDevices()} right after {@link #createBridge(String, boolean)} will
|
||||
* generally result in an empty list. This is due to the internal asynchronous communication
|
||||
* mechanism with <code>adb</code> that does not guarantee that the {@link Device} list has been
|
||||
* mechanism with <code>adb</code> that does not guarantee that the {@link IDevice} list has been
|
||||
* built before the call to {@link #getDevices()}.
|
||||
* <p/>The recommended way to get the list of {@link Device} objects is to create a
|
||||
* <p/>The recommended way to get the list of {@link IDevice} objects is to create a
|
||||
* {@link IDeviceChangeListener} object.
|
||||
*/
|
||||
public boolean hasInitialDeviceList() {
|
||||
@@ -719,19 +719,19 @@ public final class AndroidDebugBridge {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the listener of a new {@link Device}.
|
||||
* Notify the listener of a new {@link IDevice}.
|
||||
* <p/>
|
||||
* The notification of the listeners is done in a synchronized block. It is important to
|
||||
* expect the listeners to potentially access various methods of {@link Device} as well as
|
||||
* expect the listeners to potentially access various methods of {@link IDevice} as well as
|
||||
* {@link #getDevices()} which use internal locks.
|
||||
* <p/>
|
||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
||||
* {@link Device} which is also inside a synchronized block, should first synchronize on
|
||||
* {@link IDevice} which is also inside a synchronized block, should first synchronize on
|
||||
* the {@link AndroidDebugBridge} lock. Access to this lock is done through {@link #getLock()}.
|
||||
* @param device the new <code>Device</code>.
|
||||
* @param device the new <code>IDevice</code>.
|
||||
* @see #getLock()
|
||||
*/
|
||||
void deviceConnected(Device device) {
|
||||
void deviceConnected(IDevice device) {
|
||||
// because the listeners could remove themselves from the list while processing
|
||||
// their event callback, we make a copy of the list and iterate on it instead of
|
||||
// the main list.
|
||||
@@ -755,19 +755,19 @@ public final class AndroidDebugBridge {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the listener of a disconnected {@link Device}.
|
||||
* Notify the listener of a disconnected {@link IDevice}.
|
||||
* <p/>
|
||||
* The notification of the listeners is done in a synchronized block. It is important to
|
||||
* expect the listeners to potentially access various methods of {@link Device} as well as
|
||||
* expect the listeners to potentially access various methods of {@link IDevice} as well as
|
||||
* {@link #getDevices()} which use internal locks.
|
||||
* <p/>
|
||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
||||
* {@link Device} which is also inside a synchronized block, should first synchronize on
|
||||
* {@link IDevice} which is also inside a synchronized block, should first synchronize on
|
||||
* the {@link AndroidDebugBridge} lock. Access to this lock is done through {@link #getLock()}.
|
||||
* @param device the disconnected <code>Device</code>.
|
||||
* @param device the disconnected <code>IDevice</code>.
|
||||
* @see #getLock()
|
||||
*/
|
||||
void deviceDisconnected(Device device) {
|
||||
void deviceDisconnected(IDevice device) {
|
||||
// because the listeners could remove themselves from the list while processing
|
||||
// their event callback, we make a copy of the list and iterate on it instead of
|
||||
// the main list.
|
||||
@@ -791,19 +791,19 @@ public final class AndroidDebugBridge {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the listener of a modified {@link Device}.
|
||||
* Notify the listener of a modified {@link IDevice}.
|
||||
* <p/>
|
||||
* The notification of the listeners is done in a synchronized block. It is important to
|
||||
* expect the listeners to potentially access various methods of {@link Device} as well as
|
||||
* expect the listeners to potentially access various methods of {@link IDevice} as well as
|
||||
* {@link #getDevices()} which use internal locks.
|
||||
* <p/>
|
||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
||||
* {@link Device} which is also inside a synchronized block, should first synchronize on
|
||||
* {@link IDevice} which is also inside a synchronized block, should first synchronize on
|
||||
* the {@link AndroidDebugBridge} lock. Access to this lock is done through {@link #getLock()}.
|
||||
* @param device the modified <code>Device</code>.
|
||||
* @param device the modified <code>IDevice</code>.
|
||||
* @see #getLock()
|
||||
*/
|
||||
void deviceChanged(Device device, int changeMask) {
|
||||
void deviceChanged(IDevice device, int changeMask) {
|
||||
// because the listeners could remove themselves from the list while processing
|
||||
// their event callback, we make a copy of the list and iterate on it instead of
|
||||
// the main list.
|
||||
@@ -830,11 +830,11 @@ public final class AndroidDebugBridge {
|
||||
* Notify the listener of a modified {@link Client}.
|
||||
* <p/>
|
||||
* The notification of the listeners is done in a synchronized block. It is important to
|
||||
* expect the listeners to potentially access various methods of {@link Device} as well as
|
||||
* expect the listeners to potentially access various methods of {@link IDevice} as well as
|
||||
* {@link #getDevices()} which use internal locks.
|
||||
* <p/>
|
||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
||||
* {@link Device} which is also inside a synchronized block, should first synchronize on
|
||||
* {@link IDevice} which is also inside a synchronized block, should first synchronize on
|
||||
* the {@link AndroidDebugBridge} lock. Access to this lock is done through {@link #getLock()}.
|
||||
* @param device the modified <code>Client</code>.
|
||||
* @param changeMask the mask indicating what changed in the <code>Client</code>
|
||||
|
||||
@@ -199,7 +199,7 @@ abstract class ChunkHandler {
|
||||
protected static Client checkDebuggerPortForAppName(Client client, String appName) {
|
||||
IDebugPortProvider provider = DebugPortManager.getProvider();
|
||||
if (provider != null) {
|
||||
Device device = client.getDevice();
|
||||
Device device = client.getDeviceImpl();
|
||||
int newPort = provider.getPort(device, appName);
|
||||
|
||||
if (newPort != IDebugPortProvider.NO_STATIC_PORT &&
|
||||
|
||||
@@ -133,7 +133,7 @@ public class Client {
|
||||
mConnState = ST_INIT;
|
||||
|
||||
mClientData = new ClientData(pid);
|
||||
|
||||
|
||||
mThreadUpdateEnabled = DdmPreferences.getInitialThreadUpdate();
|
||||
mHeapUpdateEnabled = DdmPreferences.getInitialHeapUpdate();
|
||||
}
|
||||
@@ -147,9 +147,15 @@ public class Client {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Device} on which this Client is running.
|
||||
* Returns the {@link IDevice} on which this Client is running.
|
||||
*/
|
||||
public Device getDevice() {
|
||||
public IDevice getDevice() {
|
||||
return mDevice;
|
||||
}
|
||||
|
||||
/** Returns the {@link Device} on which this Client is running.
|
||||
*/
|
||||
Device getDeviceImpl() {
|
||||
return mDevice;
|
||||
}
|
||||
|
||||
@@ -238,7 +244,7 @@ public class Client {
|
||||
|
||||
update(CHANGE_THREAD_MODE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the thread update is enabled.
|
||||
*/
|
||||
@@ -268,7 +274,7 @@ public class Client {
|
||||
public void requestThreadStackTrace(int threadId) {
|
||||
HandleThread.requestThreadStackCallRefresh(this, threadId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables or disables the heap update.
|
||||
* <p/>If <code>true</code>, any GC will cause the client to send its heap information.
|
||||
@@ -320,7 +326,7 @@ public class Client {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables or disables the Allocation tracker for this client.
|
||||
* <p/>If enabled, the VM will start tracking allocation informations. A call to
|
||||
@@ -336,7 +342,7 @@ public class Client {
|
||||
Log.e("ddmlib", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends a request to the VM to send the enable status of the allocation tracking.
|
||||
* This is asynchronous.
|
||||
@@ -350,9 +356,9 @@ public class Client {
|
||||
HandleHeap.sendREAQ(this);
|
||||
} catch (IOException e) {
|
||||
Log.e("ddmlib", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends a request to the VM to send the information about all the allocations that have
|
||||
* happened since the call to {@link #enableAllocationTracker(boolean)} with <var>enable</var>
|
||||
@@ -457,7 +463,7 @@ public class Client {
|
||||
}
|
||||
|
||||
mConnState = ST_AWAIT_SHAKE;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -638,7 +644,7 @@ public class Client {
|
||||
*/
|
||||
Log.e("ddms", "Receiving data in state = " + mConnState);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -753,7 +759,7 @@ public class Client {
|
||||
|
||||
mDevice.removeClient(this, notify);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this {@link Client} has a valid connection to the application VM.
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,12 @@ package com.android.ddmlib;
|
||||
import com.android.ddmlib.Device;
|
||||
|
||||
/**
|
||||
* Centralized point to provide a {@link IDebugPortProvider} to ddmlib.
|
||||
*
|
||||
* Centralized point to provide a {@link IDebugPortProvider} to ddmlib.
|
||||
*
|
||||
* <p/>When {@link Client} objects are created, they start listening for debuggers on a specific
|
||||
* port. The default behavior is to start with {@link DdmPreferences#getDebugPortBase()} and
|
||||
* port. The default behavior is to start with {@link DdmPreferences#getDebugPortBase()} and
|
||||
* increment this value for each new <code>Client</code>.
|
||||
*
|
||||
*
|
||||
* <p/>This {@link DebugPortManager} allows applications using ddmlib to provide a custom
|
||||
* port provider on a per-<code>Client</code> basis, depending on the device/emulator they are
|
||||
* running on, and/or their names.
|
||||
@@ -48,7 +48,7 @@ public class DebugPortManager {
|
||||
* @return The non-random debugger port or {@link #NO_STATIC_PORT} if the {@link Client}
|
||||
* should use the automatic debugger port provider.
|
||||
*/
|
||||
public int getPort(Device device, String appName);
|
||||
public int getPort(IDevice device, String appName);
|
||||
}
|
||||
|
||||
private static IDebugPortProvider sProvider = null;
|
||||
@@ -63,7 +63,7 @@ public class DebugPortManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the
|
||||
* Returns the
|
||||
* @return
|
||||
*/
|
||||
static IDebugPortProvider getProvider() {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.ddmlib;
|
||||
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.log.LogReceiver;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -30,50 +29,20 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* A Device. It can be a physical device or an emulator.
|
||||
*
|
||||
* TODO: make this class package-protected, and shift all callers to use IDevice
|
||||
*/
|
||||
public final class Device implements IDevice {
|
||||
/**
|
||||
* The state of a device.
|
||||
*/
|
||||
public static enum DeviceState {
|
||||
BOOTLOADER("bootloader"), //$NON-NLS-1$
|
||||
OFFLINE("offline"), //$NON-NLS-1$
|
||||
ONLINE("device"); //$NON-NLS-1$
|
||||
|
||||
private String mState;
|
||||
|
||||
DeviceState(String state) {
|
||||
mState = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link DeviceState} from the string returned by <code>adb devices</code>.
|
||||
* @param state the device state.
|
||||
* @return a {@link DeviceState} object or <code>null</code> if the state is unknown.
|
||||
*/
|
||||
public static DeviceState getState(String state) {
|
||||
for (DeviceState deviceState : values()) {
|
||||
if (deviceState.mState.equals(state)) {
|
||||
return deviceState;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
final class Device implements IDevice {
|
||||
|
||||
/** Emulator Serial Number regexp. */
|
||||
final static String RE_EMULATOR_SN = "emulator-(\\d+)"; //$NON-NLS-1$
|
||||
|
||||
/** Serial number of the device */
|
||||
String serialNumber = null;
|
||||
private String mSerialNumber = null;
|
||||
|
||||
/** Name of the AVD */
|
||||
String mAvdName = null;
|
||||
private String mAvdName = null;
|
||||
|
||||
/** State of the device. */
|
||||
DeviceState state = null;
|
||||
private DeviceState mState = null;
|
||||
|
||||
/** Device properties. */
|
||||
private final Map<String, String> mProperties = new HashMap<String, String>();
|
||||
@@ -91,22 +60,42 @@ public final class Device implements IDevice {
|
||||
* @see com.android.ddmlib.IDevice#getSerialNumber()
|
||||
*/
|
||||
public String getSerialNumber() {
|
||||
return serialNumber;
|
||||
return mSerialNumber;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getAvdName() {
|
||||
return mAvdName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the AVD
|
||||
*/
|
||||
void setAvdName(String avdName) {
|
||||
if (isEmulator() == false) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot set the AVD name of the device is not an emulator");
|
||||
}
|
||||
|
||||
mAvdName = avdName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.android.ddmlib.IDevice#getState()
|
||||
*/
|
||||
public DeviceState getState() {
|
||||
return state;
|
||||
return mState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the state of the device.
|
||||
*/
|
||||
void setState(DeviceState state) {
|
||||
mState = state;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.android.ddmlib.IDevice#getProperties()
|
||||
@@ -134,7 +123,7 @@ public final class Device implements IDevice {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return serialNumber;
|
||||
return mSerialNumber;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -142,7 +131,7 @@ public final class Device implements IDevice {
|
||||
* @see com.android.ddmlib.IDevice#isOnline()
|
||||
*/
|
||||
public boolean isOnline() {
|
||||
return state == DeviceState.ONLINE;
|
||||
return mState == DeviceState.ONLINE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -150,7 +139,7 @@ public final class Device implements IDevice {
|
||||
* @see com.android.ddmlib.IDevice#isEmulator()
|
||||
*/
|
||||
public boolean isEmulator() {
|
||||
return serialNumber.matches(RE_EMULATOR_SN);
|
||||
return mSerialNumber.matches(RE_EMULATOR_SN);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -158,7 +147,7 @@ public final class Device implements IDevice {
|
||||
* @see com.android.ddmlib.IDevice#isOffline()
|
||||
*/
|
||||
public boolean isOffline() {
|
||||
return state == DeviceState.OFFLINE;
|
||||
return mState == DeviceState.OFFLINE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -166,7 +155,7 @@ public final class Device implements IDevice {
|
||||
* @see com.android.ddmlib.IDevice#isBootLoader()
|
||||
*/
|
||||
public boolean isBootLoader() {
|
||||
return state == DeviceState.BOOTLOADER;
|
||||
return mState == DeviceState.BOOTLOADER;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -305,8 +294,10 @@ public final class Device implements IDevice {
|
||||
}
|
||||
|
||||
|
||||
Device(DeviceMonitor monitor) {
|
||||
Device(DeviceMonitor monitor, String serialNumber, DeviceState deviceState) {
|
||||
mMonitor = monitor;
|
||||
mSerialNumber = serialNumber;
|
||||
mState = deviceState;
|
||||
}
|
||||
|
||||
DeviceMonitor getMonitor() {
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.android.ddmlib;
|
||||
|
||||
import com.android.ddmlib.AdbHelper.AdbResponse;
|
||||
import com.android.ddmlib.DebugPortManager.IDebugPortProvider;
|
||||
import com.android.ddmlib.Device.DeviceState;
|
||||
import com.android.ddmlib.IDevice.DeviceState;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -112,11 +112,11 @@ final class DeviceMonitor {
|
||||
boolean isMonitoring() {
|
||||
return mMonitoring;
|
||||
}
|
||||
|
||||
|
||||
int getConnectionAttemptCount() {
|
||||
return mConnectionAttempt;
|
||||
}
|
||||
|
||||
|
||||
int getRestartAttemptCount() {
|
||||
return mRestartAttemptCount;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ final class DeviceMonitor {
|
||||
return mDevices.toArray(new Device[mDevices.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean hasInitialDeviceList() {
|
||||
return mInitialDeviceListDone;
|
||||
}
|
||||
@@ -184,11 +184,11 @@ final class DeviceMonitor {
|
||||
if (mMonitoring) {
|
||||
// read the length of the incoming message
|
||||
int length = readLength(mMainAdbConnection, mLengthBuffer);
|
||||
|
||||
|
||||
if (length >= 0) {
|
||||
// read the incoming message
|
||||
processIncomingDeviceData(length);
|
||||
|
||||
|
||||
// flag the fact that we have build the list at least once.
|
||||
mInitialDeviceListDone = true;
|
||||
}
|
||||
@@ -278,20 +278,19 @@ final class DeviceMonitor {
|
||||
*/
|
||||
private void processIncomingDeviceData(int length) throws IOException {
|
||||
ArrayList<Device> list = new ArrayList<Device>();
|
||||
|
||||
|
||||
if (length > 0) {
|
||||
byte[] buffer = new byte[length];
|
||||
String result = read(mMainAdbConnection, buffer);
|
||||
|
||||
|
||||
String[] devices = result.split("\n"); // $NON-NLS-1$
|
||||
|
||||
for (String d : devices) {
|
||||
String[] param = d.split("\t"); // $NON-NLS-1$
|
||||
if (param.length == 2) {
|
||||
// new adb uses only serial numbers to identify devices
|
||||
Device device = new Device(this);
|
||||
device.serialNumber = param[0];
|
||||
device.state = DeviceState.getState(param[1]);
|
||||
Device device = new Device(this, param[0] /*serialnumber*/,
|
||||
DeviceState.getState(param[1]));
|
||||
|
||||
//add the device to the list
|
||||
list.add(device);
|
||||
@@ -319,24 +318,24 @@ final class DeviceMonitor {
|
||||
// * if we do not find it, we remove it from the current list.
|
||||
// Once this is done, the new list contains device we aren't monitoring yet, so we
|
||||
// add them to the list, and start monitoring them.
|
||||
|
||||
|
||||
for (int d = 0 ; d < mDevices.size() ;) {
|
||||
Device device = mDevices.get(d);
|
||||
|
||||
|
||||
// look for a similar device in the new list.
|
||||
int count = newList.size();
|
||||
boolean foundMatch = false;
|
||||
for (int dd = 0 ; dd < count ; dd++) {
|
||||
Device newDevice = newList.get(dd);
|
||||
// see if it matches in id and serial number.
|
||||
if (newDevice.serialNumber.equals(device.serialNumber)) {
|
||||
if (newDevice.getSerialNumber().equals(device.getSerialNumber())) {
|
||||
foundMatch = true;
|
||||
|
||||
|
||||
// update the state if needed.
|
||||
if (device.state != newDevice.state) {
|
||||
device.state = newDevice.state;
|
||||
if (device.getState() != newDevice.getState()) {
|
||||
device.setState(newDevice.getState());
|
||||
device.update(Device.CHANGE_STATE);
|
||||
|
||||
|
||||
// if the device just got ready/online, we need to start
|
||||
// monitoring it.
|
||||
if (device.isOnline()) {
|
||||
@@ -344,7 +343,7 @@ final class DeviceMonitor {
|
||||
if (startMonitoringDevice(device) == false) {
|
||||
Log.e("DeviceMonitor",
|
||||
"Failed to start monitoring "
|
||||
+ device.serialNumber);
|
||||
+ device.getSerialNumber());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,13 +352,13 @@ final class DeviceMonitor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove the new device from the list since it's been used
|
||||
newList.remove(dd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (foundMatch == false) {
|
||||
// the device is gone, we need to remove it, and keep current index
|
||||
// to process the next one.
|
||||
@@ -370,21 +369,21 @@ final class DeviceMonitor {
|
||||
d++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// at this point we should still have some new devices in newList, so we
|
||||
// process them.
|
||||
for (Device newDevice : newList) {
|
||||
// add them to the list
|
||||
mDevices.add(newDevice);
|
||||
mServer.deviceConnected(newDevice);
|
||||
|
||||
|
||||
// start monitoring them.
|
||||
if (AndroidDebugBridge.getClientSupport() == true) {
|
||||
if (newDevice.isOnline()) {
|
||||
startMonitoringDevice(newDevice);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// look for their build info.
|
||||
if (newDevice.isOnline()) {
|
||||
queryNewDeviceForInfo(newDevice);
|
||||
@@ -398,7 +397,7 @@ final class DeviceMonitor {
|
||||
private void removeDevice(Device device) {
|
||||
device.clearClientList();
|
||||
mDevices.remove(device);
|
||||
|
||||
|
||||
SocketChannel channel = device.getClientMonitoringSocket();
|
||||
if (channel != null) {
|
||||
try {
|
||||
@@ -419,12 +418,12 @@ final class DeviceMonitor {
|
||||
// first get the list of properties.
|
||||
device.executeShellCommand(GetPropReceiver.GETPROP_COMMAND,
|
||||
new GetPropReceiver(device));
|
||||
|
||||
|
||||
// now get the emulator Virtual Device name (if applicable).
|
||||
if (device.isEmulator()) {
|
||||
EmulatorConsole console = EmulatorConsole.getConsole(device);
|
||||
if (console != null) {
|
||||
device.mAvdName = console.getAvdName();
|
||||
device.setAvdName(console.getAvdName());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -510,7 +509,7 @@ final class DeviceMonitor {
|
||||
MonitorThread monitorThread = MonitorThread.getInstance();
|
||||
|
||||
for (Client client : clients) {
|
||||
Device device = client.getDevice();
|
||||
Device device = client.getDeviceImpl();
|
||||
int pid = client.getClientData().getPid();
|
||||
|
||||
monitorThread.dropClient(client, false /* notify */);
|
||||
@@ -623,10 +622,10 @@ final class DeviceMonitor {
|
||||
if (length > 0) {
|
||||
byte[] buffer = new byte[length];
|
||||
String result = read(monitorSocket, buffer);
|
||||
|
||||
|
||||
// split each line in its own list and create an array of integer pid
|
||||
String[] pids = result.split("\n"); //$NON-NLS-1$
|
||||
|
||||
|
||||
for (String pid : pids) {
|
||||
try {
|
||||
pidList.add(Integer.valueOf(pid));
|
||||
@@ -662,7 +661,7 @@ final class DeviceMonitor {
|
||||
for (int c = 0 ; c < clients.size() ;) {
|
||||
Client client = clients.get(c);
|
||||
int pid = client.getClientData().getPid();
|
||||
|
||||
|
||||
// look for a matching pid
|
||||
Integer match = null;
|
||||
for (Integer matchingPid : pidList) {
|
||||
@@ -671,7 +670,7 @@ final class DeviceMonitor {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (match != null) {
|
||||
pidList.remove(match);
|
||||
c++; // move on to the next client.
|
||||
@@ -705,7 +704,7 @@ final class DeviceMonitor {
|
||||
* @return
|
||||
*/
|
||||
private void openClient(Device device, int pid, int port, MonitorThread monitorThread) {
|
||||
|
||||
|
||||
SocketChannel clientSocket;
|
||||
try {
|
||||
clientSocket = AdbHelper.createPassThroughConnection(
|
||||
@@ -721,7 +720,7 @@ final class DeviceMonitor {
|
||||
"Failed to connect to client '" + pid + "': " + ioe.getMessage());
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
createClient(device, pid, clientSocket, port, monitorThread);
|
||||
}
|
||||
|
||||
@@ -814,7 +813,7 @@ final class DeviceMonitor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the length of the next message from a socket.
|
||||
* @param socket The {@link SocketChannel} to read from.
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.regex.Pattern;
|
||||
* code removes <code>\r</code> and waits for <code>\n</code>.
|
||||
* <p/>However this means you <i>may</i> receive <code>\r\n</code> when reading from the console.
|
||||
* <p/>
|
||||
* <b>This API will change in the near future.</b>
|
||||
* <b>This API will change in the near future.</b>
|
||||
*/
|
||||
public final class EmulatorConsole {
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class EmulatorConsole {
|
||||
private final static String COMMAND_NETWORK_STATUS = "network status\r\n"; //$NON-NLS-1$
|
||||
private final static String COMMAND_NETWORK_SPEED = "network speed %1$s\r\n"; //$NON-NLS-1$
|
||||
private final static String COMMAND_NETWORK_LATENCY = "network delay %1$s\r\n"; //$NON-NLS-1$
|
||||
private final static String COMMAND_GPS =
|
||||
private final static String COMMAND_GPS =
|
||||
"geo nmea $GPGGA,%1$02d%2$02d%3$02d.%4$03d," + //$NON-NLS-1$
|
||||
"%5$03d%6$09.6f,%7$c,%8$03d%9$09.6f,%10$c," + //$NON-NLS-1$
|
||||
"1,10,0.0,0.0,0,0.0,0,0.0,0000\r\n"; //$NON-NLS-1$
|
||||
@@ -202,9 +202,9 @@ public final class EmulatorConsole {
|
||||
* @param d The device that the console links to.
|
||||
* @return an <code>EmulatorConsole</code> object or <code>null</code> if the connection failed.
|
||||
*/
|
||||
public static synchronized EmulatorConsole getConsole(Device d) {
|
||||
public static synchronized EmulatorConsole getConsole(IDevice d) {
|
||||
// we need to make sure that the device is an emulator
|
||||
Matcher m = sEmulatorRegexp.matcher(d.serialNumber);
|
||||
Matcher m = sEmulatorRegexp.matcher(d.getSerialNumber());
|
||||
if (m.matches()) {
|
||||
// get the port number. This is the console port.
|
||||
int port;
|
||||
@@ -308,7 +308,7 @@ public final class EmulatorConsole {
|
||||
RemoveConsole(mPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized String getAvdName() {
|
||||
if (sendCommand(COMMAND_AVD_NAME)) {
|
||||
String[] result = readLines();
|
||||
@@ -323,7 +323,7 @@ public final class EmulatorConsole {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -517,18 +517,18 @@ public final class EmulatorConsole {
|
||||
String command = String.format(COMMAND_NETWORK_LATENCY, NETWORK_LATENCIES[selectionIndex]);
|
||||
return processCommand(command);
|
||||
}
|
||||
|
||||
|
||||
public synchronized String sendLocation(double longitude, double latitude, double elevation) {
|
||||
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
|
||||
double absLong = Math.abs(longitude);
|
||||
int longDegree = (int)Math.floor(absLong);
|
||||
char longDirection = 'E';
|
||||
if (longitude < 0) {
|
||||
longDirection = 'W';
|
||||
}
|
||||
|
||||
|
||||
double longMinute = (absLong - Math.floor(absLong)) * 60;
|
||||
|
||||
double absLat = Math.abs(latitude);
|
||||
@@ -537,15 +537,15 @@ public final class EmulatorConsole {
|
||||
if (latitude < 0) {
|
||||
latDirection = 'S';
|
||||
}
|
||||
|
||||
|
||||
double latMinute = (absLat - Math.floor(absLat)) * 60;
|
||||
|
||||
|
||||
String command = String.format(COMMAND_GPS,
|
||||
c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE),
|
||||
c.get(Calendar.SECOND), c.get(Calendar.MILLISECOND),
|
||||
latDegree, latMinute, latDirection,
|
||||
longDegree, longMinute, longDirection);
|
||||
|
||||
|
||||
return processCommand(command);
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ public final class EmulatorConsole {
|
||||
ByteBuffer buf = ByteBuffer.wrap(mBuffer, 0, mBuffer.length);
|
||||
int numWaits = 0;
|
||||
boolean stop = false;
|
||||
|
||||
|
||||
while (buf.position() != buf.limit() && stop == false) {
|
||||
int count;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.ddmlib;
|
||||
|
||||
import com.android.ddmlib.Device.DeviceState;
|
||||
import com.android.ddmlib.log.LogReceiver;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -40,6 +39,35 @@ public interface IDevice {
|
||||
/** Device change bit mask: build info change. */
|
||||
public static final int CHANGE_BUILD_INFO = 0x0004;
|
||||
|
||||
/**
|
||||
* The state of a device.
|
||||
*/
|
||||
public static enum DeviceState {
|
||||
BOOTLOADER("bootloader"), //$NON-NLS-1$
|
||||
OFFLINE("offline"), //$NON-NLS-1$
|
||||
ONLINE("device"); //$NON-NLS-1$
|
||||
|
||||
private String mState;
|
||||
|
||||
DeviceState(String state) {
|
||||
mState = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link DeviceState} from the string returned by <code>adb devices</code>.
|
||||
* @param state the device state.
|
||||
* @return a {@link DeviceState} object or <code>null</code> if the state is unknown.
|
||||
*/
|
||||
public static DeviceState getState(String state) {
|
||||
for (DeviceState deviceState : values()) {
|
||||
if (deviceState.mState.equals(state)) {
|
||||
return deviceState;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the serial number of the device.
|
||||
*/
|
||||
|
||||
@@ -103,7 +103,7 @@ final class MonitorThread extends Thread {
|
||||
|
||||
|
||||
/**
|
||||
* Sets or changes the port number for "debug selected".
|
||||
* Sets or changes the port number for "debug selected".
|
||||
*/
|
||||
synchronized void setDebugSelectedPort(int port) throws IllegalStateException {
|
||||
if (mInstance == null) {
|
||||
@@ -206,7 +206,7 @@ final class MonitorThread extends Thread {
|
||||
}
|
||||
|
||||
while (!mQuit) {
|
||||
|
||||
|
||||
try {
|
||||
/*
|
||||
* sync with new registrations: we wait until addClient is done before going through
|
||||
@@ -215,7 +215,7 @@ final class MonitorThread extends Thread {
|
||||
*/
|
||||
synchronized (mClientList) {
|
||||
}
|
||||
|
||||
|
||||
// (re-)open the "debug selected" port, if it's not opened yet or
|
||||
// if the port changed.
|
||||
try {
|
||||
@@ -234,7 +234,7 @@ final class MonitorThread extends Thread {
|
||||
Log.e("ddms", ioe);
|
||||
mNewDebugSelectedPort = mDebugSelectedPort; // no retry
|
||||
}
|
||||
|
||||
|
||||
int count;
|
||||
try {
|
||||
count = mSelector.select();
|
||||
@@ -244,20 +244,20 @@ final class MonitorThread extends Thread {
|
||||
} catch (CancelledKeyException cke) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (count == 0) {
|
||||
// somebody called wakeup() ?
|
||||
// Log.i("ddms", "selector looping");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Set<SelectionKey> keys = mSelector.selectedKeys();
|
||||
Iterator<SelectionKey> iter = keys.iterator();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
SelectionKey key = iter.next();
|
||||
iter.remove();
|
||||
|
||||
|
||||
try {
|
||||
if (key.attachment() instanceof Client) {
|
||||
processClientActivity(key);
|
||||
@@ -300,7 +300,7 @@ final class MonitorThread extends Thread {
|
||||
*/
|
||||
private void processClientActivity(SelectionKey key) {
|
||||
Client client = (Client)key.attachment();
|
||||
|
||||
|
||||
try {
|
||||
if (key.isReadable() == false || key.isValid() == false) {
|
||||
Log.d("ddms", "Invalid key from " + client + ". Dropping client.");
|
||||
@@ -423,7 +423,7 @@ final class MonitorThread extends Thread {
|
||||
* @param notify
|
||||
*/
|
||||
synchronized void dropClient(Client client, boolean notify) {
|
||||
if (mInstance == null) {
|
||||
if (mInstance == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -551,13 +551,13 @@ final class MonitorThread extends Thread {
|
||||
|
||||
// we should drop the client, but also attempt to reopen it.
|
||||
// This is done by the DeviceMonitor.
|
||||
client.getDevice().getMonitor().addClientToDropAndReopen(client,
|
||||
client.getDeviceImpl().getMonitor().addClientToDropAndReopen(client,
|
||||
IDebugPortProvider.NO_STATIC_PORT);
|
||||
} else {
|
||||
Log.i("ddms", " (recycling client connection as well)");
|
||||
// we should drop the client, but also attempt to reopen it.
|
||||
// This is done by the DeviceMonitor.
|
||||
client.getDevice().getMonitor().addClientToDropAndReopen(client,
|
||||
client.getDeviceImpl().getMonitor().addClientToDropAndReopen(client,
|
||||
IDebugPortProvider.NO_STATIC_PORT);
|
||||
}
|
||||
}
|
||||
@@ -644,7 +644,7 @@ final class MonitorThread extends Thread {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Broadcast an event to all message handlers.
|
||||
*/
|
||||
@@ -719,7 +719,7 @@ final class MonitorThread extends Thread {
|
||||
}
|
||||
|
||||
mDebugSelectedChan.register(mSelector, SelectionKey.OP_ACCEPT, this);
|
||||
|
||||
|
||||
return true;
|
||||
} catch (java.net.BindException e) {
|
||||
displayDebugSelectedBindError(mNewDebugSelectedPort);
|
||||
@@ -727,7 +727,7 @@ final class MonitorThread extends Thread {
|
||||
// do not attempt to reopen it.
|
||||
mDebugSelectedChan = null;
|
||||
mNewDebugSelectedPort = -1;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.ddmlib.log;
|
||||
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.Log;
|
||||
import com.android.ddmlib.MultiLineReceiver;
|
||||
import com.android.ddmlib.log.EventContainer.EventValueType;
|
||||
@@ -55,7 +55,7 @@ public final class EventLogParser {
|
||||
private final static int EVENT_TYPE_LONG = 1;
|
||||
private final static int EVENT_TYPE_STRING = 2;
|
||||
private final static int EVENT_TYPE_LIST = 3;
|
||||
|
||||
|
||||
private final static Pattern PATTERN_SIMPLE_TAG = Pattern.compile(
|
||||
"^(\\d+)\\s+([A-Za-z0-9_]+)\\s*$"); //$NON-NLS-1$
|
||||
private final static Pattern PATTERN_TAG_WITH_DESC = Pattern.compile(
|
||||
@@ -67,9 +67,9 @@ public final class EventLogParser {
|
||||
"(\\d\\d)-(\\d\\d)\\s(\\d\\d):(\\d\\d):(\\d\\d).(\\d{3})\\s+I/([a-zA-Z0-9_]+)\\s*\\(\\s*(\\d+)\\):\\s+(.*)"); //$NON-NLS-1$
|
||||
|
||||
private final TreeMap<Integer, String> mTagMap = new TreeMap<Integer, String>();
|
||||
|
||||
|
||||
private final TreeMap<Integer, EventValueDescription[]> mValueDescriptionMap =
|
||||
new TreeMap<Integer, EventValueDescription[]>();
|
||||
new TreeMap<Integer, EventValueDescription[]>();
|
||||
|
||||
public EventLogParser() {
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public final class EventLogParser {
|
||||
* @param device The device.
|
||||
* @return <code>true</code> if success, <code>false</code> if failure or cancellation.
|
||||
*/
|
||||
public boolean init(Device device) {
|
||||
public boolean init(IDevice device) {
|
||||
// read the event tag map file on the device.
|
||||
try {
|
||||
device.executeShellCommand("cat " + EVENT_TAG_MAP_FILE, //$NON-NLS-1$
|
||||
@@ -103,7 +103,7 @@ public final class EventLogParser {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inits the parser with the content of a tag file.
|
||||
* @param tagFileContent the lines of a tag file.
|
||||
@@ -115,7 +115,7 @@ public final class EventLogParser {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inits the parser with a specified event-log-tags file.
|
||||
* @param filePath
|
||||
@@ -124,7 +124,7 @@ public final class EventLogParser {
|
||||
public boolean init(String filePath) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filePath));
|
||||
|
||||
|
||||
String line = null;
|
||||
do {
|
||||
line = reader.readLine();
|
||||
@@ -132,13 +132,13 @@ public final class EventLogParser {
|
||||
processTagLine(line);
|
||||
}
|
||||
} while (line != null);
|
||||
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes a line from the event-log-tags file.
|
||||
* @param line the line to process
|
||||
@@ -154,7 +154,7 @@ public final class EventLogParser {
|
||||
if (name != null && mTagMap.get(value) == null) {
|
||||
mTagMap.put(value, name);
|
||||
}
|
||||
|
||||
|
||||
// special case for the GC tag. We ignore what is in the file,
|
||||
// and take what the custom GcEventContainer class tells us.
|
||||
// This is due to the event encoding several values on 2 longs.
|
||||
@@ -163,12 +163,12 @@ public final class EventLogParser {
|
||||
mValueDescriptionMap.put(value,
|
||||
GcEventContainer.getValueDescriptions());
|
||||
} else {
|
||||
|
||||
|
||||
String description = m.group(3);
|
||||
if (description != null && description.length() > 0) {
|
||||
EventValueDescription[] desc =
|
||||
processDescription(description);
|
||||
|
||||
|
||||
if (desc != null) {
|
||||
mValueDescriptionMap.put(value, desc);
|
||||
}
|
||||
@@ -189,12 +189,12 @@ public final class EventLogParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private EventValueDescription[] processDescription(String description) {
|
||||
String[] descriptions = description.split("\\s*,\\s*"); //$NON-NLS-1$
|
||||
|
||||
|
||||
ArrayList<EventValueDescription> list = new ArrayList<EventValueDescription>();
|
||||
|
||||
|
||||
for (String desc : descriptions) {
|
||||
Matcher m = PATTERN_DESCRIPTION.matcher(desc);
|
||||
if (m.matches()) {
|
||||
@@ -208,15 +208,15 @@ public final class EventLogParser {
|
||||
// just ignore this description if the value is not recognized.
|
||||
// TODO: log the error.
|
||||
}
|
||||
|
||||
|
||||
typeString = m.group(3);
|
||||
if (typeString != null && typeString.length() > 0) {
|
||||
//skip the |
|
||||
typeString = typeString.substring(1);
|
||||
|
||||
|
||||
typeValue = Integer.parseInt(typeString);
|
||||
ValueType valueType = ValueType.getValueType(typeValue);
|
||||
|
||||
|
||||
list.add(new EventValueDescription(name, eventValueType, valueType));
|
||||
} else {
|
||||
list.add(new EventValueDescription(name, eventValueType));
|
||||
@@ -233,15 +233,15 @@ public final class EventLogParser {
|
||||
String.format("Can't parse %1$s", description)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return list.toArray(new EventValueDescription[list.size()]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EventContainer parse(LogEntry entry) {
|
||||
if (entry.len < 4) {
|
||||
return null;
|
||||
@@ -251,7 +251,7 @@ public final class EventLogParser {
|
||||
|
||||
int tagValue = ArrayHelper.swap32bitFromArray(entry.data, inOffset);
|
||||
inOffset += 4;
|
||||
|
||||
|
||||
String tag = mTagMap.get(tagValue);
|
||||
if (tag == null) {
|
||||
Log.e("EventLogParser", String.format("unknown tag number: %1$d", tagValue));
|
||||
@@ -275,10 +275,10 @@ public final class EventLogParser {
|
||||
} else {
|
||||
event = new EventContainer(entry, tagValue, data);
|
||||
}
|
||||
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
public EventContainer parse(String textLogLine) {
|
||||
// line will look like
|
||||
// 04-29 23:16:16.691 I/dvm_gc_info( 427): <data>
|
||||
@@ -289,7 +289,7 @@ public final class EventLogParser {
|
||||
if (textLogLine.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// parse the header first
|
||||
Matcher m = TEXT_LOG_LINE.matcher(textLogLine);
|
||||
if (m.matches()) {
|
||||
@@ -300,7 +300,7 @@ public final class EventLogParser {
|
||||
int minutes = Integer.parseInt(m.group(4));
|
||||
int seconds = Integer.parseInt(m.group(5));
|
||||
int milliseconds = Integer.parseInt(m.group(6));
|
||||
|
||||
|
||||
// convert into seconds since epoch and nano-seconds.
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(cal.get(Calendar.YEAR), month-1, day, hours, minutes, seconds);
|
||||
@@ -308,7 +308,7 @@ public final class EventLogParser {
|
||||
int nsec = milliseconds * 1000000;
|
||||
|
||||
String tag = m.group(7);
|
||||
|
||||
|
||||
// get the numerical tag value
|
||||
int tagValue = -1;
|
||||
Set<Entry<Integer, String>> tagSet = mTagMap.entrySet();
|
||||
@@ -318,18 +318,18 @@ public final class EventLogParser {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tagValue == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
int pid = Integer.parseInt(m.group(8));
|
||||
|
||||
|
||||
Object data = parseTextData(m.group(9), tagValue);
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// now we can allocate and return the EventContainer
|
||||
EventContainer event = null;
|
||||
if (tagValue == GcEventContainer.GC_EVENT_TAG) {
|
||||
@@ -337,20 +337,20 @@ public final class EventLogParser {
|
||||
} else {
|
||||
event = new EventContainer(tagValue, pid, -1 /* tid */, sec, nsec, data);
|
||||
}
|
||||
|
||||
|
||||
return event;
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer, String> getTagMap() {
|
||||
return mTagMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer, EventValueDescription[]> getEventInfoMap() {
|
||||
return mValueDescriptionMap;
|
||||
}
|
||||
@@ -370,7 +370,7 @@ public final class EventLogParser {
|
||||
|
||||
if (eventData.length - dataOffset < 1)
|
||||
return -1;
|
||||
|
||||
|
||||
int offset = dataOffset;
|
||||
|
||||
int type = eventData[offset++];
|
||||
@@ -385,7 +385,7 @@ public final class EventLogParser {
|
||||
return -1;
|
||||
ival = ArrayHelper.swap32bitFromArray(eventData, offset);
|
||||
offset += 4;
|
||||
|
||||
|
||||
list.add(new Integer(ival));
|
||||
}
|
||||
break;
|
||||
@@ -396,7 +396,7 @@ public final class EventLogParser {
|
||||
return -1;
|
||||
lval = ArrayHelper.swap64bitFromArray(eventData, offset);
|
||||
offset += 8;
|
||||
|
||||
|
||||
list.add(new Long(lval));
|
||||
}
|
||||
break;
|
||||
@@ -410,7 +410,7 @@ public final class EventLogParser {
|
||||
|
||||
if (eventData.length - offset < strLen)
|
||||
return -1;
|
||||
|
||||
|
||||
// get the string
|
||||
try {
|
||||
String str = new String(eventData, offset, strLen, "UTF-8"); //$NON-NLS-1$
|
||||
@@ -434,7 +434,7 @@ public final class EventLogParser {
|
||||
if (result == -1) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
offset += result;
|
||||
}
|
||||
|
||||
@@ -446,59 +446,59 @@ public final class EventLogParser {
|
||||
String.format("Unknown binary event type %1$d", type)); //$NON-NLS-1$
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return offset - dataOffset;
|
||||
}
|
||||
|
||||
|
||||
private Object parseTextData(String data, int tagValue) {
|
||||
// first, get the description of what we're supposed to parse
|
||||
EventValueDescription[] desc = mValueDescriptionMap.get(tagValue);
|
||||
|
||||
|
||||
if (desc == null) {
|
||||
// TODO parse and create string values.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (desc.length == 1) {
|
||||
return getObjectFromString(data, desc[0].getEventValueType());
|
||||
} else if (data.startsWith("[") && data.endsWith("]")) {
|
||||
data = data.substring(1, data.length() - 1);
|
||||
|
||||
|
||||
// get each individual values as String
|
||||
String[] values = data.split(",");
|
||||
|
||||
|
||||
if (tagValue == GcEventContainer.GC_EVENT_TAG) {
|
||||
// special case for the GC event!
|
||||
Object[] objects = new Object[2];
|
||||
|
||||
|
||||
objects[0] = getObjectFromString(values[0], EventValueType.LONG);
|
||||
objects[1] = getObjectFromString(values[1], EventValueType.LONG);
|
||||
|
||||
|
||||
return objects;
|
||||
} else {
|
||||
// must be the same number as the number of descriptors.
|
||||
if (values.length != desc.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Object[] objects = new Object[values.length];
|
||||
|
||||
|
||||
for (int i = 0 ; i < desc.length ; i++) {
|
||||
Object obj = getObjectFromString(values[i], desc[i].getEventValueType());
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
objects[i] = obj;
|
||||
objects[i] = obj;
|
||||
}
|
||||
|
||||
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Object getObjectFromString(String value, EventValueType type) {
|
||||
try {
|
||||
switch (type) {
|
||||
@@ -512,14 +512,14 @@ public final class EventLogParser {
|
||||
} catch (NumberFormatException e) {
|
||||
// do nothing, we'll return null.
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreates the event-log-tags at the specified file path.
|
||||
* Recreates the event-log-tags at the specified file path.
|
||||
* @param filePath the file path to write the file.
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void saveTags(String filePath) throws IOException {
|
||||
File destFile = new File(filePath);
|
||||
@@ -527,16 +527,16 @@ public final class EventLogParser {
|
||||
FileOutputStream fos = null;
|
||||
|
||||
try {
|
||||
|
||||
|
||||
fos = new FileOutputStream(destFile);
|
||||
|
||||
|
||||
for (Integer key : mTagMap.keySet()) {
|
||||
// get the tag name
|
||||
String tagName = mTagMap.get(key);
|
||||
|
||||
|
||||
// get the value descriptions
|
||||
EventValueDescription[] descriptors = mValueDescriptionMap.get(key);
|
||||
|
||||
|
||||
String line = null;
|
||||
if (descriptors != null) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -557,12 +557,12 @@ public final class EventLogParser {
|
||||
sb.append("|)"); //$NON-NLS-1$
|
||||
}
|
||||
sb.append("\n"); //$NON-NLS-1$
|
||||
|
||||
|
||||
line = sb.toString();
|
||||
} else {
|
||||
line = String.format("%1$d %2$s\n", key, tagName); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
byte[] buffer = line.getBytes();
|
||||
fos.write(buffer);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.IShellOutputReceiver;
|
||||
import com.android.ddmlib.RawImage;
|
||||
import com.android.ddmlib.SyncService;
|
||||
import com.android.ddmlib.Device.DeviceState;
|
||||
import com.android.ddmlib.log.LogReceiver;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -100,7 +99,7 @@ public class RemoteAndroidTestRunnerTest extends TestCase {
|
||||
final String extraArgValue = "blahValue";
|
||||
mRunner.addInstrumentationArg(extraArgName, extraArgValue);
|
||||
mRunner.run(new EmptyListener());
|
||||
assertStringsEquals(String.format("am instrument -w -r -e %s %s %s/%s", extraArgName,
|
||||
assertStringsEquals(String.format("am instrument -w -r -e %s %s %s/%s", extraArgName,
|
||||
extraArgValue, TEST_PACKAGE, TEST_RUNNER), mMockDevice.getLastShellCommand());
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ import com.android.ddmlib.AndroidDebugBridge;
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.ClientData;
|
||||
import com.android.ddmlib.DdmPreferences;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
|
||||
import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
|
||||
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
||||
import com.android.ddmlib.Device.DeviceState;
|
||||
import com.android.ddmlib.IDevice.DeviceState;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
@@ -69,16 +69,16 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
private final static int CLIENT_COL_THREAD = 2;
|
||||
private final static int CLIENT_COL_HEAP = 3;
|
||||
private final static int CLIENT_COL_PORT = 4;
|
||||
|
||||
|
||||
public final static int ICON_WIDTH = 16;
|
||||
public final static String ICON_THREAD = "thread.png"; //$NON-NLS-1$
|
||||
public final static String ICON_HEAP = "heap.png"; //$NON-NLS-1$
|
||||
public final static String ICON_HALT = "halt.png"; //$NON-NLS-1$
|
||||
public final static String ICON_GC = "gc.png"; //$NON-NLS-1$
|
||||
|
||||
private Device mCurrentDevice;
|
||||
private IDevice mCurrentDevice;
|
||||
private Client mCurrentClient;
|
||||
|
||||
|
||||
private Tree mTree;
|
||||
private TreeViewer mTreeViewer;
|
||||
|
||||
@@ -92,8 +92,8 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
private Image mDebugErrorImage;
|
||||
|
||||
private final ArrayList<IUiSelectionListener> mListeners = new ArrayList<IUiSelectionListener>();
|
||||
|
||||
private final ArrayList<Device> mDevicesToExpand = new ArrayList<Device>();
|
||||
|
||||
private final ArrayList<IDevice> mDevicesToExpand = new ArrayList<IDevice>();
|
||||
|
||||
private IImageLoader mLoader;
|
||||
|
||||
@@ -102,13 +102,13 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
/**
|
||||
* A Content provider for the {@link TreeViewer}.
|
||||
* <p/>
|
||||
* The input is a {@link AndroidDebugBridge}. First level elements are {@link Device} objects,
|
||||
* The input is a {@link AndroidDebugBridge}. First level elements are {@link IDevice} objects,
|
||||
* and second level elements are {@link Client} object.
|
||||
*/
|
||||
private class ContentProvider implements ITreeContentProvider {
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
if (parentElement instanceof Device) {
|
||||
return ((Device)parentElement).getClients();
|
||||
if (parentElement instanceof IDevice) {
|
||||
return ((IDevice)parentElement).getClients();
|
||||
}
|
||||
return new Object[0];
|
||||
}
|
||||
@@ -121,8 +121,8 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
}
|
||||
|
||||
public boolean hasChildren(Object element) {
|
||||
if (element instanceof Device) {
|
||||
return ((Device)element).hasClients();
|
||||
if (element instanceof IDevice) {
|
||||
return ((IDevice)element).hasClients();
|
||||
}
|
||||
|
||||
// Clients never have children.
|
||||
@@ -147,13 +147,13 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
|
||||
/**
|
||||
* A Label Provider for the {@link TreeViewer} in {@link DevicePanel}. It provides
|
||||
* labels and images for {@link Device} and {@link Client} objects.
|
||||
* labels and images for {@link IDevice} and {@link Client} objects.
|
||||
*/
|
||||
private class LabelProvider implements ITableLabelProvider {
|
||||
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
if (columnIndex == DEVICE_COL_SERIAL && element instanceof Device) {
|
||||
Device device = (Device)element;
|
||||
if (columnIndex == DEVICE_COL_SERIAL && element instanceof IDevice) {
|
||||
IDevice device = (IDevice)element;
|
||||
if (device.isEmulator()) {
|
||||
return mEmulatorImage;
|
||||
}
|
||||
@@ -192,17 +192,17 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
}
|
||||
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (element instanceof Device) {
|
||||
Device device = (Device)element;
|
||||
if (element instanceof IDevice) {
|
||||
IDevice device = (IDevice)element;
|
||||
switch (columnIndex) {
|
||||
case DEVICE_COL_SERIAL:
|
||||
return device.getSerialNumber();
|
||||
case DEVICE_COL_STATE:
|
||||
return getStateString(device);
|
||||
case DEVICE_COL_BUILD: {
|
||||
String version = device.getProperty(Device.PROP_BUILD_VERSION);
|
||||
String version = device.getProperty(IDevice.PROP_BUILD_VERSION);
|
||||
if (version != null) {
|
||||
String debuggable = device.getProperty(Device.PROP_DEBUGGABLE);
|
||||
String debuggable = device.getProperty(IDevice.PROP_DEBUGGABLE);
|
||||
if (device.isEmulator()) {
|
||||
String avdName = device.getAvdName();
|
||||
if (avdName == null) {
|
||||
@@ -279,15 +279,15 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
|
||||
/**
|
||||
* Classes which implement this interface provide methods that deals
|
||||
* with {@link Device} and {@link Client} selection changes coming from the ui.
|
||||
* with {@link IDevice} and {@link Client} selection changes coming from the ui.
|
||||
*/
|
||||
public interface IUiSelectionListener {
|
||||
/**
|
||||
* Sent when a new {@link Device} and {@link Client} are selected.
|
||||
* Sent when a new {@link IDevice} and {@link Client} are selected.
|
||||
* @param selectedDevice the selected device. If null, no devices are selected.
|
||||
* @param selectedClient The selected client. If null, no clients are selected.
|
||||
*/
|
||||
public void selectionChanged(Device selectedDevice, Client selectedClient);
|
||||
public void selectionChanged(IDevice selectedDevice, Client selectedClient);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,7 +359,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
|
||||
return mTree;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the focus to the proper control inside the panel.
|
||||
*/
|
||||
@@ -371,7 +371,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
@Override
|
||||
protected void postCreation() {
|
||||
// ask for notification of changes in AndroidDebugBridge (a new one is created when
|
||||
// adb is restarted from a different location), Device and Client objects.
|
||||
// adb is restarted from a different location), IDevice and Client objects.
|
||||
AndroidDebugBridge.addDebugBridgeChangeListener(this);
|
||||
AndroidDebugBridge.addDeviceChangeListener(this);
|
||||
AndroidDebugBridge.addClientChangeListener(this);
|
||||
@@ -391,10 +391,10 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected {@link Device}. If a {@link Client} is selected, it returns the
|
||||
* Device object containing the client.
|
||||
* Returns the selected {@link IDevice}. If a {@link Client} is selected, it returns the
|
||||
* IDevice object containing the client.
|
||||
*/
|
||||
public Device getSelectedDevice() {
|
||||
public IDevice getSelectedDevice() {
|
||||
return mCurrentDevice;
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
public void killSelectedClient() {
|
||||
if (mCurrentClient != null) {
|
||||
Client client = mCurrentClient;
|
||||
|
||||
|
||||
// reset the selection to the device.
|
||||
TreePath treePath = new TreePath(new Object[] { mCurrentDevice });
|
||||
TreeSelection treeSelection = new TreeSelection(treePath);
|
||||
@@ -413,7 +413,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
client.kill();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Forces a GC on the selected {@link Client}.
|
||||
*/
|
||||
@@ -422,13 +422,13 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
mCurrentClient.executeGarbageCollector();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setEnabledHeapOnSelectedClient(boolean enable) {
|
||||
if (mCurrentClient != null) {
|
||||
mCurrentClient.setHeapUpdateEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setEnabledThreadOnSelectedClient(boolean enable) {
|
||||
if (mCurrentClient != null) {
|
||||
mCurrentClient.setThreadUpdateEnabled(enable);
|
||||
@@ -476,9 +476,9 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
||||
* @see IDeviceChangeListener#deviceConnected(IDevice)
|
||||
*/
|
||||
public void deviceConnected(Device device) {
|
||||
public void deviceConnected(IDevice device) {
|
||||
exec(new Runnable() {
|
||||
public void run() {
|
||||
if (mTree.isDisposed() == false) {
|
||||
@@ -511,11 +511,11 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
||||
* @see IDeviceChangeListener#deviceDisconnected(IDevice)
|
||||
*/
|
||||
public void deviceDisconnected(Device device) {
|
||||
public void deviceDisconnected(IDevice device) {
|
||||
deviceConnected(device);
|
||||
|
||||
|
||||
// just in case, we remove it from the list of devices to expand.
|
||||
synchronized (mDevicesToExpand) {
|
||||
mDevicesToExpand.remove(device);
|
||||
@@ -529,9 +529,9 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
* @param device the device that was updated.
|
||||
* @param changeMask the mask indicating what changed.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceChanged(Device)
|
||||
* @see IDeviceChangeListener#deviceChanged(IDevice)
|
||||
*/
|
||||
public void deviceChanged(final Device device, int changeMask) {
|
||||
public void deviceChanged(final IDevice device, int changeMask) {
|
||||
boolean expand = false;
|
||||
synchronized (mDevicesToExpand) {
|
||||
int index = mDevicesToExpand.indexOf(device);
|
||||
@@ -540,7 +540,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
expand = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final boolean finalExpand = expand;
|
||||
|
||||
exec(new Runnable() {
|
||||
@@ -549,22 +549,22 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
// look if the current device is selected. This is done in case the current
|
||||
// client of this particular device was killed. In this case, we'll need to
|
||||
// manually reselect the device.
|
||||
|
||||
Device selectedDevice = getSelectedDevice();
|
||||
|
||||
IDevice selectedDevice = getSelectedDevice();
|
||||
|
||||
// refresh the device
|
||||
mTreeViewer.refresh(device);
|
||||
|
||||
|
||||
// if the selected device was the changed device and the new selection is
|
||||
// empty, we reselect the device.
|
||||
if (selectedDevice == device && mTreeViewer.getSelection().isEmpty()) {
|
||||
mTreeViewer.setSelection(new TreeSelection(new TreePath(
|
||||
new Object[] { device })));
|
||||
}
|
||||
|
||||
|
||||
// notify the listener of a possible selection change.
|
||||
notifyListeners();
|
||||
|
||||
|
||||
if (finalExpand) {
|
||||
mTreeViewer.setExpandedState(device, true);
|
||||
}
|
||||
@@ -606,7 +606,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
// make sure the device is expanded. Normally the setSelection below
|
||||
// will auto expand, but the children of device may not already exist
|
||||
// at this time. Forcing an expand will make the TreeViewer create them.
|
||||
Device device = client.getDevice();
|
||||
IDevice device = client.getDevice();
|
||||
if (mTreeViewer.getExpandedState(device) == false) {
|
||||
mTreeViewer.setExpandedState(device, true);
|
||||
}
|
||||
@@ -615,11 +615,11 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
TreePath treePath = new TreePath(new Object[] { device, client});
|
||||
TreeSelection treeSelection = new TreeSelection(treePath);
|
||||
mTreeViewer.setSelection(treeSelection);
|
||||
|
||||
|
||||
if (mAdvancedPortSupport) {
|
||||
client.setAsSelectedClient();
|
||||
}
|
||||
|
||||
|
||||
// notify the listener of a possible selection change.
|
||||
notifyListeners(device, client);
|
||||
}
|
||||
@@ -676,7 +676,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
* Returns a display string representing the state of the device.
|
||||
* @param d the device
|
||||
*/
|
||||
private static String getStateString(Device d) {
|
||||
private static String getStateString(IDevice d) {
|
||||
DeviceState deviceState = d.getState();
|
||||
if (deviceState == DeviceState.ONLINE) {
|
||||
return "Online";
|
||||
@@ -704,32 +704,32 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
AndroidDebugBridge.removeClientChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void notifyListeners() {
|
||||
// get the selection
|
||||
TreeItem[] items = mTree.getSelection();
|
||||
|
||||
Client client = null;
|
||||
Device device = null;
|
||||
IDevice device = null;
|
||||
|
||||
if (items.length == 1) {
|
||||
Object object = items[0].getData();
|
||||
if (object instanceof Client) {
|
||||
client = (Client)object;
|
||||
device = client.getDevice();
|
||||
} else if (object instanceof Device) {
|
||||
device = (Device)object;
|
||||
} else if (object instanceof IDevice) {
|
||||
device = (IDevice)object;
|
||||
}
|
||||
}
|
||||
|
||||
notifyListeners(device, client);
|
||||
}
|
||||
|
||||
private void notifyListeners(Device selectedDevice, Client selectedClient) {
|
||||
|
||||
private void notifyListeners(IDevice selectedDevice, Client selectedClient) {
|
||||
if (selectedDevice != mCurrentDevice || selectedClient != mCurrentClient) {
|
||||
mCurrentDevice = selectedDevice;
|
||||
mCurrentClient = selectedClient;
|
||||
|
||||
|
||||
for (IUiSelectionListener listener : mListeners) {
|
||||
// notify the listener with a try/catch-all to make sure this thread won't die
|
||||
// because of an uncaught exception before all the listeners were notified.
|
||||
@@ -740,5 +740,5 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.ddmuilib;
|
||||
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.EmulatorConsole;
|
||||
import com.android.ddmlib.EmulatorConsole.GsmMode;
|
||||
import com.android.ddmlib.EmulatorConsole.GsmStatus;
|
||||
@@ -75,7 +75,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
// default location: Patio outside Charlie's
|
||||
private final static double DEFAULT_LONGITUDE = -122.084095;
|
||||
private final static double DEFAULT_LATITUDE = 37.422006;
|
||||
|
||||
|
||||
private final static String SPEED_FORMAT = "Speed: %1$dX";
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
"EDGE",
|
||||
"UMTS",
|
||||
};
|
||||
|
||||
|
||||
private final static int[] PLAY_SPEEDS = new int[] { 1, 2, 5, 10, 20, 50 };
|
||||
|
||||
private final static String RE_PHONE_NUMBER = "^[+#0-9]+$"; //$NON-NLS-1$
|
||||
@@ -149,7 +149,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
private Button mCancelButton;
|
||||
|
||||
private TabFolder mLocationFolders;
|
||||
|
||||
|
||||
private Button mDecimalButton;
|
||||
private Button mSexagesimalButton;
|
||||
private CoordinateControls mLongitudeControls;
|
||||
@@ -177,7 +177,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
private int mPlayDirection = 1;
|
||||
private int mSpeed;
|
||||
private int mSpeedIndex;
|
||||
|
||||
|
||||
private final SelectionAdapter mDirectionButtonAdapter = new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
@@ -188,7 +188,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
b.setSelection(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// now handle selection change.
|
||||
if (b == mGpxForwardButton || b == mKmlForwardButton) {
|
||||
mGpxBackwardButton.setSelection(false);
|
||||
@@ -196,7 +196,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
mKmlBackwardButton.setSelection(false);
|
||||
mKmlForwardButton.setSelection(true);
|
||||
mPlayDirection = 1;
|
||||
|
||||
|
||||
} else {
|
||||
mGpxBackwardButton.setSelection(true);
|
||||
mGpxForwardButton.setSelection(false);
|
||||
@@ -206,27 +206,27 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private final SelectionAdapter mSpeedButtonAdapter = new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
mSpeedIndex = (mSpeedIndex+1) % PLAY_SPEEDS.length;
|
||||
mSpeed = PLAY_SPEEDS[mSpeedIndex];
|
||||
|
||||
|
||||
mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||
mGpxPlayControls.pack();
|
||||
mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||
mKmlPlayControls.pack();
|
||||
|
||||
|
||||
if (mPlayingThread != null) {
|
||||
mPlayingThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private Composite mKmlPlayControls;
|
||||
private Composite mGpxPlayControls;
|
||||
|
||||
|
||||
|
||||
public EmulatorControlPanel(IImageLoader imageLoader) {
|
||||
mImageLoader = imageLoader;
|
||||
}
|
||||
@@ -274,11 +274,11 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
scollingParent.setMinSize(top.computeSize(r.width, SWT.DEFAULT));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
createRadioControls(top);
|
||||
|
||||
createCallControls(top);
|
||||
|
||||
|
||||
createLocationControls(top);
|
||||
|
||||
doEnable(false);
|
||||
@@ -379,7 +379,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
Label l = new Label(g1, SWT.NONE);
|
||||
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Voice/SMS call/hang up controls
|
||||
* @param top
|
||||
@@ -517,7 +517,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Location controls.
|
||||
* @param top
|
||||
@@ -526,15 +526,15 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
Label l = new Label(top, SWT.NONE);
|
||||
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
l.setText("Location Controls");
|
||||
|
||||
|
||||
mLocationFolders = new TabFolder(top, SWT.NONE);
|
||||
mLocationFolders.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
|
||||
Composite manualLocationComp = new Composite(mLocationFolders, SWT.NONE);
|
||||
TabItem item = new TabItem(mLocationFolders, SWT.NONE);
|
||||
item.setText("Manual");
|
||||
item.setControl(manualLocationComp);
|
||||
|
||||
|
||||
createManualLocationControl(manualLocationComp);
|
||||
|
||||
mPlayImage = mImageLoader.loadImage("play.png", mParent.getDisplay()); // $NON-NLS-1$
|
||||
@@ -544,7 +544,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
item = new TabItem(mLocationFolders, SWT.NONE);
|
||||
item.setText("GPX");
|
||||
item.setControl(gpxLocationComp);
|
||||
|
||||
|
||||
createGpxLocationControl(gpxLocationComp);
|
||||
|
||||
Composite kmlLocationComp = new Composite(mLocationFolders, SWT.NONE);
|
||||
@@ -552,7 +552,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
item = new TabItem(mLocationFolders, SWT.NONE);
|
||||
item.setText("KML");
|
||||
item.setControl(kmlLocationComp);
|
||||
|
||||
|
||||
createKmlLocationControl(kmlLocationComp);
|
||||
}
|
||||
|
||||
@@ -572,63 +572,63 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
// composite to hold and switching between the 2 modes.
|
||||
final Composite content = new Composite(manualLocationComp, SWT.NONE);
|
||||
content.setLayout(sl = new StackLayout());
|
||||
|
||||
|
||||
// decimal display
|
||||
final Composite decimalContent = new Composite(content, SWT.NONE);
|
||||
decimalContent.setLayout(gl = new GridLayout(2, false));
|
||||
gl.marginHeight = gl.marginWidth = 0;
|
||||
|
||||
|
||||
mLongitudeControls = new CoordinateControls();
|
||||
mLatitudeControls = new CoordinateControls();
|
||||
|
||||
|
||||
label = new Label(decimalContent, SWT.NONE);
|
||||
label.setText("Longitude");
|
||||
|
||||
|
||||
mLongitudeControls.createDecimalText(decimalContent);
|
||||
|
||||
|
||||
label = new Label(decimalContent, SWT.NONE);
|
||||
label.setText("Latitude");
|
||||
|
||||
|
||||
mLatitudeControls.createDecimalText(decimalContent);
|
||||
|
||||
// sexagesimal content
|
||||
final Composite sexagesimalContent = new Composite(content, SWT.NONE);
|
||||
sexagesimalContent.setLayout(gl = new GridLayout(7, false));
|
||||
gl.marginHeight = gl.marginWidth = 0;
|
||||
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("Longitude");
|
||||
|
||||
|
||||
mLongitudeControls.createSexagesimalDegreeText(sexagesimalContent);
|
||||
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("\u00B0"); // degree character
|
||||
|
||||
|
||||
mLongitudeControls.createSexagesimalMinuteText(sexagesimalContent);
|
||||
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("'");
|
||||
|
||||
mLongitudeControls.createSexagesimalSecondText(sexagesimalContent);
|
||||
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("\"");
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("Latitude");
|
||||
|
||||
|
||||
mLatitudeControls.createSexagesimalDegreeText(sexagesimalContent);
|
||||
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("\u00B0");
|
||||
|
||||
|
||||
mLatitudeControls.createSexagesimalMinuteText(sexagesimalContent);
|
||||
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("'");
|
||||
|
||||
mLatitudeControls.createSexagesimalSecondText(sexagesimalContent);
|
||||
|
||||
|
||||
label = new Label(sexagesimalContent, SWT.NONE);
|
||||
label.setText("\"");
|
||||
|
||||
@@ -647,7 +647,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
content.layout();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Button sendButton = new Button(manualLocationComp, SWT.PUSH);
|
||||
sendButton.setText("Send");
|
||||
sendButton.addSelectionListener(new SelectionAdapter() {
|
||||
@@ -659,7 +659,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mLongitudeControls.setValue(DEFAULT_LONGITUDE);
|
||||
mLatitudeControls.setValue(DEFAULT_LATITUDE);
|
||||
}
|
||||
@@ -681,7 +681,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
gd.heightHint = 100;
|
||||
mGpxWayPointTable.setHeaderVisible(true);
|
||||
mGpxWayPointTable.setLinesVisible(true);
|
||||
|
||||
|
||||
TableHelper.createTableColumn(mGpxWayPointTable, "Name", SWT.LEFT,
|
||||
"Some Name",
|
||||
PREFS_WAYPOINT_COL_NAME, store);
|
||||
@@ -701,7 +701,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
final TableViewer gpxWayPointViewer = new TableViewer(mGpxWayPointTable);
|
||||
gpxWayPointViewer.setContentProvider(new WayPointContentProvider());
|
||||
gpxWayPointViewer.setLabelProvider(new WayPointLabelProvider());
|
||||
|
||||
|
||||
gpxWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
ISelection selection = event.getSelection();
|
||||
@@ -710,7 +710,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
Object selectedObject = structuredSelection.getFirstElement();
|
||||
if (selectedObject instanceof WayPoint) {
|
||||
WayPoint wayPoint = (WayPoint)selectedObject;
|
||||
|
||||
|
||||
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
||||
processCommandResult(mEmulatorConsole.sendLocation(
|
||||
wayPoint.getLongitude(), wayPoint.getLatitude(),
|
||||
@@ -748,7 +748,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
final TableViewer gpxTrackViewer = new TableViewer(mGpxTrackTable);
|
||||
gpxTrackViewer.setContentProvider(new TrackContentProvider());
|
||||
gpxTrackViewer.setLabelProvider(new TrackLabelProvider());
|
||||
|
||||
|
||||
gpxTrackViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
ISelection selection = event.getSelection();
|
||||
@@ -757,19 +757,19 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
Object selectedObject = structuredSelection.getFirstElement();
|
||||
if (selectedObject instanceof Track) {
|
||||
Track track = (Track)selectedObject;
|
||||
|
||||
|
||||
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
||||
TrackPoint[] points = track.getPoints();
|
||||
processCommandResult(mEmulatorConsole.sendLocation(
|
||||
points[0].getLongitude(), points[0].getLatitude(),
|
||||
points[0].getElevation()));
|
||||
}
|
||||
|
||||
|
||||
mPlayGpxButton.setEnabled(true);
|
||||
mGpxBackwardButton.setEnabled(true);
|
||||
mGpxForwardButton.setEnabled(true);
|
||||
mGpxSpeedButton.setEnabled(true);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -780,7 +780,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
mGpxSpeedButton.setEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mGpxUploadButton.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
@@ -799,7 +799,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mGpxPlayControls = new Composite(gpxLocationComp, SWT.NONE);
|
||||
GridLayout gl;
|
||||
mGpxPlayControls.setLayout(gl = new GridLayout(5, false));
|
||||
@@ -828,14 +828,14 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
mPlayingThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Label separator = new Label(mGpxPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
|
||||
separator.setLayoutData(gd = new GridData(
|
||||
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
|
||||
gd.heightHint = 0;
|
||||
|
||||
|
||||
mGpxBackwardButton = new Button(mGpxPlayControls, SWT.TOGGLE | SWT.FLAT);
|
||||
mGpxBackwardButton.setImage(mImageLoader.loadImage("backward.png", mParent.getDisplay())); // $NON-NLS-1$
|
||||
mGpxBackwardButton.setSelection(false);
|
||||
@@ -852,7 +852,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
|
||||
mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||
mGpxSpeedButton.addSelectionListener(mSpeedButtonAdapter);
|
||||
|
||||
|
||||
mPlayGpxButton.setEnabled(false);
|
||||
mGpxBackwardButton.setEnabled(false);
|
||||
mGpxForwardButton.setEnabled(false);
|
||||
@@ -877,7 +877,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
gd.heightHint = 200;
|
||||
mKmlWayPointTable.setHeaderVisible(true);
|
||||
mKmlWayPointTable.setLinesVisible(true);
|
||||
|
||||
|
||||
TableHelper.createTableColumn(mKmlWayPointTable, "Name", SWT.LEFT,
|
||||
"Some Name",
|
||||
PREFS_WAYPOINT_COL_NAME, store);
|
||||
@@ -911,7 +911,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
KmlParser parser = new KmlParser(fileName);
|
||||
if (parser.parse()) {
|
||||
kmlWayPointViewer.setInput(parser.getWayPoints());
|
||||
|
||||
|
||||
mPlayKmlButton.setEnabled(true);
|
||||
mKmlBackwardButton.setEnabled(true);
|
||||
mKmlForwardButton.setEnabled(true);
|
||||
@@ -920,7 +920,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
kmlWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
ISelection selection = event.getSelection();
|
||||
@@ -929,7 +929,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
Object selectedObject = structuredSelection.getFirstElement();
|
||||
if (selectedObject instanceof WayPoint) {
|
||||
WayPoint wayPoint = (WayPoint)selectedObject;
|
||||
|
||||
|
||||
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
||||
processCommandResult(mEmulatorConsole.sendLocation(
|
||||
wayPoint.getLongitude(), wayPoint.getLatitude(),
|
||||
@@ -939,9 +939,9 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mKmlPlayControls = new Composite(kmlLocationComp, SWT.NONE);
|
||||
GridLayout gl;
|
||||
mKmlPlayControls.setLayout(gl = new GridLayout(5, false));
|
||||
@@ -965,14 +965,14 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
mPlayingThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Label separator = new Label(mKmlPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
|
||||
separator.setLayoutData(gd = new GridData(
|
||||
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
|
||||
gd.heightHint = 0;
|
||||
|
||||
|
||||
mKmlBackwardButton = new Button(mKmlPlayControls, SWT.TOGGLE | SWT.FLAT);
|
||||
mKmlBackwardButton.setImage(mImageLoader.loadImage("backward.png", mParent.getDisplay())); // $NON-NLS-1$
|
||||
mKmlBackwardButton.setSelection(false);
|
||||
@@ -989,7 +989,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
|
||||
mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||
mKmlSpeedButton.addSelectionListener(mSpeedButtonAdapter);
|
||||
|
||||
|
||||
mPlayKmlButton.setEnabled(false);
|
||||
mKmlBackwardButton.setEnabled(false);
|
||||
mKmlForwardButton.setEnabled(false);
|
||||
@@ -1039,7 +1039,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
* Callback on device selection change.
|
||||
* @param device the new selected device
|
||||
*/
|
||||
public void handleNewDevice(Device device) {
|
||||
public void handleNewDevice(IDevice device) {
|
||||
if (mParent.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
@@ -1061,7 +1061,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
// get the gsm status
|
||||
gsm = mEmulatorConsole.getGsmStatus();
|
||||
netstatus = mEmulatorConsole.getNetworkStatus();
|
||||
|
||||
|
||||
if (gsm == null || netstatus == null) {
|
||||
mEmulatorConsole = null;
|
||||
}
|
||||
@@ -1073,7 +1073,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
if (d.isDisposed() == false) {
|
||||
final GsmStatus f_gsm = gsm;
|
||||
final NetworkStatus f_netstatus = netstatus;
|
||||
|
||||
|
||||
d.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
if (f_gsm.voice != GsmMode.UNKNOWN) {
|
||||
@@ -1109,7 +1109,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
synchronized (this) {
|
||||
enable = mEmulatorConsole != null;
|
||||
}
|
||||
|
||||
|
||||
enable(enable);
|
||||
}
|
||||
}
|
||||
@@ -1240,10 +1240,10 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
} catch (SWTException e) {
|
||||
// we're quitting, just ignore
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1264,13 +1264,13 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
try {
|
||||
TrackPoint[] trackPoints = track.getPoints();
|
||||
int count = trackPoints.length;
|
||||
|
||||
|
||||
// get the start index.
|
||||
int start = 0;
|
||||
if (mPlayDirection == -1) {
|
||||
start = count - 1;
|
||||
}
|
||||
|
||||
|
||||
for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
|
||||
if (mPlayingTrack == false) {
|
||||
return;
|
||||
@@ -1299,7 +1299,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
if (delta < 0) {
|
||||
delta = -delta;
|
||||
}
|
||||
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
@@ -1308,7 +1308,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
if (mPlayingTrack == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// we got interrupted, lets make sure we can play
|
||||
do {
|
||||
long waited = System.currentTimeMillis() - startTime;
|
||||
@@ -1351,7 +1351,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
mPlayingThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void playKml(final WayPoint[] trackPoints) {
|
||||
// no need to synchronize this check, the worst that can happen, is we start the thread
|
||||
// for nothing.
|
||||
@@ -1365,13 +1365,13 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
public void run() {
|
||||
try {
|
||||
int count = trackPoints.length;
|
||||
|
||||
|
||||
// get the start index.
|
||||
int start = 0;
|
||||
if (mPlayDirection == -1) {
|
||||
start = count - 1;
|
||||
}
|
||||
|
||||
|
||||
for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
|
||||
if (mPlayingTrack == false) {
|
||||
return;
|
||||
@@ -1399,7 +1399,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
if (delta < 0) {
|
||||
delta = -delta;
|
||||
}
|
||||
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
@@ -1408,7 +1408,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
if (mPlayingTrack == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// we got interrupted, lets make sure we can play
|
||||
do {
|
||||
long waited = System.currentTimeMillis() - startTime;
|
||||
@@ -1449,6 +1449,6 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
||||
};
|
||||
|
||||
mPlayingThread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.ddmuilib;
|
||||
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.Log;
|
||||
import com.android.ddmlib.RawImage;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ScreenShotDialog extends Dialog {
|
||||
private Label mBusyLabel;
|
||||
private Label mImageLabel;
|
||||
private Button mSave;
|
||||
private Device mDevice;
|
||||
private IDevice mDevice;
|
||||
|
||||
|
||||
/**
|
||||
@@ -66,9 +66,9 @@ public class ScreenShotDialog extends Dialog {
|
||||
|
||||
/**
|
||||
* Prepare and display the dialog.
|
||||
* @param device The {@link Device} from which to get the screenshot.
|
||||
* @param device The {@link IDevice} from which to get the screenshot.
|
||||
*/
|
||||
public void open(Device device) {
|
||||
public void open(IDevice device) {
|
||||
mDevice = device;
|
||||
|
||||
Shell parent = getParent();
|
||||
|
||||
@@ -17,20 +17,20 @@
|
||||
package com.android.ddmuilib;
|
||||
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
|
||||
/**
|
||||
* A Panel that requires {@link Device}/{@link Client} selection notifications.
|
||||
*/
|
||||
public abstract class SelectionDependentPanel extends Panel {
|
||||
private Device mCurrentDevice = null;
|
||||
private IDevice mCurrentDevice = null;
|
||||
private Client mCurrentClient = null;
|
||||
|
||||
/**
|
||||
* Returns the current {@link Device}.
|
||||
* @return the current device or null if none are selected.
|
||||
*/
|
||||
protected final Device getCurrentDevice() {
|
||||
protected final IDevice getCurrentDevice() {
|
||||
return mCurrentDevice;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class SelectionDependentPanel extends Panel {
|
||||
* Sent when a new device is selected.
|
||||
* @param selectedDevice the selected device.
|
||||
*/
|
||||
public final void deviceSelected(Device selectedDevice) {
|
||||
public final void deviceSelected(IDevice selectedDevice) {
|
||||
if (selectedDevice != mCurrentDevice) {
|
||||
mCurrentDevice = selectedDevice;
|
||||
deviceSelected();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.ddmuilib.explorer;
|
||||
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.FileListingService;
|
||||
import com.android.ddmlib.IShellOutputReceiver;
|
||||
import com.android.ddmlib.SyncService;
|
||||
@@ -99,7 +99,7 @@ public class DeviceExplorer extends Panel {
|
||||
private Image mPackageImage;
|
||||
private Image mOtherImage;
|
||||
|
||||
private Device mCurrentDevice;
|
||||
private IDevice mCurrentDevice;
|
||||
|
||||
private String mDefaultSave;
|
||||
|
||||
@@ -631,7 +631,7 @@ public class DeviceExplorer extends Panel {
|
||||
/**
|
||||
* Sets the new device to explorer
|
||||
*/
|
||||
public void switchDevice(final Device device) {
|
||||
public void switchDevice(final IDevice device) {
|
||||
if (device != mCurrentDevice) {
|
||||
mCurrentDevice = device;
|
||||
// now we change the input. but we need to do that in the
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.ddmuilib.log.event;
|
||||
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.Log;
|
||||
import com.android.ddmlib.Log.LogLevel;
|
||||
import com.android.ddmlib.log.EventContainer;
|
||||
@@ -80,7 +80,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
|
||||
private IImageLoader mImageLoader;
|
||||
|
||||
private Device mCurrentLoggedDevice;
|
||||
private IDevice mCurrentLoggedDevice;
|
||||
private String mCurrentLogFile;
|
||||
private LogReceiver mCurrentLogReceiver;
|
||||
private EventLogParser mCurrentEventLogParser;
|
||||
@@ -94,7 +94,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
private final ArrayList<EventContainer> mNewEvents = new ArrayList<EventContainer>();
|
||||
/** indicates a pending ui thread display */
|
||||
private boolean mPendingDisplay = false;
|
||||
|
||||
|
||||
/** list of all the custom event displays */
|
||||
private final ArrayList<EventDisplay> mEventDisplays = new ArrayList<EventDisplay>();
|
||||
|
||||
@@ -107,7 +107,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
private ICommonAction mSaveAction;
|
||||
private ICommonAction mLoadAction;
|
||||
private ICommonAction mImportAction;
|
||||
|
||||
|
||||
/** file containing the current log raw data. */
|
||||
private File mTempFile = null;
|
||||
|
||||
@@ -209,10 +209,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
// get the new EventDisplay list
|
||||
mEventDisplays.clear();
|
||||
mEventDisplays.addAll(dialog.getEventDisplays());
|
||||
|
||||
|
||||
// since the list of EventDisplay changed, we store it.
|
||||
saveEventDisplays();
|
||||
|
||||
|
||||
rebuildUi();
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
Log.e("EventLog", e); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the log.
|
||||
* <p/>
|
||||
@@ -240,7 +240,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
Log.e("EventLog", e); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves the content of the event log into a file. The log is saved in the same
|
||||
* binary format than on the device.
|
||||
@@ -254,16 +254,16 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
FileInputStream fis = new FileInputStream(mTempFile);
|
||||
FileOutputStream fos = new FileOutputStream(destFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
|
||||
int count;
|
||||
|
||||
|
||||
while ((count = fis.read(buffer)) != -1) {
|
||||
fos.write(buffer, 0, count);
|
||||
}
|
||||
|
||||
|
||||
fos.close();
|
||||
fis.close();
|
||||
|
||||
|
||||
// now we save the tag file
|
||||
filePath = filePath + TAG_FILE_EXT;
|
||||
mCurrentEventLogParser.saveTags(filePath);
|
||||
@@ -293,16 +293,16 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void importBugReport(String filePath) {
|
||||
try {
|
||||
BugReportImporter importer = new BugReportImporter(filePath);
|
||||
|
||||
|
||||
String[] tags = importer.getTags();
|
||||
String[] log = importer.getLog();
|
||||
|
||||
|
||||
startEventLogFromContent(tags, log);
|
||||
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.logAndDisplay(LogLevel.ERROR, "Import",
|
||||
"Unable to import bug report: " + e.getMessage());
|
||||
@@ -324,7 +324,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
public void deviceSelected() {
|
||||
startEventLog(getCurrentDevice());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.android.ddmlib.AndroidDebugBridge.IClientChangeListener#clientChanged(com.android.ddmlib.Client, int)
|
||||
@@ -359,7 +359,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
// init some store stuff
|
||||
store.setDefault(PREFS_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH);
|
||||
store.setDefault(PREFS_DISPLAY_HEIGHT, DEFAULT_DISPLAY_HEIGHT);
|
||||
|
||||
|
||||
mBottomParentPanel = new ScrolledComposite(parent, SWT.V_SCROLL);
|
||||
mBottomParentPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
mBottomParentPanel.setExpandHorizontal(true);
|
||||
@@ -383,7 +383,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
|
||||
// create the ui
|
||||
createDisplayUi();
|
||||
|
||||
|
||||
return mBottomParentPanel;
|
||||
}
|
||||
|
||||
@@ -402,12 +402,12 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
public void setFocus() {
|
||||
mBottomParentPanel.setFocus();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts a new logcat and set mCurrentLogCat as the current receiver.
|
||||
* @param device the device to connect logcat to.
|
||||
*/
|
||||
private void startEventLog(final Device device) {
|
||||
private void startEventLog(final IDevice device) {
|
||||
if (device == mCurrentLoggedDevice) {
|
||||
return;
|
||||
}
|
||||
@@ -448,10 +448,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
mCurrentEventLogParser = new EventLogParser();
|
||||
mCurrentEventLogParser.init(device);
|
||||
}
|
||||
|
||||
|
||||
// update the event display with the new parser.
|
||||
updateEventDisplays();
|
||||
|
||||
|
||||
// prepare the temp file that will contain the raw data
|
||||
mTempFile = File.createTempFile("android-event-", ".log");
|
||||
|
||||
@@ -464,7 +464,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void startEventLogFromFiles(final String fileName) {
|
||||
// if we have a logcat already running
|
||||
if (mCurrentLogReceiver != null) {
|
||||
@@ -475,7 +475,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
|
||||
// create a new output receiver
|
||||
mCurrentLogReceiver = new LogReceiver(this);
|
||||
|
||||
|
||||
mSaveAction.setEnabled(false);
|
||||
|
||||
// start the logcat in a different thread
|
||||
@@ -493,10 +493,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update the event display with the new parser.
|
||||
updateEventDisplays();
|
||||
|
||||
|
||||
runLocalEventLogService(fileName, mCurrentLogReceiver);
|
||||
} catch (Exception e) {
|
||||
Log.e("EventLog", e);
|
||||
@@ -516,7 +516,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
|
||||
// create a new output receiver
|
||||
mCurrentLogReceiver = new LogReceiver(this);
|
||||
|
||||
|
||||
mSaveAction.setEnabled(false);
|
||||
|
||||
// start the logcat in a different thread
|
||||
@@ -531,10 +531,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update the event display with the new parser.
|
||||
updateEventDisplays();
|
||||
|
||||
|
||||
runLocalEventLogService(log, mCurrentLogReceiver);
|
||||
} catch (Exception e) {
|
||||
Log.e("EventLog", e);
|
||||
@@ -563,7 +563,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
|
||||
resetUI(inUiThread);
|
||||
}
|
||||
|
||||
|
||||
if (mTempFile != null) {
|
||||
mTempFile.delete();
|
||||
mTempFile = null;
|
||||
@@ -593,7 +593,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void resetUiFromUiThread() {
|
||||
synchronized(mLock) {
|
||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||
@@ -618,11 +618,11 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
rowLayout.fill = true;
|
||||
rowLayout.type = SWT.HORIZONTAL;
|
||||
mBottomPanel.setLayout(rowLayout);
|
||||
|
||||
|
||||
IPreferenceStore store = DdmUiPreferences.getStore();
|
||||
int displayWidth = store.getInt(PREFS_DISPLAY_WIDTH);
|
||||
int displayHeight = store.getInt(PREFS_DISPLAY_HEIGHT);
|
||||
|
||||
|
||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||
Control c = eventDisplay.createComposite(mBottomPanel, mCurrentEventLogParser, this);
|
||||
if (c != null) {
|
||||
@@ -631,7 +631,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
rd.width = displayWidth;
|
||||
c.setLayoutData(rd);
|
||||
}
|
||||
|
||||
|
||||
Table table = eventDisplay.getTable();
|
||||
if (table != null) {
|
||||
addTableToFocusListener(table);
|
||||
@@ -642,7 +642,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
mBottomParentPanel.setMinSize(mBottomPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
mBottomParentPanel.layout();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rebuild the display ui.
|
||||
*/
|
||||
@@ -652,26 +652,26 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
// we need to rebuild the ui. First we get rid of it.
|
||||
mBottomPanel.dispose();
|
||||
mBottomPanel = null;
|
||||
|
||||
|
||||
prepareDisplayUi();
|
||||
createDisplayUi();
|
||||
|
||||
|
||||
// and fill it
|
||||
|
||||
|
||||
boolean start_event = false;
|
||||
synchronized (mNewEvents) {
|
||||
mNewEvents.addAll(0, mEvents);
|
||||
|
||||
|
||||
if (mPendingDisplay == false) {
|
||||
mPendingDisplay = true;
|
||||
start_event = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (start_event) {
|
||||
scheduleUIEventHandler();
|
||||
}
|
||||
|
||||
|
||||
Rectangle r = mBottomParentPanel.getClientArea();
|
||||
mBottomParentPanel.setMinSize(mBottomPanel.computeSize(r.width,
|
||||
SWT.DEFAULT));
|
||||
@@ -682,7 +682,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
/**
|
||||
* Processes a new {@link LogEntry} by parsing it with {@link EventLogParser} and displaying it.
|
||||
* @param entry The new log entry
|
||||
* @see LogReceiver.ILogListener#newEntry(LogEntry)
|
||||
* @see LogReceiver.ILogListener#newEntry(LogEntry)
|
||||
*/
|
||||
@WorkerThread
|
||||
public void newEntry(LogEntry entry) {
|
||||
@@ -695,24 +695,24 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@WorkerThread
|
||||
private void handleNewEvent(EventContainer event) {
|
||||
// add the event to the generic list
|
||||
mEvents.add(event);
|
||||
|
||||
|
||||
// add to the list of events that needs to be displayed, and trigger a
|
||||
// new display if needed.
|
||||
boolean start_event = false;
|
||||
synchronized (mNewEvents) {
|
||||
mNewEvents.add(event);
|
||||
|
||||
|
||||
if (mPendingDisplay == false) {
|
||||
mPendingDisplay = true;
|
||||
start_event = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (start_event == false) {
|
||||
// we're done
|
||||
return;
|
||||
@@ -737,7 +737,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
}
|
||||
});
|
||||
} catch (SWTException e) {
|
||||
// if the ui is disposed, do nothing
|
||||
// if the ui is disposed, do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||
eventDisplay.startMultiEventDisplay();
|
||||
}
|
||||
|
||||
|
||||
// display the new events
|
||||
EventContainer event = null;
|
||||
boolean need_to_reloop = false;
|
||||
@@ -803,7 +803,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||
eventDisplay.endMultiEventDisplay();
|
||||
}
|
||||
|
||||
|
||||
// if needed, ask the UI thread to re-run this method.
|
||||
if (need_to_reloop) {
|
||||
scheduleUIEventHandler();
|
||||
@@ -816,10 +816,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
private void loadEventDisplays() {
|
||||
IPreferenceStore store = DdmUiPreferences.getStore();
|
||||
String storage = store.getString(PREFS_EVENT_DISPLAY);
|
||||
|
||||
|
||||
if (storage.length() > 0) {
|
||||
String[] values = storage.split(Pattern.quote(EVENT_DISPLAY_STORAGE_SEPARATOR));
|
||||
|
||||
|
||||
for (String value : values) {
|
||||
EventDisplay eventDisplay = EventDisplay.load(value);
|
||||
if (eventDisplay != null) {
|
||||
@@ -834,10 +834,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
*/
|
||||
private void saveEventDisplays() {
|
||||
IPreferenceStore store = DdmUiPreferences.getStore();
|
||||
|
||||
|
||||
boolean first = true;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||
String storage = eventDisplay.getStorageString();
|
||||
if (storage != null) {
|
||||
@@ -846,7 +846,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
|
||||
|
||||
sb.append(storage);
|
||||
}
|
||||
}
|
||||
@@ -870,7 +870,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||
eventDisplay.setNewLogParser(mCurrentEventLogParser);
|
||||
}
|
||||
|
||||
|
||||
mOptionsAction.setEnabled(true);
|
||||
mClearAction.setEnabled(true);
|
||||
if (mCurrentLogFile == null) {
|
||||
@@ -897,21 +897,21 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
||||
* Runs an event log service out of a local file.
|
||||
* @param fileName the full file name of the local file containing the event log.
|
||||
* @param logReceiver the receiver that will handle the log
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@WorkerThread
|
||||
private void runLocalEventLogService(String fileName, LogReceiver logReceiver)
|
||||
throws IOException {
|
||||
byte[] buffer = new byte[256];
|
||||
|
||||
|
||||
FileInputStream fis = new FileInputStream(fileName);
|
||||
|
||||
|
||||
int count;
|
||||
while ((count = fis.read(buffer)) != -1) {
|
||||
logReceiver.parseNewData(buffer, 0, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@WorkerThread
|
||||
private void runLocalEventLogService(String[] log, LogReceiver currentLogReceiver) {
|
||||
synchronized (mLock) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.ddmuilib.logcat;
|
||||
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.Log;
|
||||
import com.android.ddmlib.MultiLineReceiver;
|
||||
import com.android.ddmlib.Log.LogLevel;
|
||||
@@ -163,13 +163,13 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
private int mFilterMode = FILTER_NONE;
|
||||
|
||||
/** Device currently running logcat */
|
||||
private Device mCurrentLoggedDevice = null;
|
||||
private IDevice mCurrentLoggedDevice = null;
|
||||
|
||||
private ICommonAction mDeleteFilterAction;
|
||||
private ICommonAction mEditFilterAction;
|
||||
|
||||
private ICommonAction[] mLogLevelActions;
|
||||
|
||||
|
||||
/** message data, separated from content for multi line messages */
|
||||
protected static class LogMessageInfo {
|
||||
public LogLevel logLevel;
|
||||
@@ -183,7 +183,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
* log message, to reuse the info regarding level, pid, etc...
|
||||
*/
|
||||
private LogMessageInfo mLastMessageInfo = null;
|
||||
|
||||
|
||||
private boolean mPendingAsyncRefresh = false;
|
||||
|
||||
/** loader for the images. the implementation will varie between standalone
|
||||
@@ -481,7 +481,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
* Starts a new logcat and set mCurrentLogCat as the current receiver.
|
||||
* @param device the device to connect logcat to.
|
||||
*/
|
||||
public void startLogCat(final Device device) {
|
||||
public void startLogCat(final IDevice device) {
|
||||
if (device == mCurrentLoggedDevice) {
|
||||
return;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
stopLogCat(false);
|
||||
mCurrentLoggedDevice = null;
|
||||
}
|
||||
|
||||
|
||||
resetUI(false);
|
||||
|
||||
if (device != null) {
|
||||
@@ -696,7 +696,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
synchronized (mBuffer) {
|
||||
FileDialog dlg = new FileDialog(mParent.getShell(), SWT.SAVE);
|
||||
String fileName;
|
||||
|
||||
|
||||
dlg.setText("Save log...");
|
||||
dlg.setFileName("log.txt");
|
||||
String defaultPath = mDefaultLogSave;
|
||||
@@ -710,7 +710,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
dlg.setFilterExtensions(new String[] {
|
||||
"*.txt"
|
||||
});
|
||||
|
||||
|
||||
fileName = dlg.open();
|
||||
if (fileName != null) {
|
||||
mDefaultLogSave = dlg.getFilterPath();
|
||||
@@ -928,7 +928,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
t.setLinesVisible(false);
|
||||
|
||||
if (mGlobalListener != null) {
|
||||
addTableToFocusListener(t);
|
||||
addTableToFocusListener(t);
|
||||
}
|
||||
|
||||
// create a controllistener that will handle the resizing of all the
|
||||
@@ -1064,7 +1064,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process new Log lines coming from {@link LogCatOuputReceiver}.
|
||||
* Process new Log lines coming from {@link LogCatOuputReceiver}.
|
||||
* @param lines the new lines
|
||||
*/
|
||||
protected void processLogLines(String[] lines) {
|
||||
@@ -1074,10 +1074,10 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
if (lines.length > STRING_BUFFER_LENGTH) {
|
||||
Log.e("LogCat", "Receiving more lines than STRING_BUFFER_LENGTH");
|
||||
}
|
||||
|
||||
|
||||
// parse the lines and create LogMessage that are stored in a temporary list
|
||||
final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>();
|
||||
|
||||
|
||||
synchronized (mBuffer) {
|
||||
for (String line : lines) {
|
||||
// ignore empty lines.
|
||||
@@ -1087,7 +1087,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
if (matcher.matches()) {
|
||||
// this is a header line, parse the header and keep it around.
|
||||
mLastMessageInfo = new LogMessageInfo();
|
||||
|
||||
|
||||
mLastMessageInfo.time = matcher.group(1);
|
||||
mLastMessageInfo.pidString = matcher.group(2);
|
||||
mLastMessageInfo.pid = Integer.valueOf(mLastMessageInfo.pidString);
|
||||
@@ -1097,7 +1097,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
// This is not a header line.
|
||||
// Create a new LogMessage and process it.
|
||||
LogMessage mc = new LogMessage();
|
||||
|
||||
|
||||
if (mLastMessageInfo == null) {
|
||||
// The first line of output wasn't preceded
|
||||
// by a header line; make something up so
|
||||
@@ -1109,34 +1109,34 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
mLastMessageInfo.logLevel = LogLevel.INFO;
|
||||
mLastMessageInfo.tag = "<unknown>"; //$NON-NLS1$
|
||||
}
|
||||
|
||||
|
||||
// If someone printed a log message with
|
||||
// embedded '\n' characters, there will
|
||||
// one header line followed by multiple text lines.
|
||||
// Use the last header that we saw.
|
||||
mc.data = mLastMessageInfo;
|
||||
|
||||
|
||||
// tabs seem to display as only 1 tab so we replace the leading tabs
|
||||
// by 4 spaces.
|
||||
mc.msg = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
||||
// process the new LogMessage.
|
||||
processNewMessage(mc);
|
||||
|
||||
|
||||
// store the new LogMessage
|
||||
newMessages.add(mc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if we don't have a pending Runnable that will do the refresh, we ask the Display
|
||||
// to run one in the UI thread.
|
||||
if (mPendingAsyncRefresh == false) {
|
||||
mPendingAsyncRefresh = true;
|
||||
|
||||
|
||||
try {
|
||||
Display display = mFolders.getDisplay();
|
||||
|
||||
|
||||
// run in sync because this will update the buffer start/end indices
|
||||
display.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
@@ -1165,7 +1165,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
f.flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mDefaultFilter != null) {
|
||||
mDefaultFilter.flush();
|
||||
}
|
||||
@@ -1209,7 +1209,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
// increment the next usable slot index
|
||||
mBufferEnd = (mBufferEnd + 1) % STRING_BUFFER_LENGTH;
|
||||
}
|
||||
|
||||
|
||||
LogMessage oldMessage = null;
|
||||
|
||||
// record the message that was there before
|
||||
@@ -1381,7 +1381,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
initDefaultFilter();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
filter.clear();
|
||||
|
||||
if (mBufferStart != -1) {
|
||||
@@ -1482,13 +1482,13 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
if (mDefaultFilter != null) {
|
||||
mDefaultFilter.resetTempFiltering();
|
||||
}
|
||||
|
||||
|
||||
// now we need to figure out the new temp filtering
|
||||
// split each word
|
||||
String[] segments = text.split(" "); //$NON-NLS-1$
|
||||
|
||||
|
||||
ArrayList<String> keywords = new ArrayList<String>(segments.length);
|
||||
|
||||
|
||||
// loop and look for temp id/tag
|
||||
int tempPid = -1;
|
||||
String tempTag = null;
|
||||
@@ -1511,12 +1511,12 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
keywords.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set the temp filtering in the filters
|
||||
if (tempPid != -1 || tempTag != null || keywords.size() > 0) {
|
||||
String[] keywordsArray = keywords.toArray(
|
||||
new String[keywords.size()]);
|
||||
|
||||
|
||||
for (LogFilter f : mFilters) {
|
||||
if (tempPid != -1) {
|
||||
f.setTempPidFiltering(tempPid);
|
||||
@@ -1526,7 +1526,7 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
}
|
||||
f.setTempKeywordFiltering(keywordsArray);
|
||||
}
|
||||
|
||||
|
||||
if (mDefaultFilter != null) {
|
||||
if (tempPid != -1) {
|
||||
mDefaultFilter.setTempPidFiltering(tempPid);
|
||||
@@ -1535,10 +1535,10 @@ public class LogPanel extends SelectionDependentPanel {
|
||||
mDefaultFilter.setTempTagFiltering(tempTag);
|
||||
}
|
||||
mDefaultFilter.setTempKeywordFiltering(keywordsArray);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
initFilter(mCurrentFilter);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user