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
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.ddms;
|
package com.android.ddms;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.DebugPortManager.IDebugPortProvider;
|
import com.android.ddmlib.DebugPortManager.IDebugPortProvider;
|
||||||
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
@@ -53,15 +53,15 @@ public class DebugPortProvider implements IDebugPortProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a static debug port for the specified application running on the
|
* Returns a static debug port for the specified application running on the
|
||||||
* specified {@link Device}.
|
* specified {@link IDevice}.
|
||||||
* @param device The device the application is running on.
|
* @param device The device the application is running on.
|
||||||
* @param appName The application name, as defined in the
|
* @param appName The application name, as defined in the
|
||||||
* AndroidManifest.xml package attribute.
|
* AndroidManifest.xml package attribute.
|
||||||
* @return The static debug port or {@link #NO_STATIC_PORT} if there is none setup.
|
* @return The static debug port or {@link #NO_STATIC_PORT} if there is none setup.
|
||||||
*
|
*
|
||||||
* @see IDebugPortProvider#getPort(Device, String)
|
* @see IDebugPortProvider#getPort(IDevice, String)
|
||||||
*/
|
*/
|
||||||
public int getPort(Device device, String appName) {
|
public int getPort(IDevice device, String appName) {
|
||||||
if (mMap != null) {
|
if (mMap != null) {
|
||||||
Map<String, Integer> deviceMap = mMap.get(device.getSerialNumber());
|
Map<String, Integer> deviceMap = mMap.get(device.getSerialNumber());
|
||||||
if (deviceMap != null) {
|
if (deviceMap != null) {
|
||||||
@@ -107,7 +107,7 @@ public class DebugPortProvider implements IDebugPortProvider {
|
|||||||
if (entry.length == 3) {
|
if (entry.length == 3) {
|
||||||
deviceName = entry[2];
|
deviceName = entry[2];
|
||||||
} else {
|
} else {
|
||||||
deviceName = Device.FIRST_EMULATOR_SN;
|
deviceName = IDevice.FIRST_EMULATOR_SN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the device map
|
// get the device map
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package com.android.ddms;
|
package com.android.ddms;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.IShellOutputReceiver;
|
import com.android.ddmlib.IShellOutputReceiver;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class DeviceCommandDialog extends Dialog {
|
|||||||
* Prepare and display the dialog.
|
* Prepare and display the dialog.
|
||||||
* @param currentDevice
|
* @param currentDevice
|
||||||
*/
|
*/
|
||||||
public void open(Device currentDevice) {
|
public void open(IDevice currentDevice) {
|
||||||
Shell parent = getParent();
|
Shell parent = getParent();
|
||||||
Shell shell = new Shell(parent, getStyle());
|
Shell shell = new Shell(parent, getStyle());
|
||||||
shell.setText("Remote Command");
|
shell.setText("Remote Command");
|
||||||
@@ -219,13 +219,13 @@ public class DeviceCommandDialog extends Dialog {
|
|||||||
private String mCommand;
|
private String mCommand;
|
||||||
private Text mText;
|
private Text mText;
|
||||||
private int mResult;
|
private int mResult;
|
||||||
private Device mDevice;
|
private IDevice mDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor; pass in the text widget that will receive the output.
|
* Constructor; pass in the text widget that will receive the output.
|
||||||
* @param device
|
* @param device
|
||||||
*/
|
*/
|
||||||
public Gatherer(Shell shell, Device device, String command, Text text) {
|
public Gatherer(Shell shell, IDevice device, String command, Text text) {
|
||||||
mShell = shell;
|
mShell = shell;
|
||||||
mDevice = device;
|
mDevice = device;
|
||||||
mCommand = command;
|
mCommand = command;
|
||||||
@@ -307,7 +307,7 @@ public class DeviceCommandDialog extends Dialog {
|
|||||||
* We have to run the command in a thread so that the UI continues
|
* We have to run the command in a thread so that the UI continues
|
||||||
* to work.
|
* to work.
|
||||||
*/
|
*/
|
||||||
private void executeCommand(Shell shell, Device device) {
|
private void executeCommand(Shell shell, IDevice device) {
|
||||||
Gatherer gath = new Gatherer(shell, device, commandString(), mText);
|
Gatherer gath = new Gatherer(shell, device, commandString(), mText);
|
||||||
gath.start();
|
gath.start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.ddms;
|
package com.android.ddms;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.ModifyEvent;
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
@@ -75,7 +75,7 @@ public class StaticPortEditDialog extends Dialog {
|
|||||||
public StaticPortEditDialog(Shell parent, ArrayList<Integer> ports) {
|
public StaticPortEditDialog(Shell parent, ArrayList<Integer> ports) {
|
||||||
super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
|
super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
|
||||||
mPorts = ports;
|
mPorts = ports;
|
||||||
mDeviceSn = Device.FIRST_EMULATOR_SN;
|
mDeviceSn = IDevice.FIRST_EMULATOR_SN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package com.android.ddms;
|
|||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Client;
|
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;
|
||||||
import com.android.ddmlib.Log.ILogOutput;
|
import com.android.ddmlib.Log.ILogOutput;
|
||||||
import com.android.ddmlib.Log.LogLevel;
|
import com.android.ddmlib.Log.LogLevel;
|
||||||
@@ -90,7 +90,7 @@ import java.util.ArrayList;
|
|||||||
/**
|
/**
|
||||||
* This acts as the UI builder. This cannot be its own thread since this prevent using AWT in an
|
* This acts as the UI builder. This cannot be its own thread since this prevent using AWT in an
|
||||||
* SWT application. So this class mainly builds the ui, and manages communication between the panels
|
* SWT application. So this class mainly builds the ui, and manages communication between the panels
|
||||||
* when {@link Device} / {@link Client} selection changes.
|
* when {@link IDevice} / {@link Client} selection changes.
|
||||||
*/
|
*/
|
||||||
public class UIThread implements IUiSelectionListener {
|
public class UIThread implements IUiSelectionListener {
|
||||||
/*
|
/*
|
||||||
@@ -153,7 +153,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
// the table we show in the left-hand pane
|
// the table we show in the left-hand pane
|
||||||
private DevicePanel mDevicePanel;
|
private DevicePanel mDevicePanel;
|
||||||
|
|
||||||
private Device mCurrentDevice = null;
|
private IDevice mCurrentDevice = null;
|
||||||
private Client mCurrentClient = null;
|
private Client mCurrentClient = null;
|
||||||
|
|
||||||
// status line at the bottom of the app window
|
// status line at the bottom of the app window
|
||||||
@@ -166,7 +166,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
private ToolItem mTBCauseGc;
|
private ToolItem mTBCauseGc;
|
||||||
|
|
||||||
private ImageLoader mDdmsImageLoader;
|
private ImageLoader mDdmsImageLoader;
|
||||||
private ImageLoader mDdmuiLibImageLoader;
|
private ImageLoader mDdmuiLibImageLoader;
|
||||||
|
|
||||||
private final class FilterStorage implements ILogFilterStorageManager {
|
private final class FilterStorage implements ILogFilterStorageManager {
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
private Shell mExplorerShell = null;
|
private Shell mExplorerShell = null;
|
||||||
|
|
||||||
private EmulatorControlPanel mEmulatorPanel;
|
private EmulatorControlPanel mEmulatorPanel;
|
||||||
|
|
||||||
private EventLogPanel mEventLogPanel;
|
private EventLogPanel mEventLogPanel;
|
||||||
|
|
||||||
private class TableFocusListener implements ITableFocusListener {
|
private class TableFocusListener implements ITableFocusListener {
|
||||||
@@ -333,7 +333,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
// create the image loaders for DDMS and DDMUILIB
|
// create the image loaders for DDMS and DDMUILIB
|
||||||
mDdmsImageLoader = new ImageLoader(this.getClass());
|
mDdmsImageLoader = new ImageLoader(this.getClass());
|
||||||
mDdmuiLibImageLoader = new ImageLoader(DevicePanel.class);
|
mDdmuiLibImageLoader = new ImageLoader(DevicePanel.class);
|
||||||
|
|
||||||
shell.setImage(ImageHelper.loadImage(mDdmsImageLoader, mDisplay,
|
shell.setImage(ImageHelper.loadImage(mDdmsImageLoader, mDisplay,
|
||||||
"ddms-icon.png", //$NON-NLS-1$
|
"ddms-icon.png", //$NON-NLS-1$
|
||||||
100, 50, null));
|
100, 50, null));
|
||||||
@@ -883,7 +883,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
p.setTableFocusListener(mTableListener);
|
p.setTableFocusListener(mTableListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mStatusLine.setText("");
|
mStatusLine.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,7 +892,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
*/
|
*/
|
||||||
private void createDevicePanelToolBar(ToolBar toolBar) {
|
private void createDevicePanelToolBar(ToolBar toolBar) {
|
||||||
Display display = toolBar.getDisplay();
|
Display display = toolBar.getDisplay();
|
||||||
|
|
||||||
// add "show thread updates" button
|
// add "show thread updates" button
|
||||||
mTBShowThreadUpdates = new ToolItem(toolBar, SWT.CHECK);
|
mTBShowThreadUpdates = new ToolItem(toolBar, SWT.CHECK);
|
||||||
mTBShowThreadUpdates.setImage(ImageHelper.loadImage(mDdmuiLibImageLoader, display,
|
mTBShowThreadUpdates.setImage(ImageHelper.loadImage(mDdmuiLibImageLoader, display,
|
||||||
@@ -949,7 +949,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
mDevicePanel.killSelectedClient();
|
mDevicePanel.killSelectedClient();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new ToolItem(toolBar, SWT.SEPARATOR);
|
new ToolItem(toolBar, SWT.SEPARATOR);
|
||||||
|
|
||||||
// add "cause GC" button
|
// add "cause GC" button
|
||||||
@@ -1130,7 +1130,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
|
|
||||||
mClearAction = new ToolItemAction(toolBar, SWT.PUSH);
|
mClearAction = new ToolItemAction(toolBar, SWT.PUSH);
|
||||||
mClearAction.item.setToolTipText("Clear Log");
|
mClearAction.item.setToolTipText("Clear Log");
|
||||||
|
|
||||||
mClearAction.item.setImage(ImageHelper.loadImage(mDdmuiLibImageLoader, mDisplay,
|
mClearAction.item.setImage(ImageHelper.loadImage(mDdmuiLibImageLoader, mDisplay,
|
||||||
"clear.png", //$NON-NLS-1$
|
"clear.png", //$NON-NLS-1$
|
||||||
DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
|
DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
|
||||||
@@ -1239,12 +1239,12 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
item = new TabItem(tabFolder, SWT.NONE);
|
item = new TabItem(tabFolder, SWT.NONE);
|
||||||
item.setText("Event Log");
|
item.setText("Event Log");
|
||||||
item.setToolTipText("Event Log");
|
item.setToolTipText("Event Log");
|
||||||
|
|
||||||
// create the composite that will hold the toolbar and the event log panel.
|
// create the composite that will hold the toolbar and the event log panel.
|
||||||
Composite eventLogTopComposite = new Composite(tabFolder, SWT.NONE);
|
Composite eventLogTopComposite = new Composite(tabFolder, SWT.NONE);
|
||||||
item.setControl(eventLogTopComposite);
|
item.setControl(eventLogTopComposite);
|
||||||
eventLogTopComposite.setLayout(new GridLayout(1, false));
|
eventLogTopComposite.setLayout(new GridLayout(1, false));
|
||||||
|
|
||||||
// create the toolbar and the actions
|
// create the toolbar and the actions
|
||||||
ToolBar toolbar = new ToolBar(eventLogTopComposite, SWT.HORIZONTAL);
|
ToolBar toolbar = new ToolBar(eventLogTopComposite, SWT.HORIZONTAL);
|
||||||
toolbar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
toolbar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
@@ -1260,7 +1260,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
clearAction.item.setImage(ImageHelper.loadImage(mDdmuiLibImageLoader, comp.getDisplay(),
|
clearAction.item.setImage(ImageHelper.loadImage(mDdmuiLibImageLoader, comp.getDisplay(),
|
||||||
"clear.png", //$NON-NLS-1$
|
"clear.png", //$NON-NLS-1$
|
||||||
DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
|
DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
|
||||||
|
|
||||||
new ToolItem(toolbar, SWT.SEPARATOR);
|
new ToolItem(toolbar, SWT.SEPARATOR);
|
||||||
|
|
||||||
ToolItemAction saveAction = new ToolItemAction(toolbar, SWT.PUSH);
|
ToolItemAction saveAction = new ToolItemAction(toolbar, SWT.PUSH);
|
||||||
@@ -1283,7 +1283,7 @@ public class UIThread implements IUiSelectionListener {
|
|||||||
|
|
||||||
// create the event log panel
|
// create the event log panel
|
||||||
mEventLogPanel = new EventLogPanel(mDdmuiLibImageLoader);
|
mEventLogPanel = new EventLogPanel(mDdmuiLibImageLoader);
|
||||||
|
|
||||||
// set the external actions
|
// set the external actions
|
||||||
mEventLogPanel.setActions(optionsAction, clearAction, saveAction, loadAction,
|
mEventLogPanel.setActions(optionsAction, clearAction, saveAction, loadAction,
|
||||||
importBugAction);
|
importBugAction);
|
||||||
@@ -1450,13 +1450,13 @@ public class UIThread implements 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 selectedDevice the selected device. If null, no devices are selected.
|
||||||
* @param selectedClient The selected client. If null, no clients are selected.
|
* @param selectedClient The selected client. If null, no clients are selected.
|
||||||
*
|
*
|
||||||
* @see IUiSelectionListener
|
* @see IUiSelectionListener
|
||||||
*/
|
*/
|
||||||
public void selectionChanged(Device selectedDevice, Client selectedClient) {
|
public void selectionChanged(IDevice selectedDevice, Client selectedClient) {
|
||||||
if (mCurrentDevice != selectedDevice) {
|
if (mCurrentDevice != selectedDevice) {
|
||||||
mCurrentDevice = selectedDevice;
|
mCurrentDevice = selectedDevice;
|
||||||
for (TablePanel panel : mPanels) {
|
for (TablePanel panel : mPanels) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import java.nio.channels.SocketChannel;
|
|||||||
/**
|
/**
|
||||||
* Helper class to handle requests and connections to adb.
|
* Helper class to handle requests and connections to adb.
|
||||||
* <p/>{@link DebugBridgeServer} is the public API to connection to adb, while {@link AdbHelper}
|
* <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,
|
* <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.
|
* but seems like overkill for what we're doing here.
|
||||||
*/
|
*/
|
||||||
@@ -272,14 +272,14 @@ final class AdbHelper {
|
|||||||
try {
|
try {
|
||||||
adbChan = SocketChannel.open(adbSockAddr);
|
adbChan = SocketChannel.open(adbSockAddr);
|
||||||
adbChan.configureBlocking(false);
|
adbChan.configureBlocking(false);
|
||||||
|
|
||||||
// if the device is not -1, then we first tell adb we're looking to talk
|
// if the device is not -1, then we first tell adb we're looking to talk
|
||||||
// to a specific device
|
// to a specific device
|
||||||
setDevice(adbChan, device);
|
setDevice(adbChan, device);
|
||||||
|
|
||||||
if (write(adbChan, request) == false)
|
if (write(adbChan, request) == false)
|
||||||
throw new IOException("failed asking for frame buffer");
|
throw new IOException("failed asking for frame buffer");
|
||||||
|
|
||||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||||
if (!resp.ioSuccess || !resp.okay) {
|
if (!resp.ioSuccess || !resp.okay) {
|
||||||
Log.w("ddms", "Got timeout or unhappy response from ADB fb req: "
|
Log.w("ddms", "Got timeout or unhappy response from ADB fb req: "
|
||||||
@@ -287,7 +287,7 @@ final class AdbHelper {
|
|||||||
adbChan.close();
|
adbChan.close();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply = new byte[16];
|
reply = new byte[16];
|
||||||
if (read(adbChan, reply) == false) {
|
if (read(adbChan, reply) == false) {
|
||||||
Log.w("ddms", "got partial reply from ADB fb:");
|
Log.w("ddms", "got partial reply from ADB fb:");
|
||||||
@@ -297,19 +297,19 @@ final class AdbHelper {
|
|||||||
}
|
}
|
||||||
ByteBuffer buf = ByteBuffer.wrap(reply);
|
ByteBuffer buf = ByteBuffer.wrap(reply);
|
||||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
imageParams.bpp = buf.getInt();
|
imageParams.bpp = buf.getInt();
|
||||||
imageParams.size = buf.getInt();
|
imageParams.size = buf.getInt();
|
||||||
imageParams.width = buf.getInt();
|
imageParams.width = buf.getInt();
|
||||||
imageParams.height = buf.getInt();
|
imageParams.height = buf.getInt();
|
||||||
|
|
||||||
Log.d("ddms", "image params: bpp=" + imageParams.bpp + ", size="
|
Log.d("ddms", "image params: bpp=" + imageParams.bpp + ", size="
|
||||||
+ imageParams.size + ", width=" + imageParams.width
|
+ imageParams.size + ", width=" + imageParams.width
|
||||||
+ ", height=" + imageParams.height);
|
+ ", height=" + imageParams.height);
|
||||||
|
|
||||||
if (write(adbChan, nudge) == false)
|
if (write(adbChan, nudge) == false)
|
||||||
throw new IOException("failed nudging");
|
throw new IOException("failed nudging");
|
||||||
|
|
||||||
reply = new byte[imageParams.size];
|
reply = new byte[imageParams.size];
|
||||||
if (read(adbChan, reply) == false) {
|
if (read(adbChan, reply) == false) {
|
||||||
Log.w("ddms", "got truncated reply from ADB fb data");
|
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,
|
public static void runLogService(InetSocketAddress adbSockAddr, Device device, String logName,
|
||||||
LogReceiver rcvr) throws IOException {
|
LogReceiver rcvr) throws IOException {
|
||||||
SocketChannel adbChan = null;
|
SocketChannel adbChan = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
adbChan = SocketChannel.open(adbSockAddr);
|
adbChan = SocketChannel.open(adbSockAddr);
|
||||||
adbChan.configureBlocking(false);
|
adbChan.configureBlocking(false);
|
||||||
|
|
||||||
// if the device is not -1, then we first tell adb we're looking to talk
|
// if the device is not -1, then we first tell adb we're looking to talk
|
||||||
// to a specific device
|
// to a specific device
|
||||||
setDevice(adbChan, device);
|
setDevice(adbChan, device);
|
||||||
|
|
||||||
byte[] request = formAdbRequest("log:" + logName);
|
byte[] request = formAdbRequest("log:" + logName);
|
||||||
if (write(adbChan, request) == false) {
|
if (write(adbChan, request) == false) {
|
||||||
throw new IOException("failed to submit the log command");
|
throw new IOException("failed to submit the log command");
|
||||||
}
|
}
|
||||||
|
|
||||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||||
if (!resp.ioSuccess || !resp.okay) {
|
if (!resp.ioSuccess || !resp.okay) {
|
||||||
throw new IOException("Device rejected log command: " + resp.message);
|
throw new IOException("Device rejected log command: " + resp.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = new byte[16384];
|
byte[] data = new byte[16384];
|
||||||
ByteBuffer buf = ByteBuffer.wrap(data);
|
ByteBuffer buf = ByteBuffer.wrap(data);
|
||||||
while (true) {
|
while (true) {
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (rcvr != null && rcvr.isCancelled()) {
|
if (rcvr != null && rcvr.isCancelled()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = adbChan.read(buf);
|
count = adbChan.read(buf);
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
break;
|
break;
|
||||||
@@ -465,7 +465,7 @@ final class AdbHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a port forwarding between a local and a remote port.
|
* Creates a port forwarding between a local and a remote port.
|
||||||
* @param adbSockAddr the socket address to connect to adb
|
* @param adbSockAddr the socket address to connect to adb
|
||||||
@@ -473,7 +473,7 @@ final class AdbHelper {
|
|||||||
* @param localPort the local port to forward
|
* @param localPort the local port to forward
|
||||||
* @param remotePort the remote port.
|
* @param remotePort the remote port.
|
||||||
* @return <code>true</code> if success.
|
* @return <code>true</code> if success.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static boolean createForward(InetSocketAddress adbSockAddr, Device device, int localPort,
|
public static boolean createForward(InetSocketAddress adbSockAddr, Device device, int localPort,
|
||||||
int remotePort) throws IOException {
|
int remotePort) throws IOException {
|
||||||
@@ -482,15 +482,15 @@ final class AdbHelper {
|
|||||||
try {
|
try {
|
||||||
adbChan = SocketChannel.open(adbSockAddr);
|
adbChan = SocketChannel.open(adbSockAddr);
|
||||||
adbChan.configureBlocking(false);
|
adbChan.configureBlocking(false);
|
||||||
|
|
||||||
byte[] request = formAdbRequest(String.format(
|
byte[] request = formAdbRequest(String.format(
|
||||||
"host-serial:%1$s:forward:tcp:%2$d;tcp:%3$d", //$NON-NLS-1$
|
"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) {
|
if (write(adbChan, request) == false) {
|
||||||
throw new IOException("failed to submit the forward command.");
|
throw new IOException("failed to submit the forward command.");
|
||||||
}
|
}
|
||||||
|
|
||||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||||
if (!resp.ioSuccess || !resp.okay) {
|
if (!resp.ioSuccess || !resp.okay) {
|
||||||
throw new IOException("Device rejected command: " + resp.message);
|
throw new IOException("Device rejected command: " + resp.message);
|
||||||
@@ -500,7 +500,7 @@ final class AdbHelper {
|
|||||||
adbChan.close();
|
adbChan.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,15 +520,15 @@ final class AdbHelper {
|
|||||||
try {
|
try {
|
||||||
adbChan = SocketChannel.open(adbSockAddr);
|
adbChan = SocketChannel.open(adbSockAddr);
|
||||||
adbChan.configureBlocking(false);
|
adbChan.configureBlocking(false);
|
||||||
|
|
||||||
byte[] request = formAdbRequest(String.format(
|
byte[] request = formAdbRequest(String.format(
|
||||||
"host-serial:%1$s:killforward:tcp:%2$d;tcp:%3$d", //$NON-NLS-1$
|
"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)) {
|
if (!write(adbChan, request)) {
|
||||||
throw new IOException("failed to submit the remove forward command.");
|
throw new IOException("failed to submit the remove forward command.");
|
||||||
}
|
}
|
||||||
|
|
||||||
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
|
||||||
if (!resp.ioSuccess || !resp.okay) {
|
if (!resp.ioSuccess || !resp.okay) {
|
||||||
throw new IOException("Device rejected command: " + resp.message);
|
throw new IOException("Device rejected command: " + resp.message);
|
||||||
@@ -563,7 +563,7 @@ final class AdbHelper {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads from the socket until the array is filled, or no more data is coming (because
|
* Reads from the socket until the array is filled, or no more data is coming (because
|
||||||
* the socket closed or the timeout expired).
|
* the socket closed or the timeout expired).
|
||||||
@@ -572,7 +572,7 @@ final class AdbHelper {
|
|||||||
* mode for timeouts to work
|
* mode for timeouts to work
|
||||||
* @param data the buffer to store the read data into.
|
* @param data the buffer to store the read data into.
|
||||||
* @return "true" if all data was read.
|
* @return "true" if all data was read.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
static boolean read(SocketChannel chan, byte[] data) {
|
static boolean read(SocketChannel chan, byte[] data) {
|
||||||
try {
|
try {
|
||||||
@@ -581,7 +581,7 @@ final class AdbHelper {
|
|||||||
Log.d("ddms", "readAll: IOException: " + e.getMessage());
|
Log.d("ddms", "readAll: IOException: " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,7 +597,7 @@ final class AdbHelper {
|
|||||||
* @param data the buffer to store the read data into.
|
* @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 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".
|
* @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 {
|
static void read(SocketChannel chan, byte[] data, int length, int timeout) throws IOException {
|
||||||
ByteBuffer buf = ByteBuffer.wrap(data, 0, length != -1 ? length : data.length);
|
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 data the buffer to send.
|
||||||
* @param length the length to write or -1 to send the whole buffer.
|
* @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".
|
* @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)
|
static void write(SocketChannel chan, byte[] data, int length, int timeout)
|
||||||
throws IOException {
|
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
|
// if the device is not -1, then we first tell adb we're looking to talk
|
||||||
// to a specific device
|
// to a specific device
|
||||||
if (device != null) {
|
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);
|
byte[] device_query = formAdbRequest(msg);
|
||||||
|
|
||||||
if (write(adbChan, device_query) == false)
|
if (write(adbChan, device_query) == false)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public final class AndroidDebugBridge {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes which implement this interface provide methods that deal
|
* 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 {
|
public interface IDeviceChangeListener {
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +116,7 @@ public final class AndroidDebugBridge {
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @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}.
|
* 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.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @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.
|
* 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.
|
* This is sent from a non UI thread.
|
||||||
* @param device the device that was updated.
|
* @param device the device that was updated.
|
||||||
* @param changeMask the mask describing what changed. It can contain any of the following
|
* @param changeMask the mask describing what changed. It can contain any of the following
|
||||||
* values: {@link Device#CHANGE_BUILD_INFO}, {@link Device#CHANGE_STATE},
|
* values: {@link IDevice#CHANGE_BUILD_INFO}, {@link IDevice#CHANGE_STATE},
|
||||||
* {@link Device#CHANGE_CLIENT_LIST}
|
* {@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
|
* 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() {
|
static boolean getClientSupport() {
|
||||||
return sClientSupport;
|
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,
|
* 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.
|
* by sending it one of the messages defined in the {@link IDeviceChangeListener} interface.
|
||||||
* @param listener The listener which should be notified.
|
* @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
|
* 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.
|
* list changed.
|
||||||
* @param listener The listener which should no longer be notified.
|
* @param listener The listener which should no longer be notified.
|
||||||
*/
|
*/
|
||||||
@@ -446,23 +446,23 @@ public final class AndroidDebugBridge {
|
|||||||
* Returns the devices.
|
* Returns the devices.
|
||||||
* @see #hasInitialDeviceList()
|
* @see #hasInitialDeviceList()
|
||||||
*/
|
*/
|
||||||
public Device[] getDevices() {
|
public IDevice[] getDevices() {
|
||||||
synchronized (sLock) {
|
synchronized (sLock) {
|
||||||
if (mDeviceMonitor != null) {
|
if (mDeviceMonitor != null) {
|
||||||
return mDeviceMonitor.getDevices();
|
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.
|
* 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
|
* <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
|
* 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()}.
|
* 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.
|
* {@link IDeviceChangeListener} object.
|
||||||
*/
|
*/
|
||||||
public boolean hasInitialDeviceList() {
|
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/>
|
* <p/>
|
||||||
* The notification of the listeners is done in a synchronized block. It is important to
|
* 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.
|
* {@link #getDevices()} which use internal locks.
|
||||||
* <p/>
|
* <p/>
|
||||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
* 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()}.
|
* 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()
|
* @see #getLock()
|
||||||
*/
|
*/
|
||||||
void deviceConnected(Device device) {
|
void deviceConnected(IDevice device) {
|
||||||
// because the listeners could remove themselves from the list while processing
|
// 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
|
// their event callback, we make a copy of the list and iterate on it instead of
|
||||||
// the main list.
|
// 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/>
|
* <p/>
|
||||||
* The notification of the listeners is done in a synchronized block. It is important to
|
* 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.
|
* {@link #getDevices()} which use internal locks.
|
||||||
* <p/>
|
* <p/>
|
||||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
* 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()}.
|
* 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()
|
* @see #getLock()
|
||||||
*/
|
*/
|
||||||
void deviceDisconnected(Device device) {
|
void deviceDisconnected(IDevice device) {
|
||||||
// because the listeners could remove themselves from the list while processing
|
// 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
|
// their event callback, we make a copy of the list and iterate on it instead of
|
||||||
// the main list.
|
// 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/>
|
* <p/>
|
||||||
* The notification of the listeners is done in a synchronized block. It is important to
|
* 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.
|
* {@link #getDevices()} which use internal locks.
|
||||||
* <p/>
|
* <p/>
|
||||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
* 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()}.
|
* 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()
|
* @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
|
// 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
|
// their event callback, we make a copy of the list and iterate on it instead of
|
||||||
// the main list.
|
// the main list.
|
||||||
@@ -830,11 +830,11 @@ public final class AndroidDebugBridge {
|
|||||||
* Notify the listener of a modified {@link Client}.
|
* Notify the listener of a modified {@link Client}.
|
||||||
* <p/>
|
* <p/>
|
||||||
* The notification of the listeners is done in a synchronized block. It is important to
|
* 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.
|
* {@link #getDevices()} which use internal locks.
|
||||||
* <p/>
|
* <p/>
|
||||||
* For this reason, any call to this method from a method of {@link DeviceMonitor},
|
* 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()}.
|
* the {@link AndroidDebugBridge} lock. Access to this lock is done through {@link #getLock()}.
|
||||||
* @param device the modified <code>Client</code>.
|
* @param device the modified <code>Client</code>.
|
||||||
* @param changeMask the mask indicating what changed in the <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) {
|
protected static Client checkDebuggerPortForAppName(Client client, String appName) {
|
||||||
IDebugPortProvider provider = DebugPortManager.getProvider();
|
IDebugPortProvider provider = DebugPortManager.getProvider();
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
Device device = client.getDevice();
|
Device device = client.getDeviceImpl();
|
||||||
int newPort = provider.getPort(device, appName);
|
int newPort = provider.getPort(device, appName);
|
||||||
|
|
||||||
if (newPort != IDebugPortProvider.NO_STATIC_PORT &&
|
if (newPort != IDebugPortProvider.NO_STATIC_PORT &&
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public class Client {
|
|||||||
mConnState = ST_INIT;
|
mConnState = ST_INIT;
|
||||||
|
|
||||||
mClientData = new ClientData(pid);
|
mClientData = new ClientData(pid);
|
||||||
|
|
||||||
mThreadUpdateEnabled = DdmPreferences.getInitialThreadUpdate();
|
mThreadUpdateEnabled = DdmPreferences.getInitialThreadUpdate();
|
||||||
mHeapUpdateEnabled = DdmPreferences.getInitialHeapUpdate();
|
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;
|
return mDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +244,7 @@ public class Client {
|
|||||||
|
|
||||||
update(CHANGE_THREAD_MODE);
|
update(CHANGE_THREAD_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the thread update is enabled.
|
* Returns whether the thread update is enabled.
|
||||||
*/
|
*/
|
||||||
@@ -268,7 +274,7 @@ public class Client {
|
|||||||
public void requestThreadStackTrace(int threadId) {
|
public void requestThreadStackTrace(int threadId) {
|
||||||
HandleThread.requestThreadStackCallRefresh(this, threadId);
|
HandleThread.requestThreadStackCallRefresh(this, threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables the heap update.
|
* Enables or disables the heap update.
|
||||||
* <p/>If <code>true</code>, any GC will cause the client to send its heap information.
|
* <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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables the Allocation tracker for this client.
|
* Enables or disables the Allocation tracker for this client.
|
||||||
* <p/>If enabled, the VM will start tracking allocation informations. A call to
|
* <p/>If enabled, the VM will start tracking allocation informations. A call to
|
||||||
@@ -336,7 +342,7 @@ public class Client {
|
|||||||
Log.e("ddmlib", e);
|
Log.e("ddmlib", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a request to the VM to send the enable status of the allocation tracking.
|
* Sends a request to the VM to send the enable status of the allocation tracking.
|
||||||
* This is asynchronous.
|
* This is asynchronous.
|
||||||
@@ -350,9 +356,9 @@ public class Client {
|
|||||||
HandleHeap.sendREAQ(this);
|
HandleHeap.sendREAQ(this);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e("ddmlib", e);
|
Log.e("ddmlib", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a request to the VM to send the information about all the allocations that have
|
* 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>
|
* happened since the call to {@link #enableAllocationTracker(boolean)} with <var>enable</var>
|
||||||
@@ -457,7 +463,7 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mConnState = ST_AWAIT_SHAKE;
|
mConnState = ST_AWAIT_SHAKE;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,7 +644,7 @@ public class Client {
|
|||||||
*/
|
*/
|
||||||
Log.e("ddms", "Receiving data in state = " + mConnState);
|
Log.e("ddms", "Receiving data in state = " + mConnState);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,7 +759,7 @@ public class Client {
|
|||||||
|
|
||||||
mDevice.removeClient(this, notify);
|
mDevice.removeClient(this, notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this {@link Client} has a valid connection to the application VM.
|
* 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;
|
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
|
* <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>.
|
* increment this value for each new <code>Client</code>.
|
||||||
*
|
*
|
||||||
* <p/>This {@link DebugPortManager} allows applications using ddmlib to provide a custom
|
* <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
|
* port provider on a per-<code>Client</code> basis, depending on the device/emulator they are
|
||||||
* running on, and/or their names.
|
* 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}
|
* @return The non-random debugger port or {@link #NO_STATIC_PORT} if the {@link Client}
|
||||||
* should use the automatic debugger port provider.
|
* 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;
|
private static IDebugPortProvider sProvider = null;
|
||||||
@@ -63,7 +63,7 @@ public class DebugPortManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the
|
* Returns the
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static IDebugPortProvider getProvider() {
|
static IDebugPortProvider getProvider() {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.ddmlib;
|
package com.android.ddmlib;
|
||||||
|
|
||||||
import com.android.ddmlib.Client;
|
|
||||||
import com.android.ddmlib.log.LogReceiver;
|
import com.android.ddmlib.log.LogReceiver;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -30,50 +29,20 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A Device. It can be a physical device or an emulator.
|
* 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 {
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Emulator Serial Number regexp. */
|
/** Emulator Serial Number regexp. */
|
||||||
final static String RE_EMULATOR_SN = "emulator-(\\d+)"; //$NON-NLS-1$
|
final static String RE_EMULATOR_SN = "emulator-(\\d+)"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** Serial number of the device */
|
/** Serial number of the device */
|
||||||
String serialNumber = null;
|
private String mSerialNumber = null;
|
||||||
|
|
||||||
/** Name of the AVD */
|
/** Name of the AVD */
|
||||||
String mAvdName = null;
|
private String mAvdName = null;
|
||||||
|
|
||||||
/** State of the device. */
|
/** State of the device. */
|
||||||
DeviceState state = null;
|
private DeviceState mState = null;
|
||||||
|
|
||||||
/** Device properties. */
|
/** Device properties. */
|
||||||
private final Map<String, String> mProperties = new HashMap<String, String>();
|
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()
|
* @see com.android.ddmlib.IDevice#getSerialNumber()
|
||||||
*/
|
*/
|
||||||
public String getSerialNumber() {
|
public String getSerialNumber() {
|
||||||
return serialNumber;
|
return mSerialNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
public String getAvdName() {
|
public String getAvdName() {
|
||||||
return mAvdName;
|
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)
|
* (non-Javadoc)
|
||||||
* @see com.android.ddmlib.IDevice#getState()
|
* @see com.android.ddmlib.IDevice#getState()
|
||||||
*/
|
*/
|
||||||
public DeviceState getState() {
|
public DeviceState getState() {
|
||||||
return state;
|
return mState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the state of the device.
|
||||||
|
*/
|
||||||
|
void setState(DeviceState state) {
|
||||||
|
mState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see com.android.ddmlib.IDevice#getProperties()
|
* @see com.android.ddmlib.IDevice#getProperties()
|
||||||
@@ -134,7 +123,7 @@ public final class Device implements IDevice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return serialNumber;
|
return mSerialNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -142,7 +131,7 @@ public final class Device implements IDevice {
|
|||||||
* @see com.android.ddmlib.IDevice#isOnline()
|
* @see com.android.ddmlib.IDevice#isOnline()
|
||||||
*/
|
*/
|
||||||
public boolean 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()
|
* @see com.android.ddmlib.IDevice#isEmulator()
|
||||||
*/
|
*/
|
||||||
public boolean 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()
|
* @see com.android.ddmlib.IDevice#isOffline()
|
||||||
*/
|
*/
|
||||||
public boolean 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()
|
* @see com.android.ddmlib.IDevice#isBootLoader()
|
||||||
*/
|
*/
|
||||||
public boolean 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;
|
mMonitor = monitor;
|
||||||
|
mSerialNumber = serialNumber;
|
||||||
|
mState = deviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceMonitor getMonitor() {
|
DeviceMonitor getMonitor() {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package com.android.ddmlib;
|
|||||||
|
|
||||||
import com.android.ddmlib.AdbHelper.AdbResponse;
|
import com.android.ddmlib.AdbHelper.AdbResponse;
|
||||||
import com.android.ddmlib.DebugPortManager.IDebugPortProvider;
|
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.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@@ -112,11 +112,11 @@ final class DeviceMonitor {
|
|||||||
boolean isMonitoring() {
|
boolean isMonitoring() {
|
||||||
return mMonitoring;
|
return mMonitoring;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getConnectionAttemptCount() {
|
int getConnectionAttemptCount() {
|
||||||
return mConnectionAttempt;
|
return mConnectionAttempt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getRestartAttemptCount() {
|
int getRestartAttemptCount() {
|
||||||
return mRestartAttemptCount;
|
return mRestartAttemptCount;
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ final class DeviceMonitor {
|
|||||||
return mDevices.toArray(new Device[mDevices.size()]);
|
return mDevices.toArray(new Device[mDevices.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasInitialDeviceList() {
|
boolean hasInitialDeviceList() {
|
||||||
return mInitialDeviceListDone;
|
return mInitialDeviceListDone;
|
||||||
}
|
}
|
||||||
@@ -184,11 +184,11 @@ final class DeviceMonitor {
|
|||||||
if (mMonitoring) {
|
if (mMonitoring) {
|
||||||
// read the length of the incoming message
|
// read the length of the incoming message
|
||||||
int length = readLength(mMainAdbConnection, mLengthBuffer);
|
int length = readLength(mMainAdbConnection, mLengthBuffer);
|
||||||
|
|
||||||
if (length >= 0) {
|
if (length >= 0) {
|
||||||
// read the incoming message
|
// read the incoming message
|
||||||
processIncomingDeviceData(length);
|
processIncomingDeviceData(length);
|
||||||
|
|
||||||
// flag the fact that we have build the list at least once.
|
// flag the fact that we have build the list at least once.
|
||||||
mInitialDeviceListDone = true;
|
mInitialDeviceListDone = true;
|
||||||
}
|
}
|
||||||
@@ -278,20 +278,19 @@ final class DeviceMonitor {
|
|||||||
*/
|
*/
|
||||||
private void processIncomingDeviceData(int length) throws IOException {
|
private void processIncomingDeviceData(int length) throws IOException {
|
||||||
ArrayList<Device> list = new ArrayList<Device>();
|
ArrayList<Device> list = new ArrayList<Device>();
|
||||||
|
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
byte[] buffer = new byte[length];
|
byte[] buffer = new byte[length];
|
||||||
String result = read(mMainAdbConnection, buffer);
|
String result = read(mMainAdbConnection, buffer);
|
||||||
|
|
||||||
String[] devices = result.split("\n"); // $NON-NLS-1$
|
String[] devices = result.split("\n"); // $NON-NLS-1$
|
||||||
|
|
||||||
for (String d : devices) {
|
for (String d : devices) {
|
||||||
String[] param = d.split("\t"); // $NON-NLS-1$
|
String[] param = d.split("\t"); // $NON-NLS-1$
|
||||||
if (param.length == 2) {
|
if (param.length == 2) {
|
||||||
// new adb uses only serial numbers to identify devices
|
// new adb uses only serial numbers to identify devices
|
||||||
Device device = new Device(this);
|
Device device = new Device(this, param[0] /*serialnumber*/,
|
||||||
device.serialNumber = param[0];
|
DeviceState.getState(param[1]));
|
||||||
device.state = DeviceState.getState(param[1]);
|
|
||||||
|
|
||||||
//add the device to the list
|
//add the device to the list
|
||||||
list.add(device);
|
list.add(device);
|
||||||
@@ -319,24 +318,24 @@ final class DeviceMonitor {
|
|||||||
// * if we do not find it, we remove it from the current list.
|
// * 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
|
// 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.
|
// add them to the list, and start monitoring them.
|
||||||
|
|
||||||
for (int d = 0 ; d < mDevices.size() ;) {
|
for (int d = 0 ; d < mDevices.size() ;) {
|
||||||
Device device = mDevices.get(d);
|
Device device = mDevices.get(d);
|
||||||
|
|
||||||
// look for a similar device in the new list.
|
// look for a similar device in the new list.
|
||||||
int count = newList.size();
|
int count = newList.size();
|
||||||
boolean foundMatch = false;
|
boolean foundMatch = false;
|
||||||
for (int dd = 0 ; dd < count ; dd++) {
|
for (int dd = 0 ; dd < count ; dd++) {
|
||||||
Device newDevice = newList.get(dd);
|
Device newDevice = newList.get(dd);
|
||||||
// see if it matches in id and serial number.
|
// see if it matches in id and serial number.
|
||||||
if (newDevice.serialNumber.equals(device.serialNumber)) {
|
if (newDevice.getSerialNumber().equals(device.getSerialNumber())) {
|
||||||
foundMatch = true;
|
foundMatch = true;
|
||||||
|
|
||||||
// update the state if needed.
|
// update the state if needed.
|
||||||
if (device.state != newDevice.state) {
|
if (device.getState() != newDevice.getState()) {
|
||||||
device.state = newDevice.state;
|
device.setState(newDevice.getState());
|
||||||
device.update(Device.CHANGE_STATE);
|
device.update(Device.CHANGE_STATE);
|
||||||
|
|
||||||
// if the device just got ready/online, we need to start
|
// if the device just got ready/online, we need to start
|
||||||
// monitoring it.
|
// monitoring it.
|
||||||
if (device.isOnline()) {
|
if (device.isOnline()) {
|
||||||
@@ -344,7 +343,7 @@ final class DeviceMonitor {
|
|||||||
if (startMonitoringDevice(device) == false) {
|
if (startMonitoringDevice(device) == false) {
|
||||||
Log.e("DeviceMonitor",
|
Log.e("DeviceMonitor",
|
||||||
"Failed to start monitoring "
|
"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
|
// remove the new device from the list since it's been used
|
||||||
newList.remove(dd);
|
newList.remove(dd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundMatch == false) {
|
if (foundMatch == false) {
|
||||||
// the device is gone, we need to remove it, and keep current index
|
// the device is gone, we need to remove it, and keep current index
|
||||||
// to process the next one.
|
// to process the next one.
|
||||||
@@ -370,21 +369,21 @@ final class DeviceMonitor {
|
|||||||
d++;
|
d++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// at this point we should still have some new devices in newList, so we
|
// at this point we should still have some new devices in newList, so we
|
||||||
// process them.
|
// process them.
|
||||||
for (Device newDevice : newList) {
|
for (Device newDevice : newList) {
|
||||||
// add them to the list
|
// add them to the list
|
||||||
mDevices.add(newDevice);
|
mDevices.add(newDevice);
|
||||||
mServer.deviceConnected(newDevice);
|
mServer.deviceConnected(newDevice);
|
||||||
|
|
||||||
// start monitoring them.
|
// start monitoring them.
|
||||||
if (AndroidDebugBridge.getClientSupport() == true) {
|
if (AndroidDebugBridge.getClientSupport() == true) {
|
||||||
if (newDevice.isOnline()) {
|
if (newDevice.isOnline()) {
|
||||||
startMonitoringDevice(newDevice);
|
startMonitoringDevice(newDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for their build info.
|
// look for their build info.
|
||||||
if (newDevice.isOnline()) {
|
if (newDevice.isOnline()) {
|
||||||
queryNewDeviceForInfo(newDevice);
|
queryNewDeviceForInfo(newDevice);
|
||||||
@@ -398,7 +397,7 @@ final class DeviceMonitor {
|
|||||||
private void removeDevice(Device device) {
|
private void removeDevice(Device device) {
|
||||||
device.clearClientList();
|
device.clearClientList();
|
||||||
mDevices.remove(device);
|
mDevices.remove(device);
|
||||||
|
|
||||||
SocketChannel channel = device.getClientMonitoringSocket();
|
SocketChannel channel = device.getClientMonitoringSocket();
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
try {
|
try {
|
||||||
@@ -419,12 +418,12 @@ final class DeviceMonitor {
|
|||||||
// first get the list of properties.
|
// first get the list of properties.
|
||||||
device.executeShellCommand(GetPropReceiver.GETPROP_COMMAND,
|
device.executeShellCommand(GetPropReceiver.GETPROP_COMMAND,
|
||||||
new GetPropReceiver(device));
|
new GetPropReceiver(device));
|
||||||
|
|
||||||
// now get the emulator Virtual Device name (if applicable).
|
// now get the emulator Virtual Device name (if applicable).
|
||||||
if (device.isEmulator()) {
|
if (device.isEmulator()) {
|
||||||
EmulatorConsole console = EmulatorConsole.getConsole(device);
|
EmulatorConsole console = EmulatorConsole.getConsole(device);
|
||||||
if (console != null) {
|
if (console != null) {
|
||||||
device.mAvdName = console.getAvdName();
|
device.setAvdName(console.getAvdName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -510,7 +509,7 @@ final class DeviceMonitor {
|
|||||||
MonitorThread monitorThread = MonitorThread.getInstance();
|
MonitorThread monitorThread = MonitorThread.getInstance();
|
||||||
|
|
||||||
for (Client client : clients) {
|
for (Client client : clients) {
|
||||||
Device device = client.getDevice();
|
Device device = client.getDeviceImpl();
|
||||||
int pid = client.getClientData().getPid();
|
int pid = client.getClientData().getPid();
|
||||||
|
|
||||||
monitorThread.dropClient(client, false /* notify */);
|
monitorThread.dropClient(client, false /* notify */);
|
||||||
@@ -623,10 +622,10 @@ final class DeviceMonitor {
|
|||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
byte[] buffer = new byte[length];
|
byte[] buffer = new byte[length];
|
||||||
String result = read(monitorSocket, buffer);
|
String result = read(monitorSocket, buffer);
|
||||||
|
|
||||||
// split each line in its own list and create an array of integer pid
|
// split each line in its own list and create an array of integer pid
|
||||||
String[] pids = result.split("\n"); //$NON-NLS-1$
|
String[] pids = result.split("\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (String pid : pids) {
|
for (String pid : pids) {
|
||||||
try {
|
try {
|
||||||
pidList.add(Integer.valueOf(pid));
|
pidList.add(Integer.valueOf(pid));
|
||||||
@@ -662,7 +661,7 @@ final class DeviceMonitor {
|
|||||||
for (int c = 0 ; c < clients.size() ;) {
|
for (int c = 0 ; c < clients.size() ;) {
|
||||||
Client client = clients.get(c);
|
Client client = clients.get(c);
|
||||||
int pid = client.getClientData().getPid();
|
int pid = client.getClientData().getPid();
|
||||||
|
|
||||||
// look for a matching pid
|
// look for a matching pid
|
||||||
Integer match = null;
|
Integer match = null;
|
||||||
for (Integer matchingPid : pidList) {
|
for (Integer matchingPid : pidList) {
|
||||||
@@ -671,7 +670,7 @@ final class DeviceMonitor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
pidList.remove(match);
|
pidList.remove(match);
|
||||||
c++; // move on to the next client.
|
c++; // move on to the next client.
|
||||||
@@ -705,7 +704,7 @@ final class DeviceMonitor {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private void openClient(Device device, int pid, int port, MonitorThread monitorThread) {
|
private void openClient(Device device, int pid, int port, MonitorThread monitorThread) {
|
||||||
|
|
||||||
SocketChannel clientSocket;
|
SocketChannel clientSocket;
|
||||||
try {
|
try {
|
||||||
clientSocket = AdbHelper.createPassThroughConnection(
|
clientSocket = AdbHelper.createPassThroughConnection(
|
||||||
@@ -721,7 +720,7 @@ final class DeviceMonitor {
|
|||||||
"Failed to connect to client '" + pid + "': " + ioe.getMessage());
|
"Failed to connect to client '" + pid + "': " + ioe.getMessage());
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
createClient(device, pid, clientSocket, port, monitorThread);
|
createClient(device, pid, clientSocket, port, monitorThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,7 +813,7 @@ final class DeviceMonitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the length of the next message from a socket.
|
* Reads the length of the next message from a socket.
|
||||||
* @param socket The {@link SocketChannel} to read from.
|
* @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>.
|
* 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/>However this means you <i>may</i> receive <code>\r\n</code> when reading from the console.
|
||||||
* <p/>
|
* <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 {
|
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_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_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_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$
|
"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$
|
"%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$
|
"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.
|
* @param d The device that the console links to.
|
||||||
* @return an <code>EmulatorConsole</code> object or <code>null</code> if the connection failed.
|
* @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
|
// 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()) {
|
if (m.matches()) {
|
||||||
// get the port number. This is the console port.
|
// get the port number. This is the console port.
|
||||||
int port;
|
int port;
|
||||||
@@ -308,7 +308,7 @@ public final class EmulatorConsole {
|
|||||||
RemoveConsole(mPort);
|
RemoveConsole(mPort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String getAvdName() {
|
public synchronized String getAvdName() {
|
||||||
if (sendCommand(COMMAND_AVD_NAME)) {
|
if (sendCommand(COMMAND_AVD_NAME)) {
|
||||||
String[] result = readLines();
|
String[] result = readLines();
|
||||||
@@ -323,7 +323,7 @@ public final class EmulatorConsole {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,18 +517,18 @@ public final class EmulatorConsole {
|
|||||||
String command = String.format(COMMAND_NETWORK_LATENCY, NETWORK_LATENCIES[selectionIndex]);
|
String command = String.format(COMMAND_NETWORK_LATENCY, NETWORK_LATENCIES[selectionIndex]);
|
||||||
return processCommand(command);
|
return processCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String sendLocation(double longitude, double latitude, double elevation) {
|
public synchronized String sendLocation(double longitude, double latitude, double elevation) {
|
||||||
|
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
|
|
||||||
double absLong = Math.abs(longitude);
|
double absLong = Math.abs(longitude);
|
||||||
int longDegree = (int)Math.floor(absLong);
|
int longDegree = (int)Math.floor(absLong);
|
||||||
char longDirection = 'E';
|
char longDirection = 'E';
|
||||||
if (longitude < 0) {
|
if (longitude < 0) {
|
||||||
longDirection = 'W';
|
longDirection = 'W';
|
||||||
}
|
}
|
||||||
|
|
||||||
double longMinute = (absLong - Math.floor(absLong)) * 60;
|
double longMinute = (absLong - Math.floor(absLong)) * 60;
|
||||||
|
|
||||||
double absLat = Math.abs(latitude);
|
double absLat = Math.abs(latitude);
|
||||||
@@ -537,15 +537,15 @@ public final class EmulatorConsole {
|
|||||||
if (latitude < 0) {
|
if (latitude < 0) {
|
||||||
latDirection = 'S';
|
latDirection = 'S';
|
||||||
}
|
}
|
||||||
|
|
||||||
double latMinute = (absLat - Math.floor(absLat)) * 60;
|
double latMinute = (absLat - Math.floor(absLat)) * 60;
|
||||||
|
|
||||||
String command = String.format(COMMAND_GPS,
|
String command = String.format(COMMAND_GPS,
|
||||||
c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE),
|
c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE),
|
||||||
c.get(Calendar.SECOND), c.get(Calendar.MILLISECOND),
|
c.get(Calendar.SECOND), c.get(Calendar.MILLISECOND),
|
||||||
latDegree, latMinute, latDirection,
|
latDegree, latMinute, latDirection,
|
||||||
longDegree, longMinute, longDirection);
|
longDegree, longMinute, longDirection);
|
||||||
|
|
||||||
return processCommand(command);
|
return processCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,7 +617,7 @@ public final class EmulatorConsole {
|
|||||||
ByteBuffer buf = ByteBuffer.wrap(mBuffer, 0, mBuffer.length);
|
ByteBuffer buf = ByteBuffer.wrap(mBuffer, 0, mBuffer.length);
|
||||||
int numWaits = 0;
|
int numWaits = 0;
|
||||||
boolean stop = false;
|
boolean stop = false;
|
||||||
|
|
||||||
while (buf.position() != buf.limit() && stop == false) {
|
while (buf.position() != buf.limit() && stop == false) {
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.ddmlib;
|
package com.android.ddmlib;
|
||||||
|
|
||||||
import com.android.ddmlib.Device.DeviceState;
|
|
||||||
import com.android.ddmlib.log.LogReceiver;
|
import com.android.ddmlib.log.LogReceiver;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -40,6 +39,35 @@ public interface IDevice {
|
|||||||
/** Device change bit mask: build info change. */
|
/** Device change bit mask: build info change. */
|
||||||
public static final int CHANGE_BUILD_INFO = 0x0004;
|
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.
|
* 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 {
|
synchronized void setDebugSelectedPort(int port) throws IllegalStateException {
|
||||||
if (mInstance == null) {
|
if (mInstance == null) {
|
||||||
@@ -206,7 +206,7 @@ final class MonitorThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!mQuit) {
|
while (!mQuit) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/*
|
/*
|
||||||
* sync with new registrations: we wait until addClient is done before going through
|
* sync with new registrations: we wait until addClient is done before going through
|
||||||
@@ -215,7 +215,7 @@ final class MonitorThread extends Thread {
|
|||||||
*/
|
*/
|
||||||
synchronized (mClientList) {
|
synchronized (mClientList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// (re-)open the "debug selected" port, if it's not opened yet or
|
// (re-)open the "debug selected" port, if it's not opened yet or
|
||||||
// if the port changed.
|
// if the port changed.
|
||||||
try {
|
try {
|
||||||
@@ -234,7 +234,7 @@ final class MonitorThread extends Thread {
|
|||||||
Log.e("ddms", ioe);
|
Log.e("ddms", ioe);
|
||||||
mNewDebugSelectedPort = mDebugSelectedPort; // no retry
|
mNewDebugSelectedPort = mDebugSelectedPort; // no retry
|
||||||
}
|
}
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
try {
|
try {
|
||||||
count = mSelector.select();
|
count = mSelector.select();
|
||||||
@@ -244,20 +244,20 @@ final class MonitorThread extends Thread {
|
|||||||
} catch (CancelledKeyException cke) {
|
} catch (CancelledKeyException cke) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
// somebody called wakeup() ?
|
// somebody called wakeup() ?
|
||||||
// Log.i("ddms", "selector looping");
|
// Log.i("ddms", "selector looping");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<SelectionKey> keys = mSelector.selectedKeys();
|
Set<SelectionKey> keys = mSelector.selectedKeys();
|
||||||
Iterator<SelectionKey> iter = keys.iterator();
|
Iterator<SelectionKey> iter = keys.iterator();
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
SelectionKey key = iter.next();
|
SelectionKey key = iter.next();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (key.attachment() instanceof Client) {
|
if (key.attachment() instanceof Client) {
|
||||||
processClientActivity(key);
|
processClientActivity(key);
|
||||||
@@ -300,7 +300,7 @@ final class MonitorThread extends Thread {
|
|||||||
*/
|
*/
|
||||||
private void processClientActivity(SelectionKey key) {
|
private void processClientActivity(SelectionKey key) {
|
||||||
Client client = (Client)key.attachment();
|
Client client = (Client)key.attachment();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (key.isReadable() == false || key.isValid() == false) {
|
if (key.isReadable() == false || key.isValid() == false) {
|
||||||
Log.d("ddms", "Invalid key from " + client + ". Dropping client.");
|
Log.d("ddms", "Invalid key from " + client + ". Dropping client.");
|
||||||
@@ -423,7 +423,7 @@ final class MonitorThread extends Thread {
|
|||||||
* @param notify
|
* @param notify
|
||||||
*/
|
*/
|
||||||
synchronized void dropClient(Client client, boolean notify) {
|
synchronized void dropClient(Client client, boolean notify) {
|
||||||
if (mInstance == null) {
|
if (mInstance == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,13 +551,13 @@ final class MonitorThread extends Thread {
|
|||||||
|
|
||||||
// we should drop the client, but also attempt to reopen it.
|
// we should drop the client, but also attempt to reopen it.
|
||||||
// This is done by the DeviceMonitor.
|
// This is done by the DeviceMonitor.
|
||||||
client.getDevice().getMonitor().addClientToDropAndReopen(client,
|
client.getDeviceImpl().getMonitor().addClientToDropAndReopen(client,
|
||||||
IDebugPortProvider.NO_STATIC_PORT);
|
IDebugPortProvider.NO_STATIC_PORT);
|
||||||
} else {
|
} else {
|
||||||
Log.i("ddms", " (recycling client connection as well)");
|
Log.i("ddms", " (recycling client connection as well)");
|
||||||
// we should drop the client, but also attempt to reopen it.
|
// we should drop the client, but also attempt to reopen it.
|
||||||
// This is done by the DeviceMonitor.
|
// This is done by the DeviceMonitor.
|
||||||
client.getDevice().getMonitor().addClientToDropAndReopen(client,
|
client.getDeviceImpl().getMonitor().addClientToDropAndReopen(client,
|
||||||
IDebugPortProvider.NO_STATIC_PORT);
|
IDebugPortProvider.NO_STATIC_PORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -644,7 +644,7 @@ final class MonitorThread extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Broadcast an event to all message handlers.
|
* Broadcast an event to all message handlers.
|
||||||
*/
|
*/
|
||||||
@@ -719,7 +719,7 @@ final class MonitorThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mDebugSelectedChan.register(mSelector, SelectionKey.OP_ACCEPT, this);
|
mDebugSelectedChan.register(mSelector, SelectionKey.OP_ACCEPT, this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (java.net.BindException e) {
|
} catch (java.net.BindException e) {
|
||||||
displayDebugSelectedBindError(mNewDebugSelectedPort);
|
displayDebugSelectedBindError(mNewDebugSelectedPort);
|
||||||
@@ -727,7 +727,7 @@ final class MonitorThread extends Thread {
|
|||||||
// do not attempt to reopen it.
|
// do not attempt to reopen it.
|
||||||
mDebugSelectedChan = null;
|
mDebugSelectedChan = null;
|
||||||
mNewDebugSelectedPort = -1;
|
mNewDebugSelectedPort = -1;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.ddmlib.log;
|
package com.android.ddmlib.log;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.MultiLineReceiver;
|
import com.android.ddmlib.MultiLineReceiver;
|
||||||
import com.android.ddmlib.log.EventContainer.EventValueType;
|
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_LONG = 1;
|
||||||
private final static int EVENT_TYPE_STRING = 2;
|
private final static int EVENT_TYPE_STRING = 2;
|
||||||
private final static int EVENT_TYPE_LIST = 3;
|
private final static int EVENT_TYPE_LIST = 3;
|
||||||
|
|
||||||
private final static Pattern PATTERN_SIMPLE_TAG = Pattern.compile(
|
private final static Pattern PATTERN_SIMPLE_TAG = Pattern.compile(
|
||||||
"^(\\d+)\\s+([A-Za-z0-9_]+)\\s*$"); //$NON-NLS-1$
|
"^(\\d+)\\s+([A-Za-z0-9_]+)\\s*$"); //$NON-NLS-1$
|
||||||
private final static Pattern PATTERN_TAG_WITH_DESC = Pattern.compile(
|
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$
|
"(\\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, String> mTagMap = new TreeMap<Integer, String>();
|
||||||
|
|
||||||
private final TreeMap<Integer, EventValueDescription[]> mValueDescriptionMap =
|
private final TreeMap<Integer, EventValueDescription[]> mValueDescriptionMap =
|
||||||
new TreeMap<Integer, EventValueDescription[]>();
|
new TreeMap<Integer, EventValueDescription[]>();
|
||||||
|
|
||||||
public EventLogParser() {
|
public EventLogParser() {
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public final class EventLogParser {
|
|||||||
* @param device The device.
|
* @param device The device.
|
||||||
* @return <code>true</code> if success, <code>false</code> if failure or cancellation.
|
* @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.
|
// read the event tag map file on the device.
|
||||||
try {
|
try {
|
||||||
device.executeShellCommand("cat " + EVENT_TAG_MAP_FILE, //$NON-NLS-1$
|
device.executeShellCommand("cat " + EVENT_TAG_MAP_FILE, //$NON-NLS-1$
|
||||||
@@ -103,7 +103,7 @@ public final class EventLogParser {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inits the parser with the content of a tag file.
|
* Inits the parser with the content of a tag file.
|
||||||
* @param tagFileContent the lines of a tag file.
|
* @param tagFileContent the lines of a tag file.
|
||||||
@@ -115,7 +115,7 @@ public final class EventLogParser {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inits the parser with a specified event-log-tags file.
|
* Inits the parser with a specified event-log-tags file.
|
||||||
* @param filePath
|
* @param filePath
|
||||||
@@ -124,7 +124,7 @@ public final class EventLogParser {
|
|||||||
public boolean init(String filePath) {
|
public boolean init(String filePath) {
|
||||||
try {
|
try {
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(filePath));
|
BufferedReader reader = new BufferedReader(new FileReader(filePath));
|
||||||
|
|
||||||
String line = null;
|
String line = null;
|
||||||
do {
|
do {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
@@ -132,13 +132,13 @@ public final class EventLogParser {
|
|||||||
processTagLine(line);
|
processTagLine(line);
|
||||||
}
|
}
|
||||||
} while (line != null);
|
} while (line != null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a line from the event-log-tags file.
|
* Processes a line from the event-log-tags file.
|
||||||
* @param line the line to process
|
* @param line the line to process
|
||||||
@@ -154,7 +154,7 @@ public final class EventLogParser {
|
|||||||
if (name != null && mTagMap.get(value) == null) {
|
if (name != null && mTagMap.get(value) == null) {
|
||||||
mTagMap.put(value, name);
|
mTagMap.put(value, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// special case for the GC tag. We ignore what is in the file,
|
// special case for the GC tag. We ignore what is in the file,
|
||||||
// and take what the custom GcEventContainer class tells us.
|
// and take what the custom GcEventContainer class tells us.
|
||||||
// This is due to the event encoding several values on 2 longs.
|
// This is due to the event encoding several values on 2 longs.
|
||||||
@@ -163,12 +163,12 @@ public final class EventLogParser {
|
|||||||
mValueDescriptionMap.put(value,
|
mValueDescriptionMap.put(value,
|
||||||
GcEventContainer.getValueDescriptions());
|
GcEventContainer.getValueDescriptions());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String description = m.group(3);
|
String description = m.group(3);
|
||||||
if (description != null && description.length() > 0) {
|
if (description != null && description.length() > 0) {
|
||||||
EventValueDescription[] desc =
|
EventValueDescription[] desc =
|
||||||
processDescription(description);
|
processDescription(description);
|
||||||
|
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
mValueDescriptionMap.put(value, desc);
|
mValueDescriptionMap.put(value, desc);
|
||||||
}
|
}
|
||||||
@@ -189,12 +189,12 @@ public final class EventLogParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private EventValueDescription[] processDescription(String description) {
|
private EventValueDescription[] processDescription(String description) {
|
||||||
String[] descriptions = description.split("\\s*,\\s*"); //$NON-NLS-1$
|
String[] descriptions = description.split("\\s*,\\s*"); //$NON-NLS-1$
|
||||||
|
|
||||||
ArrayList<EventValueDescription> list = new ArrayList<EventValueDescription>();
|
ArrayList<EventValueDescription> list = new ArrayList<EventValueDescription>();
|
||||||
|
|
||||||
for (String desc : descriptions) {
|
for (String desc : descriptions) {
|
||||||
Matcher m = PATTERN_DESCRIPTION.matcher(desc);
|
Matcher m = PATTERN_DESCRIPTION.matcher(desc);
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
@@ -208,15 +208,15 @@ public final class EventLogParser {
|
|||||||
// just ignore this description if the value is not recognized.
|
// just ignore this description if the value is not recognized.
|
||||||
// TODO: log the error.
|
// TODO: log the error.
|
||||||
}
|
}
|
||||||
|
|
||||||
typeString = m.group(3);
|
typeString = m.group(3);
|
||||||
if (typeString != null && typeString.length() > 0) {
|
if (typeString != null && typeString.length() > 0) {
|
||||||
//skip the |
|
//skip the |
|
||||||
typeString = typeString.substring(1);
|
typeString = typeString.substring(1);
|
||||||
|
|
||||||
typeValue = Integer.parseInt(typeString);
|
typeValue = Integer.parseInt(typeString);
|
||||||
ValueType valueType = ValueType.getValueType(typeValue);
|
ValueType valueType = ValueType.getValueType(typeValue);
|
||||||
|
|
||||||
list.add(new EventValueDescription(name, eventValueType, valueType));
|
list.add(new EventValueDescription(name, eventValueType, valueType));
|
||||||
} else {
|
} else {
|
||||||
list.add(new EventValueDescription(name, eventValueType));
|
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$
|
String.format("Can't parse %1$s", description)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.toArray(new EventValueDescription[list.size()]);
|
return list.toArray(new EventValueDescription[list.size()]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventContainer parse(LogEntry entry) {
|
public EventContainer parse(LogEntry entry) {
|
||||||
if (entry.len < 4) {
|
if (entry.len < 4) {
|
||||||
return null;
|
return null;
|
||||||
@@ -251,7 +251,7 @@ public final class EventLogParser {
|
|||||||
|
|
||||||
int tagValue = ArrayHelper.swap32bitFromArray(entry.data, inOffset);
|
int tagValue = ArrayHelper.swap32bitFromArray(entry.data, inOffset);
|
||||||
inOffset += 4;
|
inOffset += 4;
|
||||||
|
|
||||||
String tag = mTagMap.get(tagValue);
|
String tag = mTagMap.get(tagValue);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
Log.e("EventLogParser", String.format("unknown tag number: %1$d", tagValue));
|
Log.e("EventLogParser", String.format("unknown tag number: %1$d", tagValue));
|
||||||
@@ -275,10 +275,10 @@ public final class EventLogParser {
|
|||||||
} else {
|
} else {
|
||||||
event = new EventContainer(entry, tagValue, data);
|
event = new EventContainer(entry, tagValue, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventContainer parse(String textLogLine) {
|
public EventContainer parse(String textLogLine) {
|
||||||
// line will look like
|
// line will look like
|
||||||
// 04-29 23:16:16.691 I/dvm_gc_info( 427): <data>
|
// 04-29 23:16:16.691 I/dvm_gc_info( 427): <data>
|
||||||
@@ -289,7 +289,7 @@ public final class EventLogParser {
|
|||||||
if (textLogLine.length() == 0) {
|
if (textLogLine.length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the header first
|
// parse the header first
|
||||||
Matcher m = TEXT_LOG_LINE.matcher(textLogLine);
|
Matcher m = TEXT_LOG_LINE.matcher(textLogLine);
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
@@ -300,7 +300,7 @@ public final class EventLogParser {
|
|||||||
int minutes = Integer.parseInt(m.group(4));
|
int minutes = Integer.parseInt(m.group(4));
|
||||||
int seconds = Integer.parseInt(m.group(5));
|
int seconds = Integer.parseInt(m.group(5));
|
||||||
int milliseconds = Integer.parseInt(m.group(6));
|
int milliseconds = Integer.parseInt(m.group(6));
|
||||||
|
|
||||||
// convert into seconds since epoch and nano-seconds.
|
// convert into seconds since epoch and nano-seconds.
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(cal.get(Calendar.YEAR), month-1, day, hours, minutes, seconds);
|
cal.set(cal.get(Calendar.YEAR), month-1, day, hours, minutes, seconds);
|
||||||
@@ -308,7 +308,7 @@ public final class EventLogParser {
|
|||||||
int nsec = milliseconds * 1000000;
|
int nsec = milliseconds * 1000000;
|
||||||
|
|
||||||
String tag = m.group(7);
|
String tag = m.group(7);
|
||||||
|
|
||||||
// get the numerical tag value
|
// get the numerical tag value
|
||||||
int tagValue = -1;
|
int tagValue = -1;
|
||||||
Set<Entry<Integer, String>> tagSet = mTagMap.entrySet();
|
Set<Entry<Integer, String>> tagSet = mTagMap.entrySet();
|
||||||
@@ -318,18 +318,18 @@ public final class EventLogParser {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagValue == -1) {
|
if (tagValue == -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pid = Integer.parseInt(m.group(8));
|
int pid = Integer.parseInt(m.group(8));
|
||||||
|
|
||||||
Object data = parseTextData(m.group(9), tagValue);
|
Object data = parseTextData(m.group(9), tagValue);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we can allocate and return the EventContainer
|
// now we can allocate and return the EventContainer
|
||||||
EventContainer event = null;
|
EventContainer event = null;
|
||||||
if (tagValue == GcEventContainer.GC_EVENT_TAG) {
|
if (tagValue == GcEventContainer.GC_EVENT_TAG) {
|
||||||
@@ -337,20 +337,20 @@ public final class EventLogParser {
|
|||||||
} else {
|
} else {
|
||||||
event = new EventContainer(tagValue, pid, -1 /* tid */, sec, nsec, data);
|
event = new EventContainer(tagValue, pid, -1 /* tid */, sec, nsec, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, String> getTagMap() {
|
public Map<Integer, String> getTagMap() {
|
||||||
return mTagMap;
|
return mTagMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, EventValueDescription[]> getEventInfoMap() {
|
public Map<Integer, EventValueDescription[]> getEventInfoMap() {
|
||||||
return mValueDescriptionMap;
|
return mValueDescriptionMap;
|
||||||
}
|
}
|
||||||
@@ -370,7 +370,7 @@ public final class EventLogParser {
|
|||||||
|
|
||||||
if (eventData.length - dataOffset < 1)
|
if (eventData.length - dataOffset < 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int offset = dataOffset;
|
int offset = dataOffset;
|
||||||
|
|
||||||
int type = eventData[offset++];
|
int type = eventData[offset++];
|
||||||
@@ -385,7 +385,7 @@ public final class EventLogParser {
|
|||||||
return -1;
|
return -1;
|
||||||
ival = ArrayHelper.swap32bitFromArray(eventData, offset);
|
ival = ArrayHelper.swap32bitFromArray(eventData, offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
list.add(new Integer(ival));
|
list.add(new Integer(ival));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -396,7 +396,7 @@ public final class EventLogParser {
|
|||||||
return -1;
|
return -1;
|
||||||
lval = ArrayHelper.swap64bitFromArray(eventData, offset);
|
lval = ArrayHelper.swap64bitFromArray(eventData, offset);
|
||||||
offset += 8;
|
offset += 8;
|
||||||
|
|
||||||
list.add(new Long(lval));
|
list.add(new Long(lval));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -410,7 +410,7 @@ public final class EventLogParser {
|
|||||||
|
|
||||||
if (eventData.length - offset < strLen)
|
if (eventData.length - offset < strLen)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// get the string
|
// get the string
|
||||||
try {
|
try {
|
||||||
String str = new String(eventData, offset, strLen, "UTF-8"); //$NON-NLS-1$
|
String str = new String(eventData, offset, strLen, "UTF-8"); //$NON-NLS-1$
|
||||||
@@ -434,7 +434,7 @@ public final class EventLogParser {
|
|||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += result;
|
offset += result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,59 +446,59 @@ public final class EventLogParser {
|
|||||||
String.format("Unknown binary event type %1$d", type)); //$NON-NLS-1$
|
String.format("Unknown binary event type %1$d", type)); //$NON-NLS-1$
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset - dataOffset;
|
return offset - dataOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object parseTextData(String data, int tagValue) {
|
private Object parseTextData(String data, int tagValue) {
|
||||||
// first, get the description of what we're supposed to parse
|
// first, get the description of what we're supposed to parse
|
||||||
EventValueDescription[] desc = mValueDescriptionMap.get(tagValue);
|
EventValueDescription[] desc = mValueDescriptionMap.get(tagValue);
|
||||||
|
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
// TODO parse and create string values.
|
// TODO parse and create string values.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc.length == 1) {
|
if (desc.length == 1) {
|
||||||
return getObjectFromString(data, desc[0].getEventValueType());
|
return getObjectFromString(data, desc[0].getEventValueType());
|
||||||
} else if (data.startsWith("[") && data.endsWith("]")) {
|
} else if (data.startsWith("[") && data.endsWith("]")) {
|
||||||
data = data.substring(1, data.length() - 1);
|
data = data.substring(1, data.length() - 1);
|
||||||
|
|
||||||
// get each individual values as String
|
// get each individual values as String
|
||||||
String[] values = data.split(",");
|
String[] values = data.split(",");
|
||||||
|
|
||||||
if (tagValue == GcEventContainer.GC_EVENT_TAG) {
|
if (tagValue == GcEventContainer.GC_EVENT_TAG) {
|
||||||
// special case for the GC event!
|
// special case for the GC event!
|
||||||
Object[] objects = new Object[2];
|
Object[] objects = new Object[2];
|
||||||
|
|
||||||
objects[0] = getObjectFromString(values[0], EventValueType.LONG);
|
objects[0] = getObjectFromString(values[0], EventValueType.LONG);
|
||||||
objects[1] = getObjectFromString(values[1], EventValueType.LONG);
|
objects[1] = getObjectFromString(values[1], EventValueType.LONG);
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
} else {
|
} else {
|
||||||
// must be the same number as the number of descriptors.
|
// must be the same number as the number of descriptors.
|
||||||
if (values.length != desc.length) {
|
if (values.length != desc.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] objects = new Object[values.length];
|
Object[] objects = new Object[values.length];
|
||||||
|
|
||||||
for (int i = 0 ; i < desc.length ; i++) {
|
for (int i = 0 ; i < desc.length ; i++) {
|
||||||
Object obj = getObjectFromString(values[i], desc[i].getEventValueType());
|
Object obj = getObjectFromString(values[i], desc[i].getEventValueType());
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
objects[i] = obj;
|
objects[i] = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Object getObjectFromString(String value, EventValueType type) {
|
private Object getObjectFromString(String value, EventValueType type) {
|
||||||
try {
|
try {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -512,14 +512,14 @@ public final class EventLogParser {
|
|||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// do nothing, we'll return null.
|
// do nothing, we'll return null.
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
* @param filePath the file path to write the file.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void saveTags(String filePath) throws IOException {
|
public void saveTags(String filePath) throws IOException {
|
||||||
File destFile = new File(filePath);
|
File destFile = new File(filePath);
|
||||||
@@ -527,16 +527,16 @@ public final class EventLogParser {
|
|||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fos = new FileOutputStream(destFile);
|
fos = new FileOutputStream(destFile);
|
||||||
|
|
||||||
for (Integer key : mTagMap.keySet()) {
|
for (Integer key : mTagMap.keySet()) {
|
||||||
// get the tag name
|
// get the tag name
|
||||||
String tagName = mTagMap.get(key);
|
String tagName = mTagMap.get(key);
|
||||||
|
|
||||||
// get the value descriptions
|
// get the value descriptions
|
||||||
EventValueDescription[] descriptors = mValueDescriptionMap.get(key);
|
EventValueDescription[] descriptors = mValueDescriptionMap.get(key);
|
||||||
|
|
||||||
String line = null;
|
String line = null;
|
||||||
if (descriptors != null) {
|
if (descriptors != null) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -557,12 +557,12 @@ public final class EventLogParser {
|
|||||||
sb.append("|)"); //$NON-NLS-1$
|
sb.append("|)"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
sb.append("\n"); //$NON-NLS-1$
|
sb.append("\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
line = sb.toString();
|
line = sb.toString();
|
||||||
} else {
|
} else {
|
||||||
line = String.format("%1$d %2$s\n", key, tagName); //$NON-NLS-1$
|
line = String.format("%1$d %2$s\n", key, tagName); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] buffer = line.getBytes();
|
byte[] buffer = line.getBytes();
|
||||||
fos.write(buffer);
|
fos.write(buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.android.ddmlib.IDevice;
|
|||||||
import com.android.ddmlib.IShellOutputReceiver;
|
import com.android.ddmlib.IShellOutputReceiver;
|
||||||
import com.android.ddmlib.RawImage;
|
import com.android.ddmlib.RawImage;
|
||||||
import com.android.ddmlib.SyncService;
|
import com.android.ddmlib.SyncService;
|
||||||
import com.android.ddmlib.Device.DeviceState;
|
|
||||||
import com.android.ddmlib.log.LogReceiver;
|
import com.android.ddmlib.log.LogReceiver;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -100,7 +99,7 @@ public class RemoteAndroidTestRunnerTest extends TestCase {
|
|||||||
final String extraArgValue = "blahValue";
|
final String extraArgValue = "blahValue";
|
||||||
mRunner.addInstrumentationArg(extraArgName, extraArgValue);
|
mRunner.addInstrumentationArg(extraArgName, extraArgValue);
|
||||||
mRunner.run(new EmptyListener());
|
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());
|
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.Client;
|
||||||
import com.android.ddmlib.ClientData;
|
import com.android.ddmlib.ClientData;
|
||||||
import com.android.ddmlib.DdmPreferences;
|
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.IClientChangeListener;
|
||||||
import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
|
import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
|
||||||
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
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.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
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_THREAD = 2;
|
||||||
private final static int CLIENT_COL_HEAP = 3;
|
private final static int CLIENT_COL_HEAP = 3;
|
||||||
private final static int CLIENT_COL_PORT = 4;
|
private final static int CLIENT_COL_PORT = 4;
|
||||||
|
|
||||||
public final static int ICON_WIDTH = 16;
|
public final static int ICON_WIDTH = 16;
|
||||||
public final static String ICON_THREAD = "thread.png"; //$NON-NLS-1$
|
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_HEAP = "heap.png"; //$NON-NLS-1$
|
||||||
public final static String ICON_HALT = "halt.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$
|
public final static String ICON_GC = "gc.png"; //$NON-NLS-1$
|
||||||
|
|
||||||
private Device mCurrentDevice;
|
private IDevice mCurrentDevice;
|
||||||
private Client mCurrentClient;
|
private Client mCurrentClient;
|
||||||
|
|
||||||
private Tree mTree;
|
private Tree mTree;
|
||||||
private TreeViewer mTreeViewer;
|
private TreeViewer mTreeViewer;
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
private Image mDebugErrorImage;
|
private Image mDebugErrorImage;
|
||||||
|
|
||||||
private final ArrayList<IUiSelectionListener> mListeners = new ArrayList<IUiSelectionListener>();
|
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;
|
private IImageLoader mLoader;
|
||||||
|
|
||||||
@@ -102,13 +102,13 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
/**
|
/**
|
||||||
* A Content provider for the {@link TreeViewer}.
|
* A Content provider for the {@link TreeViewer}.
|
||||||
* <p/>
|
* <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.
|
* and second level elements are {@link Client} object.
|
||||||
*/
|
*/
|
||||||
private class ContentProvider implements ITreeContentProvider {
|
private class ContentProvider implements ITreeContentProvider {
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
if (parentElement instanceof Device) {
|
if (parentElement instanceof IDevice) {
|
||||||
return ((Device)parentElement).getClients();
|
return ((IDevice)parentElement).getClients();
|
||||||
}
|
}
|
||||||
return new Object[0];
|
return new Object[0];
|
||||||
}
|
}
|
||||||
@@ -121,8 +121,8 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChildren(Object element) {
|
public boolean hasChildren(Object element) {
|
||||||
if (element instanceof Device) {
|
if (element instanceof IDevice) {
|
||||||
return ((Device)element).hasClients();
|
return ((IDevice)element).hasClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clients never have children.
|
// 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
|
* 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 {
|
private class LabelProvider implements ITableLabelProvider {
|
||||||
|
|
||||||
public Image getColumnImage(Object element, int columnIndex) {
|
public Image getColumnImage(Object element, int columnIndex) {
|
||||||
if (columnIndex == DEVICE_COL_SERIAL && element instanceof Device) {
|
if (columnIndex == DEVICE_COL_SERIAL && element instanceof IDevice) {
|
||||||
Device device = (Device)element;
|
IDevice device = (IDevice)element;
|
||||||
if (device.isEmulator()) {
|
if (device.isEmulator()) {
|
||||||
return mEmulatorImage;
|
return mEmulatorImage;
|
||||||
}
|
}
|
||||||
@@ -192,17 +192,17 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnText(Object element, int columnIndex) {
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
if (element instanceof Device) {
|
if (element instanceof IDevice) {
|
||||||
Device device = (Device)element;
|
IDevice device = (IDevice)element;
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case DEVICE_COL_SERIAL:
|
case DEVICE_COL_SERIAL:
|
||||||
return device.getSerialNumber();
|
return device.getSerialNumber();
|
||||||
case DEVICE_COL_STATE:
|
case DEVICE_COL_STATE:
|
||||||
return getStateString(device);
|
return getStateString(device);
|
||||||
case DEVICE_COL_BUILD: {
|
case DEVICE_COL_BUILD: {
|
||||||
String version = device.getProperty(Device.PROP_BUILD_VERSION);
|
String version = device.getProperty(IDevice.PROP_BUILD_VERSION);
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
String debuggable = device.getProperty(Device.PROP_DEBUGGABLE);
|
String debuggable = device.getProperty(IDevice.PROP_DEBUGGABLE);
|
||||||
if (device.isEmulator()) {
|
if (device.isEmulator()) {
|
||||||
String avdName = device.getAvdName();
|
String avdName = device.getAvdName();
|
||||||
if (avdName == null) {
|
if (avdName == null) {
|
||||||
@@ -279,15 +279,15 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes which implement this interface provide methods that deals
|
* 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 {
|
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 selectedDevice the selected device. If null, no devices are selected.
|
||||||
* @param selectedClient The selected client. If null, no clients 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;
|
return mTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the focus to the proper control inside the panel.
|
* Sets the focus to the proper control inside the panel.
|
||||||
*/
|
*/
|
||||||
@@ -371,7 +371,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
@Override
|
@Override
|
||||||
protected void postCreation() {
|
protected void postCreation() {
|
||||||
// ask for notification of changes in AndroidDebugBridge (a new one is created when
|
// 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.addDebugBridgeChangeListener(this);
|
||||||
AndroidDebugBridge.addDeviceChangeListener(this);
|
AndroidDebugBridge.addDeviceChangeListener(this);
|
||||||
AndroidDebugBridge.addClientChangeListener(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
|
* Returns the selected {@link IDevice}. If a {@link Client} is selected, it returns the
|
||||||
* Device object containing the client.
|
* IDevice object containing the client.
|
||||||
*/
|
*/
|
||||||
public Device getSelectedDevice() {
|
public IDevice getSelectedDevice() {
|
||||||
return mCurrentDevice;
|
return mCurrentDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
public void killSelectedClient() {
|
public void killSelectedClient() {
|
||||||
if (mCurrentClient != null) {
|
if (mCurrentClient != null) {
|
||||||
Client client = mCurrentClient;
|
Client client = mCurrentClient;
|
||||||
|
|
||||||
// reset the selection to the device.
|
// reset the selection to the device.
|
||||||
TreePath treePath = new TreePath(new Object[] { mCurrentDevice });
|
TreePath treePath = new TreePath(new Object[] { mCurrentDevice });
|
||||||
TreeSelection treeSelection = new TreeSelection(treePath);
|
TreeSelection treeSelection = new TreeSelection(treePath);
|
||||||
@@ -413,7 +413,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
client.kill();
|
client.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forces a GC on the selected {@link Client}.
|
* Forces a GC on the selected {@link Client}.
|
||||||
*/
|
*/
|
||||||
@@ -422,13 +422,13 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
mCurrentClient.executeGarbageCollector();
|
mCurrentClient.executeGarbageCollector();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabledHeapOnSelectedClient(boolean enable) {
|
public void setEnabledHeapOnSelectedClient(boolean enable) {
|
||||||
if (mCurrentClient != null) {
|
if (mCurrentClient != null) {
|
||||||
mCurrentClient.setHeapUpdateEnabled(enable);
|
mCurrentClient.setHeapUpdateEnabled(enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabledThreadOnSelectedClient(boolean enable) {
|
public void setEnabledThreadOnSelectedClient(boolean enable) {
|
||||||
if (mCurrentClient != null) {
|
if (mCurrentClient != null) {
|
||||||
mCurrentClient.setThreadUpdateEnabled(enable);
|
mCurrentClient.setThreadUpdateEnabled(enable);
|
||||||
@@ -476,9 +476,9 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @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() {
|
exec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mTree.isDisposed() == false) {
|
if (mTree.isDisposed() == false) {
|
||||||
@@ -511,11 +511,11 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @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);
|
deviceConnected(device);
|
||||||
|
|
||||||
// just in case, we remove it from the list of devices to expand.
|
// just in case, we remove it from the list of devices to expand.
|
||||||
synchronized (mDevicesToExpand) {
|
synchronized (mDevicesToExpand) {
|
||||||
mDevicesToExpand.remove(device);
|
mDevicesToExpand.remove(device);
|
||||||
@@ -529,9 +529,9 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
* @param device the device that was updated.
|
* @param device the device that was updated.
|
||||||
* @param changeMask the mask indicating what changed.
|
* @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;
|
boolean expand = false;
|
||||||
synchronized (mDevicesToExpand) {
|
synchronized (mDevicesToExpand) {
|
||||||
int index = mDevicesToExpand.indexOf(device);
|
int index = mDevicesToExpand.indexOf(device);
|
||||||
@@ -540,7 +540,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
expand = true;
|
expand = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean finalExpand = expand;
|
final boolean finalExpand = expand;
|
||||||
|
|
||||||
exec(new Runnable() {
|
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
|
// 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
|
// client of this particular device was killed. In this case, we'll need to
|
||||||
// manually reselect the device.
|
// manually reselect the device.
|
||||||
|
|
||||||
Device selectedDevice = getSelectedDevice();
|
IDevice selectedDevice = getSelectedDevice();
|
||||||
|
|
||||||
// refresh the device
|
// refresh the device
|
||||||
mTreeViewer.refresh(device);
|
mTreeViewer.refresh(device);
|
||||||
|
|
||||||
// if the selected device was the changed device and the new selection is
|
// if the selected device was the changed device and the new selection is
|
||||||
// empty, we reselect the device.
|
// empty, we reselect the device.
|
||||||
if (selectedDevice == device && mTreeViewer.getSelection().isEmpty()) {
|
if (selectedDevice == device && mTreeViewer.getSelection().isEmpty()) {
|
||||||
mTreeViewer.setSelection(new TreeSelection(new TreePath(
|
mTreeViewer.setSelection(new TreeSelection(new TreePath(
|
||||||
new Object[] { device })));
|
new Object[] { device })));
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify the listener of a possible selection change.
|
// notify the listener of a possible selection change.
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
if (finalExpand) {
|
if (finalExpand) {
|
||||||
mTreeViewer.setExpandedState(device, true);
|
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
|
// make sure the device is expanded. Normally the setSelection below
|
||||||
// will auto expand, but the children of device may not already exist
|
// will auto expand, but the children of device may not already exist
|
||||||
// at this time. Forcing an expand will make the TreeViewer create them.
|
// 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) {
|
if (mTreeViewer.getExpandedState(device) == false) {
|
||||||
mTreeViewer.setExpandedState(device, true);
|
mTreeViewer.setExpandedState(device, true);
|
||||||
}
|
}
|
||||||
@@ -615,11 +615,11 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
TreePath treePath = new TreePath(new Object[] { device, client});
|
TreePath treePath = new TreePath(new Object[] { device, client});
|
||||||
TreeSelection treeSelection = new TreeSelection(treePath);
|
TreeSelection treeSelection = new TreeSelection(treePath);
|
||||||
mTreeViewer.setSelection(treeSelection);
|
mTreeViewer.setSelection(treeSelection);
|
||||||
|
|
||||||
if (mAdvancedPortSupport) {
|
if (mAdvancedPortSupport) {
|
||||||
client.setAsSelectedClient();
|
client.setAsSelectedClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify the listener of a possible selection change.
|
// notify the listener of a possible selection change.
|
||||||
notifyListeners(device, client);
|
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.
|
* Returns a display string representing the state of the device.
|
||||||
* @param d the device
|
* @param d the device
|
||||||
*/
|
*/
|
||||||
private static String getStateString(Device d) {
|
private static String getStateString(IDevice d) {
|
||||||
DeviceState deviceState = d.getState();
|
DeviceState deviceState = d.getState();
|
||||||
if (deviceState == DeviceState.ONLINE) {
|
if (deviceState == DeviceState.ONLINE) {
|
||||||
return "Online";
|
return "Online";
|
||||||
@@ -704,32 +704,32 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
|
|||||||
AndroidDebugBridge.removeClientChangeListener(this);
|
AndroidDebugBridge.removeClientChangeListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyListeners() {
|
private void notifyListeners() {
|
||||||
// get the selection
|
// get the selection
|
||||||
TreeItem[] items = mTree.getSelection();
|
TreeItem[] items = mTree.getSelection();
|
||||||
|
|
||||||
Client client = null;
|
Client client = null;
|
||||||
Device device = null;
|
IDevice device = null;
|
||||||
|
|
||||||
if (items.length == 1) {
|
if (items.length == 1) {
|
||||||
Object object = items[0].getData();
|
Object object = items[0].getData();
|
||||||
if (object instanceof Client) {
|
if (object instanceof Client) {
|
||||||
client = (Client)object;
|
client = (Client)object;
|
||||||
device = client.getDevice();
|
device = client.getDevice();
|
||||||
} else if (object instanceof Device) {
|
} else if (object instanceof IDevice) {
|
||||||
device = (Device)object;
|
device = (IDevice)object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyListeners(device, client);
|
notifyListeners(device, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyListeners(Device selectedDevice, Client selectedClient) {
|
private void notifyListeners(IDevice selectedDevice, Client selectedClient) {
|
||||||
if (selectedDevice != mCurrentDevice || selectedClient != mCurrentClient) {
|
if (selectedDevice != mCurrentDevice || selectedClient != mCurrentClient) {
|
||||||
mCurrentDevice = selectedDevice;
|
mCurrentDevice = selectedDevice;
|
||||||
mCurrentClient = selectedClient;
|
mCurrentClient = selectedClient;
|
||||||
|
|
||||||
for (IUiSelectionListener listener : mListeners) {
|
for (IUiSelectionListener listener : mListeners) {
|
||||||
// notify the listener with a try/catch-all to make sure this thread won't die
|
// 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.
|
// 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;
|
package com.android.ddmuilib;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.EmulatorConsole;
|
import com.android.ddmlib.EmulatorConsole;
|
||||||
import com.android.ddmlib.EmulatorConsole.GsmMode;
|
import com.android.ddmlib.EmulatorConsole.GsmMode;
|
||||||
import com.android.ddmlib.EmulatorConsole.GsmStatus;
|
import com.android.ddmlib.EmulatorConsole.GsmStatus;
|
||||||
@@ -75,7 +75,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
// default location: Patio outside Charlie's
|
// default location: Patio outside Charlie's
|
||||||
private final static double DEFAULT_LONGITUDE = -122.084095;
|
private final static double DEFAULT_LONGITUDE = -122.084095;
|
||||||
private final static double DEFAULT_LATITUDE = 37.422006;
|
private final static double DEFAULT_LATITUDE = 37.422006;
|
||||||
|
|
||||||
private final static String SPEED_FORMAT = "Speed: %1$dX";
|
private final static String SPEED_FORMAT = "Speed: %1$dX";
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
"EDGE",
|
"EDGE",
|
||||||
"UMTS",
|
"UMTS",
|
||||||
};
|
};
|
||||||
|
|
||||||
private final static int[] PLAY_SPEEDS = new int[] { 1, 2, 5, 10, 20, 50 };
|
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$
|
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 Button mCancelButton;
|
||||||
|
|
||||||
private TabFolder mLocationFolders;
|
private TabFolder mLocationFolders;
|
||||||
|
|
||||||
private Button mDecimalButton;
|
private Button mDecimalButton;
|
||||||
private Button mSexagesimalButton;
|
private Button mSexagesimalButton;
|
||||||
private CoordinateControls mLongitudeControls;
|
private CoordinateControls mLongitudeControls;
|
||||||
@@ -177,7 +177,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
private int mPlayDirection = 1;
|
private int mPlayDirection = 1;
|
||||||
private int mSpeed;
|
private int mSpeed;
|
||||||
private int mSpeedIndex;
|
private int mSpeedIndex;
|
||||||
|
|
||||||
private final SelectionAdapter mDirectionButtonAdapter = new SelectionAdapter() {
|
private final SelectionAdapter mDirectionButtonAdapter = new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
@@ -188,7 +188,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
b.setSelection(true);
|
b.setSelection(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now handle selection change.
|
// now handle selection change.
|
||||||
if (b == mGpxForwardButton || b == mKmlForwardButton) {
|
if (b == mGpxForwardButton || b == mKmlForwardButton) {
|
||||||
mGpxBackwardButton.setSelection(false);
|
mGpxBackwardButton.setSelection(false);
|
||||||
@@ -196,7 +196,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
mKmlBackwardButton.setSelection(false);
|
mKmlBackwardButton.setSelection(false);
|
||||||
mKmlForwardButton.setSelection(true);
|
mKmlForwardButton.setSelection(true);
|
||||||
mPlayDirection = 1;
|
mPlayDirection = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mGpxBackwardButton.setSelection(true);
|
mGpxBackwardButton.setSelection(true);
|
||||||
mGpxForwardButton.setSelection(false);
|
mGpxForwardButton.setSelection(false);
|
||||||
@@ -206,27 +206,27 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final SelectionAdapter mSpeedButtonAdapter = new SelectionAdapter() {
|
private final SelectionAdapter mSpeedButtonAdapter = new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
mSpeedIndex = (mSpeedIndex+1) % PLAY_SPEEDS.length;
|
mSpeedIndex = (mSpeedIndex+1) % PLAY_SPEEDS.length;
|
||||||
mSpeed = PLAY_SPEEDS[mSpeedIndex];
|
mSpeed = PLAY_SPEEDS[mSpeedIndex];
|
||||||
|
|
||||||
mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||||
mGpxPlayControls.pack();
|
mGpxPlayControls.pack();
|
||||||
mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||||
mKmlPlayControls.pack();
|
mKmlPlayControls.pack();
|
||||||
|
|
||||||
if (mPlayingThread != null) {
|
if (mPlayingThread != null) {
|
||||||
mPlayingThread.interrupt();
|
mPlayingThread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private Composite mKmlPlayControls;
|
private Composite mKmlPlayControls;
|
||||||
private Composite mGpxPlayControls;
|
private Composite mGpxPlayControls;
|
||||||
|
|
||||||
|
|
||||||
public EmulatorControlPanel(IImageLoader imageLoader) {
|
public EmulatorControlPanel(IImageLoader imageLoader) {
|
||||||
mImageLoader = imageLoader;
|
mImageLoader = imageLoader;
|
||||||
}
|
}
|
||||||
@@ -274,11 +274,11 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
scollingParent.setMinSize(top.computeSize(r.width, SWT.DEFAULT));
|
scollingParent.setMinSize(top.computeSize(r.width, SWT.DEFAULT));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
createRadioControls(top);
|
createRadioControls(top);
|
||||||
|
|
||||||
createCallControls(top);
|
createCallControls(top);
|
||||||
|
|
||||||
createLocationControls(top);
|
createLocationControls(top);
|
||||||
|
|
||||||
doEnable(false);
|
doEnable(false);
|
||||||
@@ -379,7 +379,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
Label l = new Label(g1, SWT.NONE);
|
Label l = new Label(g1, SWT.NONE);
|
||||||
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Voice/SMS call/hang up controls
|
* Create Voice/SMS call/hang up controls
|
||||||
* @param top
|
* @param top
|
||||||
@@ -517,7 +517,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Location controls.
|
* Create Location controls.
|
||||||
* @param top
|
* @param top
|
||||||
@@ -526,15 +526,15 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
Label l = new Label(top, SWT.NONE);
|
Label l = new Label(top, SWT.NONE);
|
||||||
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
l.setText("Location Controls");
|
l.setText("Location Controls");
|
||||||
|
|
||||||
mLocationFolders = new TabFolder(top, SWT.NONE);
|
mLocationFolders = new TabFolder(top, SWT.NONE);
|
||||||
mLocationFolders.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
mLocationFolders.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
|
||||||
Composite manualLocationComp = new Composite(mLocationFolders, SWT.NONE);
|
Composite manualLocationComp = new Composite(mLocationFolders, SWT.NONE);
|
||||||
TabItem item = new TabItem(mLocationFolders, SWT.NONE);
|
TabItem item = new TabItem(mLocationFolders, SWT.NONE);
|
||||||
item.setText("Manual");
|
item.setText("Manual");
|
||||||
item.setControl(manualLocationComp);
|
item.setControl(manualLocationComp);
|
||||||
|
|
||||||
createManualLocationControl(manualLocationComp);
|
createManualLocationControl(manualLocationComp);
|
||||||
|
|
||||||
mPlayImage = mImageLoader.loadImage("play.png", mParent.getDisplay()); // $NON-NLS-1$
|
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 = new TabItem(mLocationFolders, SWT.NONE);
|
||||||
item.setText("GPX");
|
item.setText("GPX");
|
||||||
item.setControl(gpxLocationComp);
|
item.setControl(gpxLocationComp);
|
||||||
|
|
||||||
createGpxLocationControl(gpxLocationComp);
|
createGpxLocationControl(gpxLocationComp);
|
||||||
|
|
||||||
Composite kmlLocationComp = new Composite(mLocationFolders, SWT.NONE);
|
Composite kmlLocationComp = new Composite(mLocationFolders, SWT.NONE);
|
||||||
@@ -552,7 +552,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
item = new TabItem(mLocationFolders, SWT.NONE);
|
item = new TabItem(mLocationFolders, SWT.NONE);
|
||||||
item.setText("KML");
|
item.setText("KML");
|
||||||
item.setControl(kmlLocationComp);
|
item.setControl(kmlLocationComp);
|
||||||
|
|
||||||
createKmlLocationControl(kmlLocationComp);
|
createKmlLocationControl(kmlLocationComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,63 +572,63 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
// composite to hold and switching between the 2 modes.
|
// composite to hold and switching between the 2 modes.
|
||||||
final Composite content = new Composite(manualLocationComp, SWT.NONE);
|
final Composite content = new Composite(manualLocationComp, SWT.NONE);
|
||||||
content.setLayout(sl = new StackLayout());
|
content.setLayout(sl = new StackLayout());
|
||||||
|
|
||||||
// decimal display
|
// decimal display
|
||||||
final Composite decimalContent = new Composite(content, SWT.NONE);
|
final Composite decimalContent = new Composite(content, SWT.NONE);
|
||||||
decimalContent.setLayout(gl = new GridLayout(2, false));
|
decimalContent.setLayout(gl = new GridLayout(2, false));
|
||||||
gl.marginHeight = gl.marginWidth = 0;
|
gl.marginHeight = gl.marginWidth = 0;
|
||||||
|
|
||||||
mLongitudeControls = new CoordinateControls();
|
mLongitudeControls = new CoordinateControls();
|
||||||
mLatitudeControls = new CoordinateControls();
|
mLatitudeControls = new CoordinateControls();
|
||||||
|
|
||||||
label = new Label(decimalContent, SWT.NONE);
|
label = new Label(decimalContent, SWT.NONE);
|
||||||
label.setText("Longitude");
|
label.setText("Longitude");
|
||||||
|
|
||||||
mLongitudeControls.createDecimalText(decimalContent);
|
mLongitudeControls.createDecimalText(decimalContent);
|
||||||
|
|
||||||
label = new Label(decimalContent, SWT.NONE);
|
label = new Label(decimalContent, SWT.NONE);
|
||||||
label.setText("Latitude");
|
label.setText("Latitude");
|
||||||
|
|
||||||
mLatitudeControls.createDecimalText(decimalContent);
|
mLatitudeControls.createDecimalText(decimalContent);
|
||||||
|
|
||||||
// sexagesimal content
|
// sexagesimal content
|
||||||
final Composite sexagesimalContent = new Composite(content, SWT.NONE);
|
final Composite sexagesimalContent = new Composite(content, SWT.NONE);
|
||||||
sexagesimalContent.setLayout(gl = new GridLayout(7, false));
|
sexagesimalContent.setLayout(gl = new GridLayout(7, false));
|
||||||
gl.marginHeight = gl.marginWidth = 0;
|
gl.marginHeight = gl.marginWidth = 0;
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("Longitude");
|
label.setText("Longitude");
|
||||||
|
|
||||||
mLongitudeControls.createSexagesimalDegreeText(sexagesimalContent);
|
mLongitudeControls.createSexagesimalDegreeText(sexagesimalContent);
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("\u00B0"); // degree character
|
label.setText("\u00B0"); // degree character
|
||||||
|
|
||||||
mLongitudeControls.createSexagesimalMinuteText(sexagesimalContent);
|
mLongitudeControls.createSexagesimalMinuteText(sexagesimalContent);
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("'");
|
label.setText("'");
|
||||||
|
|
||||||
mLongitudeControls.createSexagesimalSecondText(sexagesimalContent);
|
mLongitudeControls.createSexagesimalSecondText(sexagesimalContent);
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("\"");
|
label.setText("\"");
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("Latitude");
|
label.setText("Latitude");
|
||||||
|
|
||||||
mLatitudeControls.createSexagesimalDegreeText(sexagesimalContent);
|
mLatitudeControls.createSexagesimalDegreeText(sexagesimalContent);
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("\u00B0");
|
label.setText("\u00B0");
|
||||||
|
|
||||||
mLatitudeControls.createSexagesimalMinuteText(sexagesimalContent);
|
mLatitudeControls.createSexagesimalMinuteText(sexagesimalContent);
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("'");
|
label.setText("'");
|
||||||
|
|
||||||
mLatitudeControls.createSexagesimalSecondText(sexagesimalContent);
|
mLatitudeControls.createSexagesimalSecondText(sexagesimalContent);
|
||||||
|
|
||||||
label = new Label(sexagesimalContent, SWT.NONE);
|
label = new Label(sexagesimalContent, SWT.NONE);
|
||||||
label.setText("\"");
|
label.setText("\"");
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
content.layout();
|
content.layout();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button sendButton = new Button(manualLocationComp, SWT.PUSH);
|
Button sendButton = new Button(manualLocationComp, SWT.PUSH);
|
||||||
sendButton.setText("Send");
|
sendButton.setText("Send");
|
||||||
sendButton.addSelectionListener(new SelectionAdapter() {
|
sendButton.addSelectionListener(new SelectionAdapter() {
|
||||||
@@ -659,7 +659,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mLongitudeControls.setValue(DEFAULT_LONGITUDE);
|
mLongitudeControls.setValue(DEFAULT_LONGITUDE);
|
||||||
mLatitudeControls.setValue(DEFAULT_LATITUDE);
|
mLatitudeControls.setValue(DEFAULT_LATITUDE);
|
||||||
}
|
}
|
||||||
@@ -681,7 +681,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
gd.heightHint = 100;
|
gd.heightHint = 100;
|
||||||
mGpxWayPointTable.setHeaderVisible(true);
|
mGpxWayPointTable.setHeaderVisible(true);
|
||||||
mGpxWayPointTable.setLinesVisible(true);
|
mGpxWayPointTable.setLinesVisible(true);
|
||||||
|
|
||||||
TableHelper.createTableColumn(mGpxWayPointTable, "Name", SWT.LEFT,
|
TableHelper.createTableColumn(mGpxWayPointTable, "Name", SWT.LEFT,
|
||||||
"Some Name",
|
"Some Name",
|
||||||
PREFS_WAYPOINT_COL_NAME, store);
|
PREFS_WAYPOINT_COL_NAME, store);
|
||||||
@@ -701,7 +701,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
final TableViewer gpxWayPointViewer = new TableViewer(mGpxWayPointTable);
|
final TableViewer gpxWayPointViewer = new TableViewer(mGpxWayPointTable);
|
||||||
gpxWayPointViewer.setContentProvider(new WayPointContentProvider());
|
gpxWayPointViewer.setContentProvider(new WayPointContentProvider());
|
||||||
gpxWayPointViewer.setLabelProvider(new WayPointLabelProvider());
|
gpxWayPointViewer.setLabelProvider(new WayPointLabelProvider());
|
||||||
|
|
||||||
gpxWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
gpxWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
ISelection selection = event.getSelection();
|
ISelection selection = event.getSelection();
|
||||||
@@ -710,7 +710,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
Object selectedObject = structuredSelection.getFirstElement();
|
Object selectedObject = structuredSelection.getFirstElement();
|
||||||
if (selectedObject instanceof WayPoint) {
|
if (selectedObject instanceof WayPoint) {
|
||||||
WayPoint wayPoint = (WayPoint)selectedObject;
|
WayPoint wayPoint = (WayPoint)selectedObject;
|
||||||
|
|
||||||
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
||||||
processCommandResult(mEmulatorConsole.sendLocation(
|
processCommandResult(mEmulatorConsole.sendLocation(
|
||||||
wayPoint.getLongitude(), wayPoint.getLatitude(),
|
wayPoint.getLongitude(), wayPoint.getLatitude(),
|
||||||
@@ -748,7 +748,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
final TableViewer gpxTrackViewer = new TableViewer(mGpxTrackTable);
|
final TableViewer gpxTrackViewer = new TableViewer(mGpxTrackTable);
|
||||||
gpxTrackViewer.setContentProvider(new TrackContentProvider());
|
gpxTrackViewer.setContentProvider(new TrackContentProvider());
|
||||||
gpxTrackViewer.setLabelProvider(new TrackLabelProvider());
|
gpxTrackViewer.setLabelProvider(new TrackLabelProvider());
|
||||||
|
|
||||||
gpxTrackViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
gpxTrackViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
ISelection selection = event.getSelection();
|
ISelection selection = event.getSelection();
|
||||||
@@ -757,19 +757,19 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
Object selectedObject = structuredSelection.getFirstElement();
|
Object selectedObject = structuredSelection.getFirstElement();
|
||||||
if (selectedObject instanceof Track) {
|
if (selectedObject instanceof Track) {
|
||||||
Track track = (Track)selectedObject;
|
Track track = (Track)selectedObject;
|
||||||
|
|
||||||
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
||||||
TrackPoint[] points = track.getPoints();
|
TrackPoint[] points = track.getPoints();
|
||||||
processCommandResult(mEmulatorConsole.sendLocation(
|
processCommandResult(mEmulatorConsole.sendLocation(
|
||||||
points[0].getLongitude(), points[0].getLatitude(),
|
points[0].getLongitude(), points[0].getLatitude(),
|
||||||
points[0].getElevation()));
|
points[0].getElevation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
mPlayGpxButton.setEnabled(true);
|
mPlayGpxButton.setEnabled(true);
|
||||||
mGpxBackwardButton.setEnabled(true);
|
mGpxBackwardButton.setEnabled(true);
|
||||||
mGpxForwardButton.setEnabled(true);
|
mGpxForwardButton.setEnabled(true);
|
||||||
mGpxSpeedButton.setEnabled(true);
|
mGpxSpeedButton.setEnabled(true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -780,7 +780,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
mGpxSpeedButton.setEnabled(false);
|
mGpxSpeedButton.setEnabled(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mGpxUploadButton.addSelectionListener(new SelectionAdapter() {
|
mGpxUploadButton.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
@@ -799,7 +799,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mGpxPlayControls = new Composite(gpxLocationComp, SWT.NONE);
|
mGpxPlayControls = new Composite(gpxLocationComp, SWT.NONE);
|
||||||
GridLayout gl;
|
GridLayout gl;
|
||||||
mGpxPlayControls.setLayout(gl = new GridLayout(5, false));
|
mGpxPlayControls.setLayout(gl = new GridLayout(5, false));
|
||||||
@@ -828,14 +828,14 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
mPlayingThread.interrupt();
|
mPlayingThread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Label separator = new Label(mGpxPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
|
Label separator = new Label(mGpxPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
|
||||||
separator.setLayoutData(gd = new GridData(
|
separator.setLayoutData(gd = new GridData(
|
||||||
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
|
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
|
||||||
gd.heightHint = 0;
|
gd.heightHint = 0;
|
||||||
|
|
||||||
mGpxBackwardButton = new Button(mGpxPlayControls, SWT.TOGGLE | SWT.FLAT);
|
mGpxBackwardButton = new Button(mGpxPlayControls, SWT.TOGGLE | SWT.FLAT);
|
||||||
mGpxBackwardButton.setImage(mImageLoader.loadImage("backward.png", mParent.getDisplay())); // $NON-NLS-1$
|
mGpxBackwardButton.setImage(mImageLoader.loadImage("backward.png", mParent.getDisplay())); // $NON-NLS-1$
|
||||||
mGpxBackwardButton.setSelection(false);
|
mGpxBackwardButton.setSelection(false);
|
||||||
@@ -852,7 +852,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
|
|
||||||
mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||||
mGpxSpeedButton.addSelectionListener(mSpeedButtonAdapter);
|
mGpxSpeedButton.addSelectionListener(mSpeedButtonAdapter);
|
||||||
|
|
||||||
mPlayGpxButton.setEnabled(false);
|
mPlayGpxButton.setEnabled(false);
|
||||||
mGpxBackwardButton.setEnabled(false);
|
mGpxBackwardButton.setEnabled(false);
|
||||||
mGpxForwardButton.setEnabled(false);
|
mGpxForwardButton.setEnabled(false);
|
||||||
@@ -877,7 +877,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
gd.heightHint = 200;
|
gd.heightHint = 200;
|
||||||
mKmlWayPointTable.setHeaderVisible(true);
|
mKmlWayPointTable.setHeaderVisible(true);
|
||||||
mKmlWayPointTable.setLinesVisible(true);
|
mKmlWayPointTable.setLinesVisible(true);
|
||||||
|
|
||||||
TableHelper.createTableColumn(mKmlWayPointTable, "Name", SWT.LEFT,
|
TableHelper.createTableColumn(mKmlWayPointTable, "Name", SWT.LEFT,
|
||||||
"Some Name",
|
"Some Name",
|
||||||
PREFS_WAYPOINT_COL_NAME, store);
|
PREFS_WAYPOINT_COL_NAME, store);
|
||||||
@@ -911,7 +911,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
KmlParser parser = new KmlParser(fileName);
|
KmlParser parser = new KmlParser(fileName);
|
||||||
if (parser.parse()) {
|
if (parser.parse()) {
|
||||||
kmlWayPointViewer.setInput(parser.getWayPoints());
|
kmlWayPointViewer.setInput(parser.getWayPoints());
|
||||||
|
|
||||||
mPlayKmlButton.setEnabled(true);
|
mPlayKmlButton.setEnabled(true);
|
||||||
mKmlBackwardButton.setEnabled(true);
|
mKmlBackwardButton.setEnabled(true);
|
||||||
mKmlForwardButton.setEnabled(true);
|
mKmlForwardButton.setEnabled(true);
|
||||||
@@ -920,7 +920,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
kmlWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
kmlWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
ISelection selection = event.getSelection();
|
ISelection selection = event.getSelection();
|
||||||
@@ -929,7 +929,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
Object selectedObject = structuredSelection.getFirstElement();
|
Object selectedObject = structuredSelection.getFirstElement();
|
||||||
if (selectedObject instanceof WayPoint) {
|
if (selectedObject instanceof WayPoint) {
|
||||||
WayPoint wayPoint = (WayPoint)selectedObject;
|
WayPoint wayPoint = (WayPoint)selectedObject;
|
||||||
|
|
||||||
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
if (mEmulatorConsole != null && mPlayingTrack == false) {
|
||||||
processCommandResult(mEmulatorConsole.sendLocation(
|
processCommandResult(mEmulatorConsole.sendLocation(
|
||||||
wayPoint.getLongitude(), wayPoint.getLatitude(),
|
wayPoint.getLongitude(), wayPoint.getLatitude(),
|
||||||
@@ -939,9 +939,9 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mKmlPlayControls = new Composite(kmlLocationComp, SWT.NONE);
|
mKmlPlayControls = new Composite(kmlLocationComp, SWT.NONE);
|
||||||
GridLayout gl;
|
GridLayout gl;
|
||||||
mKmlPlayControls.setLayout(gl = new GridLayout(5, false));
|
mKmlPlayControls.setLayout(gl = new GridLayout(5, false));
|
||||||
@@ -965,14 +965,14 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
mPlayingThread.interrupt();
|
mPlayingThread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Label separator = new Label(mKmlPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
|
Label separator = new Label(mKmlPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
|
||||||
separator.setLayoutData(gd = new GridData(
|
separator.setLayoutData(gd = new GridData(
|
||||||
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
|
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
|
||||||
gd.heightHint = 0;
|
gd.heightHint = 0;
|
||||||
|
|
||||||
mKmlBackwardButton = new Button(mKmlPlayControls, SWT.TOGGLE | SWT.FLAT);
|
mKmlBackwardButton = new Button(mKmlPlayControls, SWT.TOGGLE | SWT.FLAT);
|
||||||
mKmlBackwardButton.setImage(mImageLoader.loadImage("backward.png", mParent.getDisplay())); // $NON-NLS-1$
|
mKmlBackwardButton.setImage(mImageLoader.loadImage("backward.png", mParent.getDisplay())); // $NON-NLS-1$
|
||||||
mKmlBackwardButton.setSelection(false);
|
mKmlBackwardButton.setSelection(false);
|
||||||
@@ -989,7 +989,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
|
|
||||||
mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
|
||||||
mKmlSpeedButton.addSelectionListener(mSpeedButtonAdapter);
|
mKmlSpeedButton.addSelectionListener(mSpeedButtonAdapter);
|
||||||
|
|
||||||
mPlayKmlButton.setEnabled(false);
|
mPlayKmlButton.setEnabled(false);
|
||||||
mKmlBackwardButton.setEnabled(false);
|
mKmlBackwardButton.setEnabled(false);
|
||||||
mKmlForwardButton.setEnabled(false);
|
mKmlForwardButton.setEnabled(false);
|
||||||
@@ -1039,7 +1039,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
* Callback on device selection change.
|
* Callback on device selection change.
|
||||||
* @param device the new selected device
|
* @param device the new selected device
|
||||||
*/
|
*/
|
||||||
public void handleNewDevice(Device device) {
|
public void handleNewDevice(IDevice device) {
|
||||||
if (mParent.isDisposed()) {
|
if (mParent.isDisposed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1061,7 +1061,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
// get the gsm status
|
// get the gsm status
|
||||||
gsm = mEmulatorConsole.getGsmStatus();
|
gsm = mEmulatorConsole.getGsmStatus();
|
||||||
netstatus = mEmulatorConsole.getNetworkStatus();
|
netstatus = mEmulatorConsole.getNetworkStatus();
|
||||||
|
|
||||||
if (gsm == null || netstatus == null) {
|
if (gsm == null || netstatus == null) {
|
||||||
mEmulatorConsole = null;
|
mEmulatorConsole = null;
|
||||||
}
|
}
|
||||||
@@ -1073,7 +1073,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
if (d.isDisposed() == false) {
|
if (d.isDisposed() == false) {
|
||||||
final GsmStatus f_gsm = gsm;
|
final GsmStatus f_gsm = gsm;
|
||||||
final NetworkStatus f_netstatus = netstatus;
|
final NetworkStatus f_netstatus = netstatus;
|
||||||
|
|
||||||
d.asyncExec(new Runnable() {
|
d.asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (f_gsm.voice != GsmMode.UNKNOWN) {
|
if (f_gsm.voice != GsmMode.UNKNOWN) {
|
||||||
@@ -1109,7 +1109,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
enable = mEmulatorConsole != null;
|
enable = mEmulatorConsole != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable(enable);
|
enable(enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1240,10 +1240,10 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
} catch (SWTException e) {
|
} catch (SWTException e) {
|
||||||
// we're quitting, just ignore
|
// we're quitting, just ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1264,13 +1264,13 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
try {
|
try {
|
||||||
TrackPoint[] trackPoints = track.getPoints();
|
TrackPoint[] trackPoints = track.getPoints();
|
||||||
int count = trackPoints.length;
|
int count = trackPoints.length;
|
||||||
|
|
||||||
// get the start index.
|
// get the start index.
|
||||||
int start = 0;
|
int start = 0;
|
||||||
if (mPlayDirection == -1) {
|
if (mPlayDirection == -1) {
|
||||||
start = count - 1;
|
start = count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
|
for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
|
||||||
if (mPlayingTrack == false) {
|
if (mPlayingTrack == false) {
|
||||||
return;
|
return;
|
||||||
@@ -1299,7 +1299,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
delta = -delta;
|
delta = -delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1308,7 +1308,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
if (mPlayingTrack == false) {
|
if (mPlayingTrack == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we got interrupted, lets make sure we can play
|
// we got interrupted, lets make sure we can play
|
||||||
do {
|
do {
|
||||||
long waited = System.currentTimeMillis() - startTime;
|
long waited = System.currentTimeMillis() - startTime;
|
||||||
@@ -1351,7 +1351,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
mPlayingThread.start();
|
mPlayingThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playKml(final WayPoint[] trackPoints) {
|
private void playKml(final WayPoint[] trackPoints) {
|
||||||
// no need to synchronize this check, the worst that can happen, is we start the thread
|
// no need to synchronize this check, the worst that can happen, is we start the thread
|
||||||
// for nothing.
|
// for nothing.
|
||||||
@@ -1365,13 +1365,13 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
int count = trackPoints.length;
|
int count = trackPoints.length;
|
||||||
|
|
||||||
// get the start index.
|
// get the start index.
|
||||||
int start = 0;
|
int start = 0;
|
||||||
if (mPlayDirection == -1) {
|
if (mPlayDirection == -1) {
|
||||||
start = count - 1;
|
start = count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
|
for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
|
||||||
if (mPlayingTrack == false) {
|
if (mPlayingTrack == false) {
|
||||||
return;
|
return;
|
||||||
@@ -1399,7 +1399,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
delta = -delta;
|
delta = -delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1408,7 +1408,7 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
if (mPlayingTrack == false) {
|
if (mPlayingTrack == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we got interrupted, lets make sure we can play
|
// we got interrupted, lets make sure we can play
|
||||||
do {
|
do {
|
||||||
long waited = System.currentTimeMillis() - startTime;
|
long waited = System.currentTimeMillis() - startTime;
|
||||||
@@ -1449,6 +1449,6 @@ public class EmulatorControlPanel extends SelectionDependentPanel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
mPlayingThread.start();
|
mPlayingThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.ddmuilib;
|
package com.android.ddmuilib;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.RawImage;
|
import com.android.ddmlib.RawImage;
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ public class ScreenShotDialog extends Dialog {
|
|||||||
private Label mBusyLabel;
|
private Label mBusyLabel;
|
||||||
private Label mImageLabel;
|
private Label mImageLabel;
|
||||||
private Button mSave;
|
private Button mSave;
|
||||||
private Device mDevice;
|
private IDevice mDevice;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,9 +66,9 @@ public class ScreenShotDialog extends Dialog {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare and display the 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;
|
mDevice = device;
|
||||||
|
|
||||||
Shell parent = getParent();
|
Shell parent = getParent();
|
||||||
|
|||||||
@@ -17,20 +17,20 @@
|
|||||||
package com.android.ddmuilib;
|
package com.android.ddmuilib;
|
||||||
|
|
||||||
import com.android.ddmlib.Client;
|
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.
|
* A Panel that requires {@link Device}/{@link Client} selection notifications.
|
||||||
*/
|
*/
|
||||||
public abstract class SelectionDependentPanel extends Panel {
|
public abstract class SelectionDependentPanel extends Panel {
|
||||||
private Device mCurrentDevice = null;
|
private IDevice mCurrentDevice = null;
|
||||||
private Client mCurrentClient = null;
|
private Client mCurrentClient = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current {@link Device}.
|
* Returns the current {@link Device}.
|
||||||
* @return the current device or null if none are selected.
|
* @return the current device or null if none are selected.
|
||||||
*/
|
*/
|
||||||
protected final Device getCurrentDevice() {
|
protected final IDevice getCurrentDevice() {
|
||||||
return mCurrentDevice;
|
return mCurrentDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public abstract class SelectionDependentPanel extends Panel {
|
|||||||
* Sent when a new device is selected.
|
* Sent when a new device is selected.
|
||||||
* @param selectedDevice the selected device.
|
* @param selectedDevice the selected device.
|
||||||
*/
|
*/
|
||||||
public final void deviceSelected(Device selectedDevice) {
|
public final void deviceSelected(IDevice selectedDevice) {
|
||||||
if (selectedDevice != mCurrentDevice) {
|
if (selectedDevice != mCurrentDevice) {
|
||||||
mCurrentDevice = selectedDevice;
|
mCurrentDevice = selectedDevice;
|
||||||
deviceSelected();
|
deviceSelected();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.ddmuilib.explorer;
|
package com.android.ddmuilib.explorer;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.FileListingService;
|
import com.android.ddmlib.FileListingService;
|
||||||
import com.android.ddmlib.IShellOutputReceiver;
|
import com.android.ddmlib.IShellOutputReceiver;
|
||||||
import com.android.ddmlib.SyncService;
|
import com.android.ddmlib.SyncService;
|
||||||
@@ -99,7 +99,7 @@ public class DeviceExplorer extends Panel {
|
|||||||
private Image mPackageImage;
|
private Image mPackageImage;
|
||||||
private Image mOtherImage;
|
private Image mOtherImage;
|
||||||
|
|
||||||
private Device mCurrentDevice;
|
private IDevice mCurrentDevice;
|
||||||
|
|
||||||
private String mDefaultSave;
|
private String mDefaultSave;
|
||||||
|
|
||||||
@@ -631,7 +631,7 @@ public class DeviceExplorer extends Panel {
|
|||||||
/**
|
/**
|
||||||
* Sets the new device to explorer
|
* Sets the new device to explorer
|
||||||
*/
|
*/
|
||||||
public void switchDevice(final Device device) {
|
public void switchDevice(final IDevice device) {
|
||||||
if (device != mCurrentDevice) {
|
if (device != mCurrentDevice) {
|
||||||
mCurrentDevice = device;
|
mCurrentDevice = device;
|
||||||
// now we change the input. but we need to do that in the
|
// now we change the input. but we need to do that in the
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.ddmuilib.log.event;
|
package com.android.ddmuilib.log.event;
|
||||||
|
|
||||||
import com.android.ddmlib.Client;
|
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;
|
||||||
import com.android.ddmlib.Log.LogLevel;
|
import com.android.ddmlib.Log.LogLevel;
|
||||||
import com.android.ddmlib.log.EventContainer;
|
import com.android.ddmlib.log.EventContainer;
|
||||||
@@ -80,7 +80,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
|
|
||||||
private IImageLoader mImageLoader;
|
private IImageLoader mImageLoader;
|
||||||
|
|
||||||
private Device mCurrentLoggedDevice;
|
private IDevice mCurrentLoggedDevice;
|
||||||
private String mCurrentLogFile;
|
private String mCurrentLogFile;
|
||||||
private LogReceiver mCurrentLogReceiver;
|
private LogReceiver mCurrentLogReceiver;
|
||||||
private EventLogParser mCurrentEventLogParser;
|
private EventLogParser mCurrentEventLogParser;
|
||||||
@@ -94,7 +94,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
private final ArrayList<EventContainer> mNewEvents = new ArrayList<EventContainer>();
|
private final ArrayList<EventContainer> mNewEvents = new ArrayList<EventContainer>();
|
||||||
/** indicates a pending ui thread display */
|
/** indicates a pending ui thread display */
|
||||||
private boolean mPendingDisplay = false;
|
private boolean mPendingDisplay = false;
|
||||||
|
|
||||||
/** list of all the custom event displays */
|
/** list of all the custom event displays */
|
||||||
private final ArrayList<EventDisplay> mEventDisplays = new ArrayList<EventDisplay>();
|
private final ArrayList<EventDisplay> mEventDisplays = new ArrayList<EventDisplay>();
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
private ICommonAction mSaveAction;
|
private ICommonAction mSaveAction;
|
||||||
private ICommonAction mLoadAction;
|
private ICommonAction mLoadAction;
|
||||||
private ICommonAction mImportAction;
|
private ICommonAction mImportAction;
|
||||||
|
|
||||||
/** file containing the current log raw data. */
|
/** file containing the current log raw data. */
|
||||||
private File mTempFile = null;
|
private File mTempFile = null;
|
||||||
|
|
||||||
@@ -209,10 +209,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
// get the new EventDisplay list
|
// get the new EventDisplay list
|
||||||
mEventDisplays.clear();
|
mEventDisplays.clear();
|
||||||
mEventDisplays.addAll(dialog.getEventDisplays());
|
mEventDisplays.addAll(dialog.getEventDisplays());
|
||||||
|
|
||||||
// since the list of EventDisplay changed, we store it.
|
// since the list of EventDisplay changed, we store it.
|
||||||
saveEventDisplays();
|
saveEventDisplays();
|
||||||
|
|
||||||
rebuildUi();
|
rebuildUi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +220,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
Log.e("EventLog", e); //$NON-NLS-1$
|
Log.e("EventLog", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the log.
|
* Clears the log.
|
||||||
* <p/>
|
* <p/>
|
||||||
@@ -240,7 +240,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
Log.e("EventLog", e); //$NON-NLS-1$
|
Log.e("EventLog", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the content of the event log into a file. The log is saved in the same
|
* Saves the content of the event log into a file. The log is saved in the same
|
||||||
* binary format than on the device.
|
* binary format than on the device.
|
||||||
@@ -254,16 +254,16 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
FileInputStream fis = new FileInputStream(mTempFile);
|
FileInputStream fis = new FileInputStream(mTempFile);
|
||||||
FileOutputStream fos = new FileOutputStream(destFile);
|
FileOutputStream fos = new FileOutputStream(destFile);
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
while ((count = fis.read(buffer)) != -1) {
|
while ((count = fis.read(buffer)) != -1) {
|
||||||
fos.write(buffer, 0, count);
|
fos.write(buffer, 0, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
fos.close();
|
fos.close();
|
||||||
fis.close();
|
fis.close();
|
||||||
|
|
||||||
// now we save the tag file
|
// now we save the tag file
|
||||||
filePath = filePath + TAG_FILE_EXT;
|
filePath = filePath + TAG_FILE_EXT;
|
||||||
mCurrentEventLogParser.saveTags(filePath);
|
mCurrentEventLogParser.saveTags(filePath);
|
||||||
@@ -293,16 +293,16 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importBugReport(String filePath) {
|
public void importBugReport(String filePath) {
|
||||||
try {
|
try {
|
||||||
BugReportImporter importer = new BugReportImporter(filePath);
|
BugReportImporter importer = new BugReportImporter(filePath);
|
||||||
|
|
||||||
String[] tags = importer.getTags();
|
String[] tags = importer.getTags();
|
||||||
String[] log = importer.getLog();
|
String[] log = importer.getLog();
|
||||||
|
|
||||||
startEventLogFromContent(tags, log);
|
startEventLogFromContent(tags, log);
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Log.logAndDisplay(LogLevel.ERROR, "Import",
|
Log.logAndDisplay(LogLevel.ERROR, "Import",
|
||||||
"Unable to import bug report: " + e.getMessage());
|
"Unable to import bug report: " + e.getMessage());
|
||||||
@@ -324,7 +324,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
public void deviceSelected() {
|
public void deviceSelected() {
|
||||||
startEventLog(getCurrentDevice());
|
startEventLog(getCurrentDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see com.android.ddmlib.AndroidDebugBridge.IClientChangeListener#clientChanged(com.android.ddmlib.Client, int)
|
* @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
|
// init some store stuff
|
||||||
store.setDefault(PREFS_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH);
|
store.setDefault(PREFS_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH);
|
||||||
store.setDefault(PREFS_DISPLAY_HEIGHT, DEFAULT_DISPLAY_HEIGHT);
|
store.setDefault(PREFS_DISPLAY_HEIGHT, DEFAULT_DISPLAY_HEIGHT);
|
||||||
|
|
||||||
mBottomParentPanel = new ScrolledComposite(parent, SWT.V_SCROLL);
|
mBottomParentPanel = new ScrolledComposite(parent, SWT.V_SCROLL);
|
||||||
mBottomParentPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
|
mBottomParentPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
mBottomParentPanel.setExpandHorizontal(true);
|
mBottomParentPanel.setExpandHorizontal(true);
|
||||||
@@ -383,7 +383,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
|
|
||||||
// create the ui
|
// create the ui
|
||||||
createDisplayUi();
|
createDisplayUi();
|
||||||
|
|
||||||
return mBottomParentPanel;
|
return mBottomParentPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,12 +402,12 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
mBottomParentPanel.setFocus();
|
mBottomParentPanel.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new logcat and set mCurrentLogCat as the current receiver.
|
* Starts a new logcat and set mCurrentLogCat as the current receiver.
|
||||||
* @param device the device to connect logcat to.
|
* @param device the device to connect logcat to.
|
||||||
*/
|
*/
|
||||||
private void startEventLog(final Device device) {
|
private void startEventLog(final IDevice device) {
|
||||||
if (device == mCurrentLoggedDevice) {
|
if (device == mCurrentLoggedDevice) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -448,10 +448,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
mCurrentEventLogParser = new EventLogParser();
|
mCurrentEventLogParser = new EventLogParser();
|
||||||
mCurrentEventLogParser.init(device);
|
mCurrentEventLogParser.init(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the event display with the new parser.
|
// update the event display with the new parser.
|
||||||
updateEventDisplays();
|
updateEventDisplays();
|
||||||
|
|
||||||
// prepare the temp file that will contain the raw data
|
// prepare the temp file that will contain the raw data
|
||||||
mTempFile = File.createTempFile("android-event-", ".log");
|
mTempFile = File.createTempFile("android-event-", ".log");
|
||||||
|
|
||||||
@@ -464,7 +464,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startEventLogFromFiles(final String fileName) {
|
private void startEventLogFromFiles(final String fileName) {
|
||||||
// if we have a logcat already running
|
// if we have a logcat already running
|
||||||
if (mCurrentLogReceiver != null) {
|
if (mCurrentLogReceiver != null) {
|
||||||
@@ -475,7 +475,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
|
|
||||||
// create a new output receiver
|
// create a new output receiver
|
||||||
mCurrentLogReceiver = new LogReceiver(this);
|
mCurrentLogReceiver = new LogReceiver(this);
|
||||||
|
|
||||||
mSaveAction.setEnabled(false);
|
mSaveAction.setEnabled(false);
|
||||||
|
|
||||||
// start the logcat in a different thread
|
// start the logcat in a different thread
|
||||||
@@ -493,10 +493,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the event display with the new parser.
|
// update the event display with the new parser.
|
||||||
updateEventDisplays();
|
updateEventDisplays();
|
||||||
|
|
||||||
runLocalEventLogService(fileName, mCurrentLogReceiver);
|
runLocalEventLogService(fileName, mCurrentLogReceiver);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("EventLog", e);
|
Log.e("EventLog", e);
|
||||||
@@ -516,7 +516,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
|
|
||||||
// create a new output receiver
|
// create a new output receiver
|
||||||
mCurrentLogReceiver = new LogReceiver(this);
|
mCurrentLogReceiver = new LogReceiver(this);
|
||||||
|
|
||||||
mSaveAction.setEnabled(false);
|
mSaveAction.setEnabled(false);
|
||||||
|
|
||||||
// start the logcat in a different thread
|
// start the logcat in a different thread
|
||||||
@@ -531,10 +531,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the event display with the new parser.
|
// update the event display with the new parser.
|
||||||
updateEventDisplays();
|
updateEventDisplays();
|
||||||
|
|
||||||
runLocalEventLogService(log, mCurrentLogReceiver);
|
runLocalEventLogService(log, mCurrentLogReceiver);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("EventLog", e);
|
Log.e("EventLog", e);
|
||||||
@@ -563,7 +563,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
|
|
||||||
resetUI(inUiThread);
|
resetUI(inUiThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTempFile != null) {
|
if (mTempFile != null) {
|
||||||
mTempFile.delete();
|
mTempFile.delete();
|
||||||
mTempFile = null;
|
mTempFile = null;
|
||||||
@@ -593,7 +593,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetUiFromUiThread() {
|
private void resetUiFromUiThread() {
|
||||||
synchronized(mLock) {
|
synchronized(mLock) {
|
||||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||||
@@ -618,11 +618,11 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
rowLayout.fill = true;
|
rowLayout.fill = true;
|
||||||
rowLayout.type = SWT.HORIZONTAL;
|
rowLayout.type = SWT.HORIZONTAL;
|
||||||
mBottomPanel.setLayout(rowLayout);
|
mBottomPanel.setLayout(rowLayout);
|
||||||
|
|
||||||
IPreferenceStore store = DdmUiPreferences.getStore();
|
IPreferenceStore store = DdmUiPreferences.getStore();
|
||||||
int displayWidth = store.getInt(PREFS_DISPLAY_WIDTH);
|
int displayWidth = store.getInt(PREFS_DISPLAY_WIDTH);
|
||||||
int displayHeight = store.getInt(PREFS_DISPLAY_HEIGHT);
|
int displayHeight = store.getInt(PREFS_DISPLAY_HEIGHT);
|
||||||
|
|
||||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||||
Control c = eventDisplay.createComposite(mBottomPanel, mCurrentEventLogParser, this);
|
Control c = eventDisplay.createComposite(mBottomPanel, mCurrentEventLogParser, this);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
@@ -631,7 +631,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
rd.width = displayWidth;
|
rd.width = displayWidth;
|
||||||
c.setLayoutData(rd);
|
c.setLayoutData(rd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Table table = eventDisplay.getTable();
|
Table table = eventDisplay.getTable();
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
addTableToFocusListener(table);
|
addTableToFocusListener(table);
|
||||||
@@ -642,7 +642,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
mBottomParentPanel.setMinSize(mBottomPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
mBottomParentPanel.setMinSize(mBottomPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||||
mBottomParentPanel.layout();
|
mBottomParentPanel.layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuild the display ui.
|
* 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.
|
// we need to rebuild the ui. First we get rid of it.
|
||||||
mBottomPanel.dispose();
|
mBottomPanel.dispose();
|
||||||
mBottomPanel = null;
|
mBottomPanel = null;
|
||||||
|
|
||||||
prepareDisplayUi();
|
prepareDisplayUi();
|
||||||
createDisplayUi();
|
createDisplayUi();
|
||||||
|
|
||||||
// and fill it
|
// and fill it
|
||||||
|
|
||||||
boolean start_event = false;
|
boolean start_event = false;
|
||||||
synchronized (mNewEvents) {
|
synchronized (mNewEvents) {
|
||||||
mNewEvents.addAll(0, mEvents);
|
mNewEvents.addAll(0, mEvents);
|
||||||
|
|
||||||
if (mPendingDisplay == false) {
|
if (mPendingDisplay == false) {
|
||||||
mPendingDisplay = true;
|
mPendingDisplay = true;
|
||||||
start_event = true;
|
start_event = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_event) {
|
if (start_event) {
|
||||||
scheduleUIEventHandler();
|
scheduleUIEventHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle r = mBottomParentPanel.getClientArea();
|
Rectangle r = mBottomParentPanel.getClientArea();
|
||||||
mBottomParentPanel.setMinSize(mBottomPanel.computeSize(r.width,
|
mBottomParentPanel.setMinSize(mBottomPanel.computeSize(r.width,
|
||||||
SWT.DEFAULT));
|
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.
|
* Processes a new {@link LogEntry} by parsing it with {@link EventLogParser} and displaying it.
|
||||||
* @param entry The new log entry
|
* @param entry The new log entry
|
||||||
* @see LogReceiver.ILogListener#newEntry(LogEntry)
|
* @see LogReceiver.ILogListener#newEntry(LogEntry)
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public void newEntry(LogEntry entry) {
|
public void newEntry(LogEntry entry) {
|
||||||
@@ -695,24 +695,24 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private void handleNewEvent(EventContainer event) {
|
private void handleNewEvent(EventContainer event) {
|
||||||
// add the event to the generic list
|
// add the event to the generic list
|
||||||
mEvents.add(event);
|
mEvents.add(event);
|
||||||
|
|
||||||
// add to the list of events that needs to be displayed, and trigger a
|
// add to the list of events that needs to be displayed, and trigger a
|
||||||
// new display if needed.
|
// new display if needed.
|
||||||
boolean start_event = false;
|
boolean start_event = false;
|
||||||
synchronized (mNewEvents) {
|
synchronized (mNewEvents) {
|
||||||
mNewEvents.add(event);
|
mNewEvents.add(event);
|
||||||
|
|
||||||
if (mPendingDisplay == false) {
|
if (mPendingDisplay == false) {
|
||||||
mPendingDisplay = true;
|
mPendingDisplay = true;
|
||||||
start_event = true;
|
start_event = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_event == false) {
|
if (start_event == false) {
|
||||||
// we're done
|
// we're done
|
||||||
return;
|
return;
|
||||||
@@ -737,7 +737,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (SWTException e) {
|
} 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) {
|
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||||
eventDisplay.startMultiEventDisplay();
|
eventDisplay.startMultiEventDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// display the new events
|
// display the new events
|
||||||
EventContainer event = null;
|
EventContainer event = null;
|
||||||
boolean need_to_reloop = false;
|
boolean need_to_reloop = false;
|
||||||
@@ -803,7 +803,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||||
eventDisplay.endMultiEventDisplay();
|
eventDisplay.endMultiEventDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if needed, ask the UI thread to re-run this method.
|
// if needed, ask the UI thread to re-run this method.
|
||||||
if (need_to_reloop) {
|
if (need_to_reloop) {
|
||||||
scheduleUIEventHandler();
|
scheduleUIEventHandler();
|
||||||
@@ -816,10 +816,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
private void loadEventDisplays() {
|
private void loadEventDisplays() {
|
||||||
IPreferenceStore store = DdmUiPreferences.getStore();
|
IPreferenceStore store = DdmUiPreferences.getStore();
|
||||||
String storage = store.getString(PREFS_EVENT_DISPLAY);
|
String storage = store.getString(PREFS_EVENT_DISPLAY);
|
||||||
|
|
||||||
if (storage.length() > 0) {
|
if (storage.length() > 0) {
|
||||||
String[] values = storage.split(Pattern.quote(EVENT_DISPLAY_STORAGE_SEPARATOR));
|
String[] values = storage.split(Pattern.quote(EVENT_DISPLAY_STORAGE_SEPARATOR));
|
||||||
|
|
||||||
for (String value : values) {
|
for (String value : values) {
|
||||||
EventDisplay eventDisplay = EventDisplay.load(value);
|
EventDisplay eventDisplay = EventDisplay.load(value);
|
||||||
if (eventDisplay != null) {
|
if (eventDisplay != null) {
|
||||||
@@ -834,10 +834,10 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
*/
|
*/
|
||||||
private void saveEventDisplays() {
|
private void saveEventDisplays() {
|
||||||
IPreferenceStore store = DdmUiPreferences.getStore();
|
IPreferenceStore store = DdmUiPreferences.getStore();
|
||||||
|
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||||
String storage = eventDisplay.getStorageString();
|
String storage = eventDisplay.getStorageString();
|
||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
@@ -846,7 +846,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(storage);
|
sb.append(storage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -870,7 +870,7 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
for (EventDisplay eventDisplay : mEventDisplays) {
|
for (EventDisplay eventDisplay : mEventDisplays) {
|
||||||
eventDisplay.setNewLogParser(mCurrentEventLogParser);
|
eventDisplay.setNewLogParser(mCurrentEventLogParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
mOptionsAction.setEnabled(true);
|
mOptionsAction.setEnabled(true);
|
||||||
mClearAction.setEnabled(true);
|
mClearAction.setEnabled(true);
|
||||||
if (mCurrentLogFile == null) {
|
if (mCurrentLogFile == null) {
|
||||||
@@ -897,21 +897,21 @@ public class EventLogPanel extends TablePanel implements ILogListener,
|
|||||||
* Runs an event log service out of a local file.
|
* 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 fileName the full file name of the local file containing the event log.
|
||||||
* @param logReceiver the receiver that will handle the log
|
* @param logReceiver the receiver that will handle the log
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private void runLocalEventLogService(String fileName, LogReceiver logReceiver)
|
private void runLocalEventLogService(String fileName, LogReceiver logReceiver)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
byte[] buffer = new byte[256];
|
byte[] buffer = new byte[256];
|
||||||
|
|
||||||
FileInputStream fis = new FileInputStream(fileName);
|
FileInputStream fis = new FileInputStream(fileName);
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
while ((count = fis.read(buffer)) != -1) {
|
while ((count = fis.read(buffer)) != -1) {
|
||||||
logReceiver.parseNewData(buffer, 0, count);
|
logReceiver.parseNewData(buffer, 0, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private void runLocalEventLogService(String[] log, LogReceiver currentLogReceiver) {
|
private void runLocalEventLogService(String[] log, LogReceiver currentLogReceiver) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.ddmuilib.logcat;
|
package com.android.ddmuilib.logcat;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.MultiLineReceiver;
|
import com.android.ddmlib.MultiLineReceiver;
|
||||||
import com.android.ddmlib.Log.LogLevel;
|
import com.android.ddmlib.Log.LogLevel;
|
||||||
@@ -163,13 +163,13 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
private int mFilterMode = FILTER_NONE;
|
private int mFilterMode = FILTER_NONE;
|
||||||
|
|
||||||
/** Device currently running logcat */
|
/** Device currently running logcat */
|
||||||
private Device mCurrentLoggedDevice = null;
|
private IDevice mCurrentLoggedDevice = null;
|
||||||
|
|
||||||
private ICommonAction mDeleteFilterAction;
|
private ICommonAction mDeleteFilterAction;
|
||||||
private ICommonAction mEditFilterAction;
|
private ICommonAction mEditFilterAction;
|
||||||
|
|
||||||
private ICommonAction[] mLogLevelActions;
|
private ICommonAction[] mLogLevelActions;
|
||||||
|
|
||||||
/** message data, separated from content for multi line messages */
|
/** message data, separated from content for multi line messages */
|
||||||
protected static class LogMessageInfo {
|
protected static class LogMessageInfo {
|
||||||
public LogLevel logLevel;
|
public LogLevel logLevel;
|
||||||
@@ -183,7 +183,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
* log message, to reuse the info regarding level, pid, etc...
|
* log message, to reuse the info regarding level, pid, etc...
|
||||||
*/
|
*/
|
||||||
private LogMessageInfo mLastMessageInfo = null;
|
private LogMessageInfo mLastMessageInfo = null;
|
||||||
|
|
||||||
private boolean mPendingAsyncRefresh = false;
|
private boolean mPendingAsyncRefresh = false;
|
||||||
|
|
||||||
/** loader for the images. the implementation will varie between standalone
|
/** 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.
|
* Starts a new logcat and set mCurrentLogCat as the current receiver.
|
||||||
* @param device the device to connect logcat to.
|
* @param device the device to connect logcat to.
|
||||||
*/
|
*/
|
||||||
public void startLogCat(final Device device) {
|
public void startLogCat(final IDevice device) {
|
||||||
if (device == mCurrentLoggedDevice) {
|
if (device == mCurrentLoggedDevice) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
stopLogCat(false);
|
stopLogCat(false);
|
||||||
mCurrentLoggedDevice = null;
|
mCurrentLoggedDevice = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetUI(false);
|
resetUI(false);
|
||||||
|
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
@@ -696,7 +696,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
synchronized (mBuffer) {
|
synchronized (mBuffer) {
|
||||||
FileDialog dlg = new FileDialog(mParent.getShell(), SWT.SAVE);
|
FileDialog dlg = new FileDialog(mParent.getShell(), SWT.SAVE);
|
||||||
String fileName;
|
String fileName;
|
||||||
|
|
||||||
dlg.setText("Save log...");
|
dlg.setText("Save log...");
|
||||||
dlg.setFileName("log.txt");
|
dlg.setFileName("log.txt");
|
||||||
String defaultPath = mDefaultLogSave;
|
String defaultPath = mDefaultLogSave;
|
||||||
@@ -710,7 +710,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
dlg.setFilterExtensions(new String[] {
|
dlg.setFilterExtensions(new String[] {
|
||||||
"*.txt"
|
"*.txt"
|
||||||
});
|
});
|
||||||
|
|
||||||
fileName = dlg.open();
|
fileName = dlg.open();
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
mDefaultLogSave = dlg.getFilterPath();
|
mDefaultLogSave = dlg.getFilterPath();
|
||||||
@@ -928,7 +928,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
t.setLinesVisible(false);
|
t.setLinesVisible(false);
|
||||||
|
|
||||||
if (mGlobalListener != null) {
|
if (mGlobalListener != null) {
|
||||||
addTableToFocusListener(t);
|
addTableToFocusListener(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a controllistener that will handle the resizing of all the
|
// 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
|
* @param lines the new lines
|
||||||
*/
|
*/
|
||||||
protected void processLogLines(String[] lines) {
|
protected void processLogLines(String[] lines) {
|
||||||
@@ -1074,10 +1074,10 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
if (lines.length > STRING_BUFFER_LENGTH) {
|
if (lines.length > STRING_BUFFER_LENGTH) {
|
||||||
Log.e("LogCat", "Receiving more lines than 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
|
// parse the lines and create LogMessage that are stored in a temporary list
|
||||||
final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>();
|
final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>();
|
||||||
|
|
||||||
synchronized (mBuffer) {
|
synchronized (mBuffer) {
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
// ignore empty lines.
|
// ignore empty lines.
|
||||||
@@ -1087,7 +1087,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
// this is a header line, parse the header and keep it around.
|
// this is a header line, parse the header and keep it around.
|
||||||
mLastMessageInfo = new LogMessageInfo();
|
mLastMessageInfo = new LogMessageInfo();
|
||||||
|
|
||||||
mLastMessageInfo.time = matcher.group(1);
|
mLastMessageInfo.time = matcher.group(1);
|
||||||
mLastMessageInfo.pidString = matcher.group(2);
|
mLastMessageInfo.pidString = matcher.group(2);
|
||||||
mLastMessageInfo.pid = Integer.valueOf(mLastMessageInfo.pidString);
|
mLastMessageInfo.pid = Integer.valueOf(mLastMessageInfo.pidString);
|
||||||
@@ -1097,7 +1097,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
// This is not a header line.
|
// This is not a header line.
|
||||||
// Create a new LogMessage and process it.
|
// Create a new LogMessage and process it.
|
||||||
LogMessage mc = new LogMessage();
|
LogMessage mc = new LogMessage();
|
||||||
|
|
||||||
if (mLastMessageInfo == null) {
|
if (mLastMessageInfo == null) {
|
||||||
// The first line of output wasn't preceded
|
// The first line of output wasn't preceded
|
||||||
// by a header line; make something up so
|
// by a header line; make something up so
|
||||||
@@ -1109,34 +1109,34 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
mLastMessageInfo.logLevel = LogLevel.INFO;
|
mLastMessageInfo.logLevel = LogLevel.INFO;
|
||||||
mLastMessageInfo.tag = "<unknown>"; //$NON-NLS1$
|
mLastMessageInfo.tag = "<unknown>"; //$NON-NLS1$
|
||||||
}
|
}
|
||||||
|
|
||||||
// If someone printed a log message with
|
// If someone printed a log message with
|
||||||
// embedded '\n' characters, there will
|
// embedded '\n' characters, there will
|
||||||
// one header line followed by multiple text lines.
|
// one header line followed by multiple text lines.
|
||||||
// Use the last header that we saw.
|
// Use the last header that we saw.
|
||||||
mc.data = mLastMessageInfo;
|
mc.data = mLastMessageInfo;
|
||||||
|
|
||||||
// tabs seem to display as only 1 tab so we replace the leading tabs
|
// tabs seem to display as only 1 tab so we replace the leading tabs
|
||||||
// by 4 spaces.
|
// by 4 spaces.
|
||||||
mc.msg = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
mc.msg = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
// process the new LogMessage.
|
// process the new LogMessage.
|
||||||
processNewMessage(mc);
|
processNewMessage(mc);
|
||||||
|
|
||||||
// store the new LogMessage
|
// store the new LogMessage
|
||||||
newMessages.add(mc);
|
newMessages.add(mc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we don't have a pending Runnable that will do the refresh, we ask the Display
|
// if we don't have a pending Runnable that will do the refresh, we ask the Display
|
||||||
// to run one in the UI thread.
|
// to run one in the UI thread.
|
||||||
if (mPendingAsyncRefresh == false) {
|
if (mPendingAsyncRefresh == false) {
|
||||||
mPendingAsyncRefresh = true;
|
mPendingAsyncRefresh = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Display display = mFolders.getDisplay();
|
Display display = mFolders.getDisplay();
|
||||||
|
|
||||||
// run in sync because this will update the buffer start/end indices
|
// run in sync because this will update the buffer start/end indices
|
||||||
display.asyncExec(new Runnable() {
|
display.asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -1165,7 +1165,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
f.flush();
|
f.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDefaultFilter != null) {
|
if (mDefaultFilter != null) {
|
||||||
mDefaultFilter.flush();
|
mDefaultFilter.flush();
|
||||||
}
|
}
|
||||||
@@ -1209,7 +1209,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
// increment the next usable slot index
|
// increment the next usable slot index
|
||||||
mBufferEnd = (mBufferEnd + 1) % STRING_BUFFER_LENGTH;
|
mBufferEnd = (mBufferEnd + 1) % STRING_BUFFER_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage oldMessage = null;
|
LogMessage oldMessage = null;
|
||||||
|
|
||||||
// record the message that was there before
|
// record the message that was there before
|
||||||
@@ -1381,7 +1381,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
initDefaultFilter();
|
initDefaultFilter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter.clear();
|
filter.clear();
|
||||||
|
|
||||||
if (mBufferStart != -1) {
|
if (mBufferStart != -1) {
|
||||||
@@ -1482,13 +1482,13 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
if (mDefaultFilter != null) {
|
if (mDefaultFilter != null) {
|
||||||
mDefaultFilter.resetTempFiltering();
|
mDefaultFilter.resetTempFiltering();
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we need to figure out the new temp filtering
|
// now we need to figure out the new temp filtering
|
||||||
// split each word
|
// split each word
|
||||||
String[] segments = text.split(" "); //$NON-NLS-1$
|
String[] segments = text.split(" "); //$NON-NLS-1$
|
||||||
|
|
||||||
ArrayList<String> keywords = new ArrayList<String>(segments.length);
|
ArrayList<String> keywords = new ArrayList<String>(segments.length);
|
||||||
|
|
||||||
// loop and look for temp id/tag
|
// loop and look for temp id/tag
|
||||||
int tempPid = -1;
|
int tempPid = -1;
|
||||||
String tempTag = null;
|
String tempTag = null;
|
||||||
@@ -1511,12 +1511,12 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
keywords.add(s);
|
keywords.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the temp filtering in the filters
|
// set the temp filtering in the filters
|
||||||
if (tempPid != -1 || tempTag != null || keywords.size() > 0) {
|
if (tempPid != -1 || tempTag != null || keywords.size() > 0) {
|
||||||
String[] keywordsArray = keywords.toArray(
|
String[] keywordsArray = keywords.toArray(
|
||||||
new String[keywords.size()]);
|
new String[keywords.size()]);
|
||||||
|
|
||||||
for (LogFilter f : mFilters) {
|
for (LogFilter f : mFilters) {
|
||||||
if (tempPid != -1) {
|
if (tempPid != -1) {
|
||||||
f.setTempPidFiltering(tempPid);
|
f.setTempPidFiltering(tempPid);
|
||||||
@@ -1526,7 +1526,7 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
}
|
}
|
||||||
f.setTempKeywordFiltering(keywordsArray);
|
f.setTempKeywordFiltering(keywordsArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDefaultFilter != null) {
|
if (mDefaultFilter != null) {
|
||||||
if (tempPid != -1) {
|
if (tempPid != -1) {
|
||||||
mDefaultFilter.setTempPidFiltering(tempPid);
|
mDefaultFilter.setTempPidFiltering(tempPid);
|
||||||
@@ -1535,10 +1535,10 @@ public class LogPanel extends SelectionDependentPanel {
|
|||||||
mDefaultFilter.setTempTagFiltering(tempTag);
|
mDefaultFilter.setTempTagFiltering(tempTag);
|
||||||
}
|
}
|
||||||
mDefaultFilter.setTempKeywordFiltering(keywordsArray);
|
mDefaultFilter.setTempKeywordFiltering(keywordsArray);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initFilter(mCurrentFilter);
|
initFilter(mCurrentFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.dumpeventlog;
|
package com.android.dumpeventlog;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.Log.ILogOutput;
|
import com.android.ddmlib.Log.ILogOutput;
|
||||||
import com.android.ddmlib.Log.LogLevel;
|
import com.android.ddmlib.Log.LogLevel;
|
||||||
@@ -30,7 +30,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a device using ddmlib and dumps its event log as long as the device is connected.
|
* Connects to a device using ddmlib and dumps its event log as long as the device is connected.
|
||||||
*/
|
*/
|
||||||
public class DumpEventLog {
|
public class DumpEventLog {
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class DumpEventLog {
|
|||||||
System.out.println("Usage: dumpeventlog <device s/n> <filepath>");
|
System.out.println("Usage: dumpeventlog <device s/n> <filepath>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect the log output to /dev/null
|
// redirect the log output to /dev/null
|
||||||
Log.setLogOutput(new ILogOutput() {
|
Log.setLogOutput(new ILogOutput() {
|
||||||
public void printAndPromptLog(LogLevel logLevel, String tag, String message) {
|
public void printAndPromptLog(LogLevel logLevel, String tag, String message) {
|
||||||
@@ -85,13 +85,13 @@ public class DumpEventLog {
|
|||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// init the lib
|
// init the lib
|
||||||
AndroidDebugBridge.init(false /* debugger support */);
|
AndroidDebugBridge.init(false /* debugger support */);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge();
|
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge();
|
||||||
|
|
||||||
// we can't just ask for the device list right away, as the internal thread getting
|
// we can't just ask for the device list right away, as the internal thread getting
|
||||||
// them from ADB may not be done getting the first list.
|
// them from ADB may not be done getting the first list.
|
||||||
// Since we don't really want getDevices() to be blocking, we wait here manually.
|
// Since we don't really want getDevices() to be blocking, we wait here manually.
|
||||||
@@ -103,7 +103,7 @@ public class DumpEventLog {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's not wait > 10 sec.
|
// let's not wait > 10 sec.
|
||||||
if (count > 100) {
|
if (count > 100) {
|
||||||
System.err.println("Timeout getting device list!");
|
System.err.println("Timeout getting device list!");
|
||||||
@@ -112,9 +112,9 @@ public class DumpEventLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now get the devices
|
// now get the devices
|
||||||
Device[] devices = bridge.getDevices();
|
IDevice[] devices = bridge.getDevices();
|
||||||
|
|
||||||
for (Device device : devices) {
|
for (IDevice device : devices) {
|
||||||
if (device.getSerialNumber().equals(args[0])) {
|
if (device.getSerialNumber().equals(args[0])) {
|
||||||
try {
|
try {
|
||||||
grabLogFrom(device, args[1]);
|
grabLogFrom(device, args[1]);
|
||||||
@@ -126,20 +126,20 @@ public class DumpEventLog {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.println("Could not find " + args[0]);
|
System.err.println("Could not find " + args[0]);
|
||||||
} finally {
|
} finally {
|
||||||
AndroidDebugBridge.terminate();
|
AndroidDebugBridge.terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void grabLogFrom(Device device, String filePath) throws IOException {
|
private static void grabLogFrom(IDevice device, String filePath) throws IOException {
|
||||||
LogWriter writer = new LogWriter(filePath);
|
LogWriter writer = new LogWriter(filePath);
|
||||||
LogReceiver receiver = new LogReceiver(writer);
|
LogReceiver receiver = new LogReceiver(writer);
|
||||||
writer.setReceiver(receiver);
|
writer.setReceiver(receiver);
|
||||||
|
|
||||||
device.runEventLogService(receiver);
|
device.runEventLogService(receiver);
|
||||||
|
|
||||||
writer.done();
|
writer.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.ide.eclipse.adt.internal.launch;
|
|||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Client;
|
import com.android.ddmlib.Client;
|
||||||
import com.android.ddmlib.ClientData;
|
import com.android.ddmlib.ClientData;
|
||||||
import com.android.ddmlib.Device;
|
|
||||||
import com.android.ddmlib.IDevice;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.MultiLineReceiver;
|
import com.android.ddmlib.MultiLineReceiver;
|
||||||
@@ -1381,9 +1380,9 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @param device the new device.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
* @see IDeviceChangeListener#deviceConnected(IDevice)
|
||||||
*/
|
*/
|
||||||
public void deviceConnected(Device device) {
|
public void deviceConnected(IDevice device) {
|
||||||
synchronized (sListLock) {
|
synchronized (sListLock) {
|
||||||
// look if there's an app waiting for a device
|
// look if there's an app waiting for a device
|
||||||
if (mWaitingForEmulatorLaunches.size() > 0) {
|
if (mWaitingForEmulatorLaunches.size() > 0) {
|
||||||
@@ -1415,10 +1414,10 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @param device the new device.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
* @see IDeviceChangeListener#deviceDisconnected(IDevice)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void deviceDisconnected(Device device) {
|
public void deviceDisconnected(IDevice device) {
|
||||||
// any pending launch on this device must be canceled.
|
// any pending launch on this device must be canceled.
|
||||||
String message = "%1$s disconnected! Cancelling '%2$s'!";
|
String message = "%1$s disconnected! Cancelling '%2$s'!";
|
||||||
synchronized (sListLock) {
|
synchronized (sListLock) {
|
||||||
@@ -1451,9 +1450,9 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
|||||||
* @param device the device that was updated.
|
* @param device the device that was updated.
|
||||||
* @param changeMask the mask indicating what changed.
|
* @param changeMask the mask indicating what changed.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceChanged(Device, int)
|
* @see IDeviceChangeListener#deviceChanged(IDevice, int)
|
||||||
*/
|
*/
|
||||||
public void deviceChanged(Device device, int changeMask) {
|
public void deviceChanged(IDevice device, int changeMask) {
|
||||||
// We could check if any starting device we care about is now ready, but we can wait for
|
// We could check if any starting device we care about is now ready, but we can wait for
|
||||||
// its home app to show up, so...
|
// its home app to show up, so...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,9 @@ package com.android.ide.eclipse.adt.internal.launch;
|
|||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Client;
|
import com.android.ddmlib.Client;
|
||||||
import com.android.ddmlib.Device;
|
|
||||||
import com.android.ddmlib.IDevice;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
||||||
import com.android.ddmlib.Device.DeviceState;
|
import com.android.ddmlib.IDevice.DeviceState;
|
||||||
import com.android.ddmuilib.IImageLoader;
|
import com.android.ddmuilib.IImageLoader;
|
||||||
import com.android.ddmuilib.ImageHelper;
|
import com.android.ddmuilib.ImageHelper;
|
||||||
import com.android.ddmuilib.TableHelper;
|
import com.android.ddmuilib.TableHelper;
|
||||||
@@ -99,7 +98,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
private boolean mDisableAvdSelectionChange = false;
|
private boolean mDisableAvdSelectionChange = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic Content Provider for a table full of {@link Device} objects. The input is
|
* Basic Content Provider for a table full of {@link IDevice} objects. The input is
|
||||||
* a {@link AndroidDebugBridge}.
|
* a {@link AndroidDebugBridge}.
|
||||||
*/
|
*/
|
||||||
private class ContentProvider implements IStructuredContentProvider {
|
private class ContentProvider implements IStructuredContentProvider {
|
||||||
@@ -123,13 +122,13 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A Label Provider for the {@link TableViewer} in {@link DeviceChooserDialog}.
|
* A Label Provider for the {@link TableViewer} in {@link DeviceChooserDialog}.
|
||||||
* It provides labels and images for {@link Device} objects.
|
* It provides labels and images for {@link IDevice} objects.
|
||||||
*/
|
*/
|
||||||
private class LabelProvider implements ITableLabelProvider {
|
private class LabelProvider implements ITableLabelProvider {
|
||||||
|
|
||||||
public Image getColumnImage(Object element, int columnIndex) {
|
public Image getColumnImage(Object element, int columnIndex) {
|
||||||
if (element instanceof Device) {
|
if (element instanceof IDevice) {
|
||||||
Device device = (Device)element;
|
IDevice device = (IDevice)element;
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return device.isEmulator() ? mEmulatorImage : mDeviceImage;
|
return device.isEmulator() ? mEmulatorImage : mDeviceImage;
|
||||||
@@ -175,8 +174,8 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnText(Object element, int columnIndex) {
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
if (element instanceof Device) {
|
if (element instanceof IDevice) {
|
||||||
Device device = (Device)element;
|
IDevice device = (IDevice)element;
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return device.getSerialNumber();
|
return device.getSerialNumber();
|
||||||
@@ -514,7 +513,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
* Returns a display string representing the state of the device.
|
* Returns a display string representing the state of the device.
|
||||||
* @param d the device
|
* @param d the device
|
||||||
*/
|
*/
|
||||||
private static String getStateString(Device d) {
|
private static String getStateString(IDevice d) {
|
||||||
DeviceState deviceState = d.getState();
|
DeviceState deviceState = d.getState();
|
||||||
if (deviceState == DeviceState.ONLINE) {
|
if (deviceState == DeviceState.ONLINE) {
|
||||||
return "Online";
|
return "Online";
|
||||||
@@ -533,9 +532,9 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @param device the new device.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
* @see IDeviceChangeListener#deviceConnected(IDevice)
|
||||||
*/
|
*/
|
||||||
public void deviceConnected(Device device) {
|
public void deviceConnected(IDevice device) {
|
||||||
final DeviceChooserDialog dialog = this;
|
final DeviceChooserDialog dialog = this;
|
||||||
exec(new Runnable() {
|
exec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -565,9 +564,9 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @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);
|
deviceConnected(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,10 +577,10 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
* @param device the device that was updated.
|
* @param device the device that was updated.
|
||||||
* @param changeMask the mask indicating what changed.
|
* @param changeMask the mask indicating what changed.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceChanged(Device, int)
|
* @see IDeviceChangeListener#deviceChanged(IDevice, int)
|
||||||
*/
|
*/
|
||||||
public void deviceChanged(final Device device, int changeMask) {
|
public void deviceChanged(final IDevice device, int changeMask) {
|
||||||
if ((changeMask & (Device.CHANGE_STATE | Device.CHANGE_BUILD_INFO)) != 0) {
|
if ((changeMask & (IDevice.CHANGE_STATE | IDevice.CHANGE_BUILD_INFO)) != 0) {
|
||||||
final DeviceChooserDialog dialog = this;
|
final DeviceChooserDialog dialog = this;
|
||||||
exec(new Runnable() {
|
exec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -663,15 +662,15 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
} else {
|
} else {
|
||||||
int index = mDeviceTable.getSelectionIndex();
|
int index = mDeviceTable.getSelectionIndex();
|
||||||
Object data = mViewer.getElementAt(index);
|
Object data = mViewer.getElementAt(index);
|
||||||
if (data instanceof Device) {
|
if (data instanceof IDevice) {
|
||||||
handleSelection((Device)data);
|
handleSelection((IDevice)data);
|
||||||
} else {
|
} else {
|
||||||
handleSelection(null);
|
handleSelection(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSelection(Device device) {
|
private void handleSelection(IDevice device) {
|
||||||
mResponse.setDeviceToUse(device);
|
mResponse.setDeviceToUse(device);
|
||||||
enableOkButton();
|
enableOkButton();
|
||||||
}
|
}
|
||||||
@@ -686,9 +685,9 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
if (mDeviceTable.getSelectionCount() == 0) {
|
if (mDeviceTable.getSelectionCount() == 0) {
|
||||||
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
|
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
|
||||||
|
|
||||||
Device[] devices = bridge.getDevices();
|
IDevice[] devices = bridge.getDevices();
|
||||||
|
|
||||||
for (Device device : devices) {
|
for (IDevice device : devices) {
|
||||||
Client[] clients = device.getClients();
|
Client[] clients = device.getClients();
|
||||||
|
|
||||||
for (Client client : clients) {
|
for (Client client : clients) {
|
||||||
@@ -724,9 +723,9 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
|||||||
|
|
||||||
// loop through all the Avd and put the one that are not running in the list.
|
// loop through all the Avd and put the one that are not running in the list.
|
||||||
if (mFullAvdList != null) {
|
if (mFullAvdList != null) {
|
||||||
Device[] devices = AndroidDebugBridge.getBridge().getDevices();
|
IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();
|
||||||
avdLoop: for (AvdInfo info : mFullAvdList) {
|
avdLoop: for (AvdInfo info : mFullAvdList) {
|
||||||
for (Device d : devices) {
|
for (IDevice d : devices) {
|
||||||
if (info.getName().equals(d.getAvdName())) {
|
if (info.getName().equals(d.getAvdName())) {
|
||||||
continue avdLoop;
|
continue avdLoop;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.android.ide.eclipse.adt.internal.project;
|
package com.android.ide.eclipse.adt.internal.project;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Device;
|
|
||||||
import com.android.ddmlib.IDevice;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
|
import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
|
||||||
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
||||||
@@ -40,15 +39,15 @@ import java.util.ArrayList;
|
|||||||
* always receive new APKs (since the APK could be uninstalled manually).
|
* always receive new APKs (since the APK could be uninstalled manually).
|
||||||
* <p/>
|
* <p/>
|
||||||
* Manually uninstalling an APK from a connected device will still be a problem, but this should
|
* Manually uninstalling an APK from a connected device will still be a problem, but this should
|
||||||
* be a limited use case.
|
* be a limited use case.
|
||||||
* <p/>
|
* <p/>
|
||||||
* This is a singleton. To get the instance, use {@link #getInstance()}
|
* This is a singleton. To get the instance, use {@link #getInstance()}
|
||||||
*/
|
*/
|
||||||
public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeChangeListener,
|
public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeChangeListener,
|
||||||
IProjectListener {
|
IProjectListener {
|
||||||
|
|
||||||
private final static ApkInstallManager sThis = new ApkInstallManager();
|
private final static ApkInstallManager sThis = new ApkInstallManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal struct to associate a project and a device.
|
* Internal struct to associate a project and a device.
|
||||||
*/
|
*/
|
||||||
@@ -60,13 +59,13 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
|||||||
IProject project;
|
IProject project;
|
||||||
IDevice device;
|
IDevice device;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ArrayList<ApkInstall> mInstallList = new ArrayList<ApkInstall>();
|
private final ArrayList<ApkInstall> mInstallList = new ArrayList<ApkInstall>();
|
||||||
|
|
||||||
public static ApkInstallManager getInstance() {
|
public static ApkInstallManager getInstance() {
|
||||||
return sThis;
|
return sThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an installation of <var>project</var> onto <var>device</var>
|
* Registers an installation of <var>project</var> onto <var>device</var>
|
||||||
* @param project The project that was installed.
|
* @param project The project that was installed.
|
||||||
@@ -77,7 +76,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
|||||||
mInstallList.add(new ApkInstall(project, device));
|
mInstallList.add(new ApkInstall(project, device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a <var>project</var> was installed on the <var>device</var>.
|
* Returns whether a <var>project</var> was installed on the <var>device</var>.
|
||||||
* @param project the project that may have been installed.
|
* @param project the project that may have been installed.
|
||||||
@@ -113,7 +112,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApkInstallManager() {
|
private ApkInstallManager() {
|
||||||
AndroidDebugBridge.addDeviceChangeListener(this);
|
AndroidDebugBridge.addDeviceChangeListener(this);
|
||||||
AndroidDebugBridge.addDebugBridgeChangeListener(this);
|
AndroidDebugBridge.addDebugBridgeChangeListener(this);
|
||||||
@@ -138,7 +137,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
|||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceDisconnected(com.android.ddmlib.Device)
|
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceDisconnected(com.android.ddmlib.Device)
|
||||||
*/
|
*/
|
||||||
public void deviceDisconnected(Device device) {
|
public void deviceDisconnected(IDevice device) {
|
||||||
synchronized (mInstallList) {
|
synchronized (mInstallList) {
|
||||||
for (int i = 0 ; i < mInstallList.size() ;) {
|
for (int i = 0 ; i < mInstallList.size() ;) {
|
||||||
ApkInstall install = mInstallList.get(i);
|
ApkInstall install = mInstallList.get(i);
|
||||||
@@ -174,7 +173,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
|||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceChanged(com.android.ddmlib.Device, int)
|
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceChanged(com.android.ddmlib.Device, int)
|
||||||
*/
|
*/
|
||||||
public void deviceChanged(Device device, int changeMask) {
|
public void deviceChanged(IDevice device, int changeMask) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +182,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
|||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceConnected(com.android.ddmlib.Device)
|
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceConnected(com.android.ddmlib.Device)
|
||||||
*/
|
*/
|
||||||
public void deviceConnected(Device device) {
|
public void deviceConnected(IDevice device) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package com.android.ide.eclipse.ddms;
|
|||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Client;
|
import com.android.ddmlib.Client;
|
||||||
import com.android.ddmlib.DdmPreferences;
|
import com.android.ddmlib.DdmPreferences;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
||||||
import com.android.ddmlib.Log.ILogOutput;
|
import com.android.ddmlib.Log.ILogOutput;
|
||||||
@@ -76,11 +76,11 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
|
|
||||||
/** Image loader object */
|
/** Image loader object */
|
||||||
private ImageLoader mLoader;
|
private ImageLoader mLoader;
|
||||||
|
|
||||||
private Device mCurrentDevice;
|
private IDevice mCurrentDevice;
|
||||||
private Client mCurrentClient;
|
private Client mCurrentClient;
|
||||||
private boolean mListeningToUiSelection = false;
|
private boolean mListeningToUiSelection = false;
|
||||||
|
|
||||||
private final ArrayList<ISelectionListener> mListeners = new ArrayList<ISelectionListener>();
|
private final ArrayList<ISelectionListener> mListeners = new ArrayList<ISelectionListener>();
|
||||||
|
|
||||||
private Color mRed;
|
private Color mRed;
|
||||||
@@ -93,24 +93,24 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
public interface IDebugLauncher {
|
public interface IDebugLauncher {
|
||||||
public boolean debug(String packageName, int port);
|
public boolean debug(String packageName, int port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes which implement this interface provide methods that deals
|
* Classes which implement this interface provide methods that deals
|
||||||
* with {@link Device} and {@link Client} selectionchanges.
|
* with {@link IDevice} and {@link Client} selectionchanges.
|
||||||
*/
|
*/
|
||||||
public interface ISelectionListener {
|
public interface ISelectionListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent when a new {@link Client} is selected.
|
* Sent when a new {@link Client} is selected.
|
||||||
* @param selectedClient The selected client. If null, no clients are selected.
|
* @param selectedClient The selected client. If null, no clients are selected.
|
||||||
*/
|
*/
|
||||||
public void selectionChanged(Client selectedClient);
|
public void selectionChanged(Client selectedClient);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent when a new {@link Device} is selected.
|
* Sent when a new {@link IDevice} is selected.
|
||||||
* @param selectedDevice the selected device. If null, no devices are selected.
|
* @param selectedDevice the selected device. If null, no devices are selected.
|
||||||
*/
|
*/
|
||||||
public void selectionChanged(Device selectedDevice);
|
public void selectionChanged(IDevice selectedDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,14 +128,14 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
@Override
|
@Override
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
|
|
||||||
final Display display = getDisplay();
|
final Display display = getDisplay();
|
||||||
|
|
||||||
// get the eclipse store
|
// get the eclipse store
|
||||||
final IPreferenceStore eclipseStore = getPreferenceStore();
|
final IPreferenceStore eclipseStore = getPreferenceStore();
|
||||||
|
|
||||||
AndroidDebugBridge.addDeviceChangeListener(this);
|
AndroidDebugBridge.addDeviceChangeListener(this);
|
||||||
|
|
||||||
DdmUiPreferences.setStore(eclipseStore);
|
DdmUiPreferences.setStore(eclipseStore);
|
||||||
|
|
||||||
//DdmUiPreferences.displayCharts();
|
//DdmUiPreferences.displayCharts();
|
||||||
@@ -186,12 +186,12 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// create the loader that's able to load the images
|
// create the loader that's able to load the images
|
||||||
mLoader = new ImageLoader(this);
|
mLoader = new ImageLoader(this);
|
||||||
|
|
||||||
// set the listener for the preference change
|
// set the listener for the preference change
|
||||||
Preferences prefs = getPluginPreferences();
|
Preferences prefs = getPluginPreferences();
|
||||||
prefs.addPropertyChangeListener(new IPropertyChangeListener() {
|
prefs.addPropertyChangeListener(new IPropertyChangeListener() {
|
||||||
@@ -214,7 +214,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// read the adb location from the prefs to attempt to start it properly without
|
// read the adb location from the prefs to attempt to start it properly without
|
||||||
// having to wait for ADT to start
|
// having to wait for ADT to start
|
||||||
sAdbLocation = eclipseStore.getString(ADB_LOCATION);
|
sAdbLocation = eclipseStore.getString(ADB_LOCATION);
|
||||||
@@ -248,9 +248,9 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
AndroidDebugBridge.removeDeviceChangeListener(this);
|
AndroidDebugBridge.removeDeviceChangeListener(this);
|
||||||
|
|
||||||
AndroidDebugBridge.terminate();
|
AndroidDebugBridge.terminate();
|
||||||
|
|
||||||
mRed.dispose();
|
mRed.dispose();
|
||||||
|
|
||||||
sPlugin = null;
|
sPlugin = null;
|
||||||
@@ -303,15 +303,15 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void initDdmlib() {
|
private synchronized void initDdmlib() {
|
||||||
if (mDdmlibInitialized == false) {
|
if (mDdmlibInitialized == false) {
|
||||||
// set the preferences.
|
// set the preferences.
|
||||||
PreferenceInitializer.setupPreferences();
|
PreferenceInitializer.setupPreferences();
|
||||||
|
|
||||||
// init the lib
|
// init the lib
|
||||||
AndroidDebugBridge.init(true /* debugger support */);
|
AndroidDebugBridge.init(true /* debugger support */);
|
||||||
|
|
||||||
mDdmlibInitialized = true;
|
mDdmlibInitialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,10 +342,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
public static IDebugLauncher getRunningAppDebugLauncher() {
|
public static IDebugLauncher getRunningAppDebugLauncher() {
|
||||||
return sRunningAppDebugLauncher;
|
return sRunningAppDebugLauncher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addSelectionListener(ISelectionListener listener) {
|
public synchronized void addSelectionListener(ISelectionListener listener) {
|
||||||
mListeners.add(listener);
|
mListeners.add(listener);
|
||||||
|
|
||||||
// notify the new listener of the current selection
|
// notify the new listener of the current selection
|
||||||
listener.selectionChanged(mCurrentDevice);
|
listener.selectionChanged(mCurrentDevice);
|
||||||
listener.selectionChanged(mCurrentClient);
|
listener.selectionChanged(mCurrentClient);
|
||||||
@@ -364,10 +364,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
* <p/>
|
* <p/>
|
||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @param device the new device.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
* @see IDeviceChangeListener#deviceConnected(IDevice)
|
||||||
*/
|
*/
|
||||||
public void deviceConnected(Device device) {
|
public void deviceConnected(IDevice device) {
|
||||||
// if we are listening to selection coming from the ui, then we do nothing, as
|
// if we are listening to selection coming from the ui, then we do nothing, as
|
||||||
// any change in the devices/clients, will be handled by the UI, and we'll receive
|
// any change in the devices/clients, will be handled by the UI, and we'll receive
|
||||||
// selection notification through our implementation of IUiSelectionListener.
|
// selection notification through our implementation of IUiSelectionListener.
|
||||||
@@ -383,10 +383,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
* <p/>
|
* <p/>
|
||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the new device.
|
* @param device the new device.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
* @see IDeviceChangeListener#deviceDisconnected(IDevice)
|
||||||
*/
|
*/
|
||||||
public void deviceDisconnected(Device device) {
|
public void deviceDisconnected(IDevice device) {
|
||||||
// if we are listening to selection coming from the ui, then we do nothing, as
|
// if we are listening to selection coming from the ui, then we do nothing, as
|
||||||
// any change in the devices/clients, will be handled by the UI, and we'll receive
|
// any change in the devices/clients, will be handled by the UI, and we'll receive
|
||||||
// selection notification through our implementation of IUiSelectionListener.
|
// selection notification through our implementation of IUiSelectionListener.
|
||||||
@@ -397,16 +397,16 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
|
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
|
||||||
if (bridge != null) {
|
if (bridge != null) {
|
||||||
// get the device list
|
// get the device list
|
||||||
Device[] devices = bridge.getDevices();
|
IDevice[] devices = bridge.getDevices();
|
||||||
|
|
||||||
// check if we still have devices
|
// check if we still have devices
|
||||||
if (devices.length == 0) {
|
if (devices.length == 0) {
|
||||||
handleDefaultSelection((Device)null);
|
handleDefaultSelection((IDevice)null);
|
||||||
} else {
|
} else {
|
||||||
handleDefaultSelection(devices[0]);
|
handleDefaultSelection(devices[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleDefaultSelection((Device)null);
|
handleDefaultSelection((IDevice)null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,15 +418,15 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
* This is sent from a non UI thread.
|
* This is sent from a non UI thread.
|
||||||
* @param device the device that was updated.
|
* @param device the device that was updated.
|
||||||
* @param changeMask the mask indicating what changed.
|
* @param changeMask the mask indicating what changed.
|
||||||
*
|
*
|
||||||
* @see IDeviceChangeListener#deviceChanged(Device)
|
* @see IDeviceChangeListener#deviceChanged(IDevice)
|
||||||
*/
|
*/
|
||||||
public void deviceChanged(Device device, int changeMask) {
|
public void deviceChanged(IDevice device, int changeMask) {
|
||||||
// if we are listening to selection coming from the ui, then we do nothing, as
|
// if we are listening to selection coming from the ui, then we do nothing, as
|
||||||
// any change in the devices/clients, will be handled by the UI, and we'll receive
|
// any change in the devices/clients, will be handled by the UI, and we'll receive
|
||||||
// selection notification through our implementation of IUiSelectionListener.
|
// selection notification through our implementation of IUiSelectionListener.
|
||||||
if (mListeningToUiSelection == false) {
|
if (mListeningToUiSelection == false) {
|
||||||
|
|
||||||
// check if this is our device
|
// check if this is our device
|
||||||
if (device == mCurrentDevice) {
|
if (device == mCurrentDevice) {
|
||||||
if (mCurrentClient == null) {
|
if (mCurrentClient == null) {
|
||||||
@@ -441,7 +441,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we haven't found our client, lets look for a new one
|
// if we haven't found our client, lets look for a new one
|
||||||
if (foundClient == false) {
|
if (foundClient == false) {
|
||||||
mCurrentClient = null;
|
mCurrentClient = null;
|
||||||
@@ -453,11 +453,11 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 selectedDevice the selected device. If null, no devices are selected.
|
||||||
* @param selectedClient The selected client. If null, no clients are selected.
|
* @param selectedClient The selected client. If null, no clients are selected.
|
||||||
*/
|
*/
|
||||||
public synchronized void selectionChanged(Device selectedDevice, Client selectedClient) {
|
public synchronized void selectionChanged(IDevice selectedDevice, Client selectedClient) {
|
||||||
if (mCurrentDevice != selectedDevice) {
|
if (mCurrentDevice != selectedDevice) {
|
||||||
mCurrentDevice = selectedDevice;
|
mCurrentDevice = selectedDevice;
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
|
|
||||||
if (mCurrentClient != selectedClient) {
|
if (mCurrentClient != selectedClient) {
|
||||||
mCurrentClient = selectedClient;
|
mCurrentClient = selectedClient;
|
||||||
|
|
||||||
// notify of the new default client
|
// notify of the new default client
|
||||||
for (ISelectionListener listener : mListeners) {
|
for (ISelectionListener listener : mListeners) {
|
||||||
listener.selectionChanged(mCurrentClient);
|
listener.selectionChanged(mCurrentClient);
|
||||||
@@ -478,15 +478,15 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a default selection of a {@link Device} and {@link Client}.
|
* Handles a default selection of a {@link IDevice} and {@link Client}.
|
||||||
* @param device the selected device
|
* @param device the selected device
|
||||||
*/
|
*/
|
||||||
private void handleDefaultSelection(final Device device) {
|
private void handleDefaultSelection(final IDevice device) {
|
||||||
// because the listener expect to receive this from the UI thread, and this is called
|
// because the listener expect to receive this from the UI thread, and this is called
|
||||||
// from the AndroidDebugBridge notifications, we need to run this in the UI thread.
|
// from the AndroidDebugBridge notifications, we need to run this in the UI thread.
|
||||||
try {
|
try {
|
||||||
Display display = getDisplay();
|
Display display = getDisplay();
|
||||||
|
|
||||||
display.asyncExec(new Runnable() {
|
display.asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// set the new device if different.
|
// set the new device if different.
|
||||||
@@ -494,13 +494,13 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
if (mCurrentDevice != device) {
|
if (mCurrentDevice != device) {
|
||||||
mCurrentDevice = device;
|
mCurrentDevice = device;
|
||||||
newDevice = true;
|
newDevice = true;
|
||||||
|
|
||||||
// notify of the new default device
|
// notify of the new default device
|
||||||
for (ISelectionListener listener : mListeners) {
|
for (ISelectionListener listener : mListeners) {
|
||||||
listener.selectionChanged(mCurrentDevice);
|
listener.selectionChanged(mCurrentDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
// if this is a device switch or the same device but we didn't find a valid
|
// if this is a device switch or the same device but we didn't find a valid
|
||||||
// client the last time, we go look for a client to use again.
|
// client the last time, we go look for a client to use again.
|
||||||
@@ -522,16 +522,16 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
// display is disposed. Do nothing since we're quitting anyway.
|
// display is disposed. Do nothing since we're quitting anyway.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDefaultSelection(Client client) {
|
private void handleDefaultSelection(Client client) {
|
||||||
mCurrentClient = client;
|
mCurrentClient = client;
|
||||||
|
|
||||||
// notify of the new default client
|
// notify of the new default client
|
||||||
for (ISelectionListener listener : mListeners) {
|
for (ISelectionListener listener : mListeners) {
|
||||||
listener.selectionChanged(mCurrentClient);
|
listener.selectionChanged(mCurrentClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a message, associated with a project to the specified stream
|
* Prints a message, associated with a project to the specified stream
|
||||||
* @param stream The stream to write to
|
* @param stream The stream to write to
|
||||||
@@ -545,7 +545,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
|||||||
stream.print(dateTag);
|
stream.print(dateTag);
|
||||||
stream.println(message);
|
stream.println(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a string containing the current date/time, and the tag
|
* Creates a string containing the current date/time, and the tag
|
||||||
* @param tag The tag associated to the message. Can be null
|
* @param tag The tag associated to the message. Can be null
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package com.android.ide.eclipse.ddms.views;
|
|||||||
import com.android.ddmlib.Client;
|
import com.android.ddmlib.Client;
|
||||||
import com.android.ddmlib.ClientData;
|
import com.android.ddmlib.ClientData;
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmuilib.DevicePanel;
|
import com.android.ddmuilib.DevicePanel;
|
||||||
import com.android.ddmuilib.ScreenShotDialog;
|
import com.android.ddmuilib.ScreenShotDialog;
|
||||||
import com.android.ddmuilib.DevicePanel.IUiSelectionListener;
|
import com.android.ddmuilib.DevicePanel.IUiSelectionListener;
|
||||||
@@ -42,7 +42,7 @@ import org.eclipse.ui.PlatformUI;
|
|||||||
import org.eclipse.ui.part.ViewPart;
|
import org.eclipse.ui.part.ViewPart;
|
||||||
|
|
||||||
public class DeviceView extends ViewPart implements IUiSelectionListener {
|
public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||||
|
|
||||||
private final static boolean USE_SELECTED_DEBUG_PORT = true;
|
private final static boolean USE_SELECTED_DEBUG_PORT = true;
|
||||||
|
|
||||||
public static final String ID =
|
public static final String ID =
|
||||||
@@ -69,7 +69,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
public static DeviceView getInstance() {
|
public static DeviceView getInstance() {
|
||||||
return sThis;
|
return sThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link IDebugLauncher}.
|
* Sets the {@link IDebugLauncher}.
|
||||||
* @param debugLauncher
|
* @param debugLauncher
|
||||||
@@ -89,7 +89,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
mDeviceList = new DevicePanel(DdmsPlugin.getImageLoader(), USE_SELECTED_DEBUG_PORT);
|
mDeviceList = new DevicePanel(DdmsPlugin.getImageLoader(), USE_SELECTED_DEBUG_PORT);
|
||||||
mDeviceList.createPanel(parent);
|
mDeviceList.createPanel(parent);
|
||||||
mDeviceList.addSelectionListener(this);
|
mDeviceList.addSelectionListener(this);
|
||||||
|
|
||||||
DdmsPlugin plugin = DdmsPlugin.getDefault();
|
DdmsPlugin plugin = DdmsPlugin.getDefault();
|
||||||
mDeviceList.addSelectionListener(plugin);
|
mDeviceList.addSelectionListener(plugin);
|
||||||
plugin.setListeningState(true);
|
plugin.setListeningState(true);
|
||||||
@@ -212,7 +212,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
if (packageName != null) {
|
if (packageName != null) {
|
||||||
if (mDebugLauncher.debug(packageName,
|
if (mDebugLauncher.debug(packageName,
|
||||||
currentClient.getDebuggerListenPort()) == false) {
|
currentClient.getDebuggerListenPort()) == false) {
|
||||||
|
|
||||||
// if we get to this point, then we failed to find a project
|
// if we get to this point, then we failed to find a project
|
||||||
// that matched the application to debug
|
// that matched the application to debug
|
||||||
Display display = DdmsPlugin.getDisplay();
|
Display display = DdmsPlugin.getDisplay();
|
||||||
@@ -233,7 +233,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
if (mDebugLauncher == null) {
|
if (mDebugLauncher == null) {
|
||||||
mDebugAction.setEnabled(false);
|
mDebugAction.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
placeActions();
|
placeActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,13 +241,13 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
mDeviceList.setFocus();
|
mDeviceList.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 selectedDevice the selected device. If null, no devices are selected.
|
||||||
* @param selectedClient The selected client. If null, no clients 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) {
|
||||||
// update the buttons
|
// update the buttons
|
||||||
doSelectionChanged(selectedClient);
|
doSelectionChanged(selectedClient);
|
||||||
doSelectionChanged(selectedDevice);
|
doSelectionChanged(selectedDevice);
|
||||||
@@ -264,7 +264,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
mDebugAction.setEnabled(mDebugLauncher != null);
|
mDebugAction.setEnabled(mDebugLauncher != null);
|
||||||
mKillAppAction.setEnabled(true);
|
mKillAppAction.setEnabled(true);
|
||||||
mGcAction.setEnabled(true);
|
mGcAction.setEnabled(true);
|
||||||
|
|
||||||
mUpdateHeapAction.setEnabled(true);
|
mUpdateHeapAction.setEnabled(true);
|
||||||
mUpdateHeapAction.setChecked(selectedClient.isHeapUpdateEnabled());
|
mUpdateHeapAction.setChecked(selectedClient.isHeapUpdateEnabled());
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
bridge.setSelectedClient(null);
|
bridge.setSelectedClient(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebugAction.setEnabled(false);
|
mDebugAction.setEnabled(false);
|
||||||
mKillAppAction.setEnabled(false);
|
mKillAppAction.setEnabled(false);
|
||||||
mGcAction.setEnabled(false);
|
mGcAction.setEnabled(false);
|
||||||
@@ -288,8 +288,8 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
|||||||
mUpdateThreadAction.setChecked(false);
|
mUpdateThreadAction.setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSelectionChanged(Device selectedDevice) {
|
private void doSelectionChanged(IDevice selectedDevice) {
|
||||||
mCaptureAction.setEnabled(selectedDevice != null);
|
mCaptureAction.setEnabled(selectedDevice != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.ide.eclipse.ddms.views;
|
package com.android.ide.eclipse.ddms.views;
|
||||||
|
|
||||||
import com.android.ddmlib.Client;
|
import com.android.ddmlib.Client;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmuilib.explorer.DeviceExplorer;
|
import com.android.ddmuilib.explorer.DeviceExplorer;
|
||||||
import com.android.ide.eclipse.ddms.CommonAction;
|
import com.android.ide.eclipse.ddms.CommonAction;
|
||||||
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
||||||
@@ -26,6 +26,7 @@ import com.android.ide.eclipse.ddms.DdmsPlugin.ISelectionListener;
|
|||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IToolBarManager;
|
||||||
import org.eclipse.jface.action.Separator;
|
import org.eclipse.jface.action.Separator;
|
||||||
|
import org.eclipse.swt.graphics.Device;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.ISharedImages;
|
import org.eclipse.ui.ISharedImages;
|
||||||
@@ -128,7 +129,7 @@ public class FileExplorerView extends ViewPart implements ISelectionListener {
|
|||||||
toolBarManager.add(pushAction);
|
toolBarManager.add(pushAction);
|
||||||
toolBarManager.add(new Separator());
|
toolBarManager.add(new Separator());
|
||||||
toolBarManager.add(deleteAction);
|
toolBarManager.add(deleteAction);
|
||||||
|
|
||||||
mExplorer.createPanel(parent);
|
mExplorer.createPanel(parent);
|
||||||
|
|
||||||
DdmsPlugin.getDefault().addSelectionListener(this);
|
DdmsPlugin.getDefault().addSelectionListener(this);
|
||||||
@@ -146,20 +147,20 @@ public class FileExplorerView extends ViewPart implements ISelectionListener {
|
|||||||
public void selectionChanged(Client selectedClient) {
|
public void selectionChanged(Client selectedClient) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent when a new {@link Device} is selected.
|
* Sent when a new {@link Device} is selected.
|
||||||
* @param selectedDevice the selected device.
|
* @param selectedDevice the selected device.
|
||||||
*/
|
*/
|
||||||
public void selectionChanged(Device selectedDevice) {
|
public void selectionChanged(IDevice selectedDevice) {
|
||||||
mExplorer.switchDevice(selectedDevice);
|
mExplorer.switchDevice(selectedDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent when there is no current selection.
|
* Sent when there is no current selection.
|
||||||
*/
|
*/
|
||||||
public void selectionRemoved() {
|
public void selectionRemoved() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
|
|
||||||
package com.android.ide.eclipse.ddms.views;
|
package com.android.ide.eclipse.ddms.views;
|
||||||
|
|
||||||
|
import com.android.ddmlib.Client;
|
||||||
|
import com.android.ddmlib.IDevice;
|
||||||
|
import com.android.ddmuilib.SelectionDependentPanel;
|
||||||
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
||||||
import com.android.ide.eclipse.ddms.DdmsPlugin.ISelectionListener;
|
import com.android.ide.eclipse.ddms.DdmsPlugin.ISelectionListener;
|
||||||
import com.android.ddmlib.Client;
|
|
||||||
import com.android.ddmlib.Device;
|
|
||||||
import com.android.ddmuilib.SelectionDependentPanel;
|
|
||||||
|
|
||||||
|
import org.eclipse.swt.graphics.Device;
|
||||||
import org.eclipse.ui.part.ViewPart;
|
import org.eclipse.ui.part.ViewPart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,17 +30,17 @@ import org.eclipse.ui.part.ViewPart;
|
|||||||
* from {@link DdmsPlugin} through the {@link ISelectionListener} interface.
|
* from {@link DdmsPlugin} through the {@link ISelectionListener} interface.
|
||||||
*/
|
*/
|
||||||
public abstract class SelectionDependentViewPart extends ViewPart implements ISelectionListener {
|
public abstract class SelectionDependentViewPart extends ViewPart implements ISelectionListener {
|
||||||
|
|
||||||
private SelectionDependentPanel mPanel;
|
private SelectionDependentPanel mPanel;
|
||||||
|
|
||||||
protected final void setSelectionDependentPanel(SelectionDependentPanel panel) {
|
protected final void setSelectionDependentPanel(SelectionDependentPanel panel) {
|
||||||
// remember the panel
|
// remember the panel
|
||||||
mPanel = panel;
|
mPanel = panel;
|
||||||
|
|
||||||
// and add ourself as listener of selection events.
|
// and add ourself as listener of selection events.
|
||||||
DdmsPlugin.getDefault().addSelectionListener(this);
|
DdmsPlugin.getDefault().addSelectionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
DdmsPlugin.getDefault().removeSelectionListener(this);
|
DdmsPlugin.getDefault().removeSelectionListener(this);
|
||||||
@@ -49,20 +50,20 @@ public abstract class SelectionDependentViewPart extends ViewPart implements ISe
|
|||||||
/**
|
/**
|
||||||
* Sent when a new {@link Client} is selected.
|
* Sent when a new {@link Client} is selected.
|
||||||
* @param selectedClient The selected client.
|
* @param selectedClient The selected client.
|
||||||
*
|
*
|
||||||
* @see ISelectionListener
|
* @see ISelectionListener
|
||||||
*/
|
*/
|
||||||
public final void selectionChanged(Client selectedClient) {
|
public final void selectionChanged(Client selectedClient) {
|
||||||
mPanel.clientSelected(selectedClient);
|
mPanel.clientSelected(selectedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent when a new {@link Device} is selected.
|
* Sent when a new {@link Device} is selected.
|
||||||
* @param selectedDevice the selected device.
|
* @param selectedDevice the selected device.
|
||||||
*
|
*
|
||||||
* @see ISelectionListener
|
* @see ISelectionListener
|
||||||
*/
|
*/
|
||||||
public final void selectionChanged(Device selectedDevice) {
|
public final void selectionChanged(IDevice selectedDevice) {
|
||||||
mPanel.deviceSelected(selectedDevice);
|
mPanel.deviceSelected(selectedDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.eventanalyzer;
|
package com.android.eventanalyzer;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.Log.ILogOutput;
|
import com.android.ddmlib.Log.ILogOutput;
|
||||||
import com.android.ddmlib.Log.LogLevel;
|
import com.android.ddmlib.Log.LogLevel;
|
||||||
@@ -42,19 +42,19 @@ import java.util.Set;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a device using ddmlib and analyze its event log.
|
* Connects to a device using ddmlib and analyze its event log.
|
||||||
*/
|
*/
|
||||||
public class EventAnalyzer implements ILogListener {
|
public class EventAnalyzer implements ILogListener {
|
||||||
|
|
||||||
private final static int TAG_ACTIVITY_LAUNCH_TIME = 30009;
|
private final static int TAG_ACTIVITY_LAUNCH_TIME = 30009;
|
||||||
private final static char DATA_SEPARATOR = ',';
|
private final static char DATA_SEPARATOR = ',';
|
||||||
|
|
||||||
private final static String CVS_EXT = ".csv";
|
private final static String CVS_EXT = ".csv";
|
||||||
private final static String TAG_FILE_EXT = ".tag"; //$NON-NLS-1$
|
private final static String TAG_FILE_EXT = ".tag"; //$NON-NLS-1$
|
||||||
|
|
||||||
private EventLogParser mParser;
|
private EventLogParser mParser;
|
||||||
private TreeMap<String, ArrayList<Long>> mLaunchMap = new TreeMap<String, ArrayList<Long>>();
|
private TreeMap<String, ArrayList<Long>> mLaunchMap = new TreeMap<String, ArrayList<Long>>();
|
||||||
|
|
||||||
String mInputTextFile = null;
|
String mInputTextFile = null;
|
||||||
String mInputBinaryFile = null;
|
String mInputBinaryFile = null;
|
||||||
String mInputDevice = null;
|
String mInputDevice = null;
|
||||||
@@ -65,47 +65,47 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new EventAnalyzer().run(args);
|
new EventAnalyzer().run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run(String[] args) {
|
private void run(String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
printUsageAndQuit();
|
printUsageAndQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
do {
|
do {
|
||||||
String argument = args[index++];
|
String argument = args[index++];
|
||||||
|
|
||||||
if ("-s".equals(argument)) {
|
if ("-s".equals(argument)) {
|
||||||
checkInputValidity("-s");
|
checkInputValidity("-s");
|
||||||
|
|
||||||
if (index == args.length) {
|
if (index == args.length) {
|
||||||
printUsageAndQuit();
|
printUsageAndQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
mInputDevice = args[index++];
|
mInputDevice = args[index++];
|
||||||
} else if ("-fb".equals(argument)) {
|
} else if ("-fb".equals(argument)) {
|
||||||
checkInputValidity("-fb");
|
checkInputValidity("-fb");
|
||||||
|
|
||||||
if (index == args.length) {
|
if (index == args.length) {
|
||||||
printUsageAndQuit();
|
printUsageAndQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
mInputBinaryFile = args[index++];
|
mInputBinaryFile = args[index++];
|
||||||
} else if ("-ft".equals(argument)) {
|
} else if ("-ft".equals(argument)) {
|
||||||
checkInputValidity("-ft");
|
checkInputValidity("-ft");
|
||||||
|
|
||||||
if (index == args.length) {
|
if (index == args.length) {
|
||||||
printUsageAndQuit();
|
printUsageAndQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
mInputTextFile = args[index++];
|
mInputTextFile = args[index++];
|
||||||
} else if ("-F".equals(argument)) {
|
} else if ("-F".equals(argument)) {
|
||||||
checkInputValidity("-F");
|
checkInputValidity("-F");
|
||||||
|
|
||||||
if (index == args.length) {
|
if (index == args.length) {
|
||||||
printUsageAndQuit();
|
printUsageAndQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
mInputFolder = args[index++];
|
mInputFolder = args[index++];
|
||||||
} else if ("-t".equals(argument)) {
|
} else if ("-t".equals(argument)) {
|
||||||
if (index == args.length) {
|
if (index == args.length) {
|
||||||
@@ -156,17 +156,17 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
} else if (mInputDevice != null) {
|
} else if (mInputDevice != null) {
|
||||||
parseLogFromDevice();
|
parseLogFromDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
// analyze the data gathered by the parser methods
|
// analyze the data gathered by the parser methods
|
||||||
analyzeData();
|
analyzeData();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a binary event log file located at {@link #mInputBinaryFile}.
|
* Parses a binary event log file located at {@link #mInputBinaryFile}.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void parseBinaryLogFile() throws IOException {
|
private void parseBinaryLogFile() throws IOException {
|
||||||
mParser = new EventLogParser();
|
mParser = new EventLogParser();
|
||||||
@@ -183,13 +183,13 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
printAndExit("Failed to get event tags from " + tagFile, false /* terminate*/);
|
printAndExit("Failed to get event tags from " + tagFile, false /* terminate*/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogReceiver receiver = new LogReceiver(this);
|
LogReceiver receiver = new LogReceiver(this);
|
||||||
|
|
||||||
byte[] buffer = new byte[256];
|
byte[] buffer = new byte[256];
|
||||||
|
|
||||||
FileInputStream fis = new FileInputStream(mInputBinaryFile);
|
FileInputStream fis = new FileInputStream(mInputBinaryFile);
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
while ((count = fis.read(buffer)) != -1) {
|
while ((count = fis.read(buffer)) != -1) {
|
||||||
receiver.parseNewData(buffer, 0, count);
|
receiver.parseNewData(buffer, 0, count);
|
||||||
@@ -230,10 +230,10 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
private void parseLogFromDevice() throws IOException {
|
private void parseLogFromDevice() throws IOException {
|
||||||
// init the lib
|
// init the lib
|
||||||
AndroidDebugBridge.init(false /* debugger support */);
|
AndroidDebugBridge.init(false /* debugger support */);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge();
|
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge();
|
||||||
|
|
||||||
// we can't just ask for the device list right away, as the internal thread getting
|
// we can't just ask for the device list right away, as the internal thread getting
|
||||||
// them from ADB may not be done getting the first list.
|
// them from ADB may not be done getting the first list.
|
||||||
// Since we don't really want getDevices() to be blocking, we wait here manually.
|
// Since we don't really want getDevices() to be blocking, we wait here manually.
|
||||||
@@ -245,7 +245,7 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's not wait > 10 sec.
|
// let's not wait > 10 sec.
|
||||||
if (count > 100) {
|
if (count > 100) {
|
||||||
printAndExit("Timeout getting device list!", true /* terminate*/);
|
printAndExit("Timeout getting device list!", true /* terminate*/);
|
||||||
@@ -253,21 +253,21 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now get the devices
|
// now get the devices
|
||||||
Device[] devices = bridge.getDevices();
|
IDevice[] devices = bridge.getDevices();
|
||||||
|
|
||||||
for (Device device : devices) {
|
for (IDevice device : devices) {
|
||||||
if (device.getSerialNumber().equals(mInputDevice)) {
|
if (device.getSerialNumber().equals(mInputDevice)) {
|
||||||
grabLogFrom(device);
|
grabLogFrom(device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.println("Could not find " + mInputDevice);
|
System.err.println("Could not find " + mInputDevice);
|
||||||
} finally {
|
} finally {
|
||||||
AndroidDebugBridge.terminate();
|
AndroidDebugBridge.terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the log files located in the folder, and its sub-folders.
|
* Parses the log files located in the folder, and its sub-folders.
|
||||||
* @param folderPath the path to the folder.
|
* @param folderPath the path to the folder.
|
||||||
@@ -278,14 +278,14 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
printAndExit(String.format("%1$s is not a valid folder", folderPath),
|
printAndExit(String.format("%1$s is not a valid folder", folderPath),
|
||||||
false /* terminate */);
|
false /* terminate */);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] files = f.list(new FilenameFilter() {
|
String[] files = f.list(new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
return name.endsWith(".tag") == false;
|
return name.endsWith(".tag") == false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
try {
|
try {
|
||||||
f = new File(folderPath + File.separator + file);
|
f = new File(folderPath + File.separator + file);
|
||||||
@@ -300,18 +300,18 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void grabLogFrom(Device device) throws IOException {
|
private void grabLogFrom(IDevice device) throws IOException {
|
||||||
mParser = new EventLogParser();
|
mParser = new EventLogParser();
|
||||||
if (mParser.init(device) == false) {
|
if (mParser.init(device) == false) {
|
||||||
printAndExit("Failed to get event-log-tags from " + device.getSerialNumber(),
|
printAndExit("Failed to get event-log-tags from " + device.getSerialNumber(),
|
||||||
true /* terminate*/);
|
true /* terminate*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogReceiver receiver = new LogReceiver(this);
|
LogReceiver receiver = new LogReceiver(this);
|
||||||
|
|
||||||
device.runEventLogService(receiver);
|
device.runEventLogService(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyze the data and writes it to {@link #mOutputFile}
|
* Analyze the data and writes it to {@link #mOutputFile}
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@@ -326,23 +326,23 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
|
|
||||||
writer = new BufferedWriter(new FileWriter(mOutputFile));
|
writer = new BufferedWriter(new FileWriter(mOutputFile));
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
// write the list of launch start. One column per activity.
|
// write the list of launch start. One column per activity.
|
||||||
Set<String> activities = mLaunchMap.keySet();
|
Set<String> activities = mLaunchMap.keySet();
|
||||||
|
|
||||||
// write the column headers.
|
// write the column headers.
|
||||||
for (String activity : activities) {
|
for (String activity : activities) {
|
||||||
builder.append(activity).append(DATA_SEPARATOR);
|
builder.append(activity).append(DATA_SEPARATOR);
|
||||||
}
|
}
|
||||||
writer.write(builder.append('\n').toString());
|
writer.write(builder.append('\n').toString());
|
||||||
|
|
||||||
// loop on the activities and write their values.
|
// loop on the activities and write their values.
|
||||||
boolean moreValues = true;
|
boolean moreValues = true;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (moreValues) {
|
while (moreValues) {
|
||||||
moreValues = false;
|
moreValues = false;
|
||||||
builder.setLength(0);
|
builder.setLength(0);
|
||||||
|
|
||||||
for (String activity : activities) {
|
for (String activity : activities) {
|
||||||
// get the activity list.
|
// get the activity list.
|
||||||
ArrayList<Long> list = mLaunchMap.get(activity);
|
ArrayList<Long> list = mLaunchMap.get(activity);
|
||||||
@@ -353,33 +353,33 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
builder.append(DATA_SEPARATOR);
|
builder.append(DATA_SEPARATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the line.
|
// write the line.
|
||||||
if (moreValues) {
|
if (moreValues) {
|
||||||
writer.write(builder.append('\n').toString());
|
writer.write(builder.append('\n').toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write per-activity stats.
|
// write per-activity stats.
|
||||||
for (String activity : activities) {
|
for (String activity : activities) {
|
||||||
builder.setLength(0);
|
builder.setLength(0);
|
||||||
builder.append(activity).append(DATA_SEPARATOR);
|
builder.append(activity).append(DATA_SEPARATOR);
|
||||||
|
|
||||||
// get the activity list.
|
// get the activity list.
|
||||||
ArrayList<Long> list = mLaunchMap.get(activity);
|
ArrayList<Long> list = mLaunchMap.get(activity);
|
||||||
|
|
||||||
// sort the list
|
// sort the list
|
||||||
Collections.sort(list);
|
Collections.sort(list);
|
||||||
|
|
||||||
// write min/max
|
// write min/max
|
||||||
builder.append(list.get(0).longValue()).append(DATA_SEPARATOR);
|
builder.append(list.get(0).longValue()).append(DATA_SEPARATOR);
|
||||||
builder.append(list.get(list.size()-1).longValue()).append(DATA_SEPARATOR);
|
builder.append(list.get(list.size()-1).longValue()).append(DATA_SEPARATOR);
|
||||||
|
|
||||||
// write median value
|
// write median value
|
||||||
builder.append(list.get(list.size()/2).longValue()).append(DATA_SEPARATOR);
|
builder.append(list.get(list.size()/2).longValue()).append(DATA_SEPARATOR);
|
||||||
|
|
||||||
// compute and write average
|
// compute and write average
|
||||||
long total = 0; // despite being encoded on a long, the values are low enough that
|
long total = 0; // despite being encoded on a long, the values are low enough that
|
||||||
// a Long should be enough to compute the total
|
// a Long should be enough to compute the total
|
||||||
@@ -387,7 +387,7 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
total += value.longValue();
|
total += value.longValue();
|
||||||
}
|
}
|
||||||
builder.append(total / list.size()).append(DATA_SEPARATOR);
|
builder.append(total / list.size()).append(DATA_SEPARATOR);
|
||||||
|
|
||||||
// finally write the data.
|
// finally write the data.
|
||||||
writer.write(builder.append('\n').toString());
|
writer.write(builder.append('\n').toString());
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,7 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
// parse and process the entry data.
|
// parse and process the entry data.
|
||||||
processEvent(mParser.parse(entry));
|
processEvent(mParser.parse(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processEvent(EventContainer event) {
|
private void processEvent(EventContainer event) {
|
||||||
if (event != null && event.mTag == TAG_ACTIVITY_LAUNCH_TIME) {
|
if (event != null && event.mTag == TAG_ACTIVITY_LAUNCH_TIME) {
|
||||||
// get the activity name
|
// get the activity name
|
||||||
@@ -434,12 +434,12 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
|
|
||||||
private void addLaunchTime(String name, Long value) {
|
private void addLaunchTime(String name, Long value) {
|
||||||
ArrayList<Long> list = mLaunchMap.get(name);
|
ArrayList<Long> list = mLaunchMap.get(name);
|
||||||
|
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList<Long>();
|
list = new ArrayList<Long>();
|
||||||
mLaunchMap.put(name, list);
|
mLaunchMap.put(name, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(value);
|
list.add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,11 +469,11 @@ public class EventAnalyzer implements ILogListener {
|
|||||||
System.out.println("Options:");
|
System.out.println("Options:");
|
||||||
System.out.println(" -t <file> The path to tag file to use in case the one associated with");
|
System.out.println(" -t <file> The path to tag file to use in case the one associated with");
|
||||||
System.out.println(" the source is missing");
|
System.out.println(" the source is missing");
|
||||||
|
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void printAndExit(String message, boolean terminate) {
|
private static void printAndExit(String message, boolean terminate) {
|
||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
if (terminate) {
|
if (terminate) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.hierarchyviewer.device;
|
package com.android.hierarchyviewer.device;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.MultiLineReceiver;
|
import com.android.ddmlib.MultiLineReceiver;
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class DeviceBridge {
|
public class DeviceBridge {
|
||||||
private static AndroidDebugBridge bridge;
|
private static AndroidDebugBridge bridge;
|
||||||
|
|
||||||
private static final HashMap<Device, Integer> devicePortMap = new HashMap<Device, Integer>();
|
private static final HashMap<IDevice, Integer> devicePortMap = new HashMap<IDevice, Integer>();
|
||||||
private static int nextLocalPort = Configuration.DEFAULT_SERVER_PORT;
|
private static int nextLocalPort = Configuration.DEFAULT_SERVER_PORT;
|
||||||
|
|
||||||
public static void initDebugBridge() {
|
public static void initDebugBridge() {
|
||||||
@@ -57,11 +57,11 @@ public class DeviceBridge {
|
|||||||
AndroidDebugBridge.removeDeviceChangeListener(listener);
|
AndroidDebugBridge.removeDeviceChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Device[] getDevices() {
|
public static IDevice[] getDevices() {
|
||||||
return bridge.getDevices();
|
return bridge.getDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isViewServerRunning(Device device) {
|
public static boolean isViewServerRunning(IDevice device) {
|
||||||
initDebugBridge();
|
initDebugBridge();
|
||||||
final boolean[] result = new boolean[1];
|
final boolean[] result = new boolean[1];
|
||||||
try {
|
try {
|
||||||
@@ -75,11 +75,11 @@ public class DeviceBridge {
|
|||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean startViewServer(Device device) {
|
public static boolean startViewServer(IDevice device) {
|
||||||
return startViewServer(device, Configuration.DEFAULT_SERVER_PORT);
|
return startViewServer(device, Configuration.DEFAULT_SERVER_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean startViewServer(Device device, int port) {
|
public static boolean startViewServer(IDevice device, int port) {
|
||||||
initDebugBridge();
|
initDebugBridge();
|
||||||
final boolean[] result = new boolean[1];
|
final boolean[] result = new boolean[1];
|
||||||
try {
|
try {
|
||||||
@@ -93,7 +93,7 @@ public class DeviceBridge {
|
|||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean stopViewServer(Device device) {
|
public static boolean stopViewServer(IDevice device) {
|
||||||
initDebugBridge();
|
initDebugBridge();
|
||||||
final boolean[] result = new boolean[1];
|
final boolean[] result = new boolean[1];
|
||||||
try {
|
try {
|
||||||
@@ -116,17 +116,17 @@ public class DeviceBridge {
|
|||||||
* <p/>This starts a port forwarding between a local port and a port on the device.
|
* <p/>This starts a port forwarding between a local port and a port on the device.
|
||||||
* @param device
|
* @param device
|
||||||
*/
|
*/
|
||||||
public static void setupDeviceForward(Device device) {
|
public static void setupDeviceForward(IDevice device) {
|
||||||
synchronized (devicePortMap) {
|
synchronized (devicePortMap) {
|
||||||
if (device.getState() == Device.DeviceState.ONLINE) {
|
if (device.getState() == IDevice.DeviceState.ONLINE) {
|
||||||
int localPort = nextLocalPort++;
|
int localPort = nextLocalPort++;
|
||||||
device.createForward(localPort, Configuration.DEFAULT_SERVER_PORT);
|
device.createForward(localPort, Configuration.DEFAULT_SERVER_PORT);
|
||||||
devicePortMap.put(device, localPort);
|
devicePortMap.put(device, localPort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeDeviceForward(Device device) {
|
public static void removeDeviceForward(IDevice device) {
|
||||||
synchronized (devicePortMap) {
|
synchronized (devicePortMap) {
|
||||||
final Integer localPort = devicePortMap.get(device);
|
final Integer localPort = devicePortMap.get(device);
|
||||||
if (localPort != null) {
|
if (localPort != null) {
|
||||||
@@ -135,18 +135,18 @@ public class DeviceBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDeviceLocalPort(Device device) {
|
public static int getDeviceLocalPort(IDevice device) {
|
||||||
synchronized (devicePortMap) {
|
synchronized (devicePortMap) {
|
||||||
Integer port = devicePortMap.get(device);
|
Integer port = devicePortMap.get(device);
|
||||||
if (port != null) {
|
if (port != null) {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.e("hierarchy", "Missing forwarded port for " + device.getSerialNumber());
|
Log.e("hierarchy", "Missing forwarded port for " + device.getSerialNumber());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String buildStartServerShellCommand(int port) {
|
private static String buildStartServerShellCommand(int port) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.hierarchyviewer.scene;
|
package com.android.hierarchyviewer.scene;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.hierarchyviewer.device.Configuration;
|
import com.android.hierarchyviewer.device.Configuration;
|
||||||
import com.android.hierarchyviewer.device.Window;
|
import com.android.hierarchyviewer.device.Window;
|
||||||
import com.android.hierarchyviewer.device.DeviceBridge;
|
import com.android.hierarchyviewer.device.DeviceBridge;
|
||||||
@@ -31,16 +31,16 @@ import java.net.Socket;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
public class CaptureLoader {
|
public class CaptureLoader {
|
||||||
public static Image loadCapture(Device device, Window window, String params) {
|
public static Image loadCapture(IDevice device, Window window, String params) {
|
||||||
Socket socket = null;
|
Socket socket = null;
|
||||||
BufferedInputStream in = null;
|
BufferedInputStream in = null;
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
socket.connect(new InetSocketAddress("127.0.0.1",
|
socket.connect(new InetSocketAddress("127.0.0.1",
|
||||||
DeviceBridge.getDeviceLocalPort(device)));
|
DeviceBridge.getDeviceLocalPort(device)));
|
||||||
|
|
||||||
out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
|
out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
|
||||||
in = new BufferedInputStream(socket.getInputStream());
|
in = new BufferedInputStream(socket.getInputStream());
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public class CaptureLoader {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.hierarchyviewer.scene;
|
package com.android.hierarchyviewer.scene;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.hierarchyviewer.device.Window;
|
import com.android.hierarchyviewer.device.Window;
|
||||||
import com.android.hierarchyviewer.device.DeviceBridge;
|
import com.android.hierarchyviewer.device.DeviceBridge;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class ProfilesLoader {
|
public class ProfilesLoader {
|
||||||
public static double[] loadProfiles(Device device, Window window, String params) {
|
public static double[] loadProfiles(IDevice device, Window window, String params) {
|
||||||
Socket socket = null;
|
Socket socket = null;
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.hierarchyviewer.scene;
|
package com.android.hierarchyviewer.scene;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.hierarchyviewer.device.DeviceBridge;
|
import com.android.hierarchyviewer.device.DeviceBridge;
|
||||||
import com.android.hierarchyviewer.device.Window;
|
import com.android.hierarchyviewer.device.Window;
|
||||||
|
|
||||||
@@ -36,19 +36,19 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class ViewHierarchyLoader {
|
public class ViewHierarchyLoader {
|
||||||
@SuppressWarnings("empty-statement")
|
@SuppressWarnings("empty-statement")
|
||||||
public static ViewHierarchyScene loadScene(Device device, Window window) {
|
public static ViewHierarchyScene loadScene(IDevice device, Window window) {
|
||||||
ViewHierarchyScene scene = new ViewHierarchyScene();
|
ViewHierarchyScene scene = new ViewHierarchyScene();
|
||||||
|
|
||||||
// Read the views tree
|
// Read the views tree
|
||||||
Socket socket = null;
|
Socket socket = null;
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.out.println("==> Starting client");
|
System.out.println("==> Starting client");
|
||||||
|
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
socket.connect(new InetSocketAddress("127.0.0.1",
|
socket.connect(new InetSocketAddress("127.0.0.1",
|
||||||
DeviceBridge.getDeviceLocalPort(device)));
|
DeviceBridge.getDeviceLocalPort(device)));
|
||||||
@@ -57,11 +57,11 @@ public class ViewHierarchyLoader {
|
|||||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||||
|
|
||||||
System.out.println("==> DUMP");
|
System.out.println("==> DUMP");
|
||||||
|
|
||||||
out.write("DUMP " + window.encode());
|
out.write("DUMP " + window.encode());
|
||||||
out.newLine();
|
out.newLine();
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
Stack<ViewNode> stack = new Stack<ViewNode>();
|
Stack<ViewNode> stack = new Stack<ViewNode>();
|
||||||
|
|
||||||
boolean setRoot = true;
|
boolean setRoot = true;
|
||||||
@@ -72,7 +72,7 @@ public class ViewHierarchyLoader {
|
|||||||
if ("DONE.".equalsIgnoreCase(line)) {
|
if ("DONE.".equalsIgnoreCase(line)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int whitespaceCount = countFrontWhitespace(line);
|
int whitespaceCount = countFrontWhitespace(line);
|
||||||
if (lastWhitespaceCount < whitespaceCount) {
|
if (lastWhitespaceCount < whitespaceCount) {
|
||||||
stack.push(lastNode);
|
stack.push(lastNode);
|
||||||
@@ -86,7 +86,7 @@ public class ViewHierarchyLoader {
|
|||||||
lastWhitespaceCount = whitespaceCount;
|
lastWhitespaceCount = whitespaceCount;
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
int index = line.indexOf(' ');
|
int index = line.indexOf(' ');
|
||||||
|
|
||||||
lastNode = new ViewNode();
|
lastNode = new ViewNode();
|
||||||
lastNode.name = line.substring(0, index);
|
lastNode.name = line.substring(0, index);
|
||||||
|
|
||||||
@@ -94,12 +94,12 @@ public class ViewHierarchyLoader {
|
|||||||
loadProperties(lastNode, line);
|
loadProperties(lastNode, line);
|
||||||
|
|
||||||
scene.addNode(lastNode);
|
scene.addNode(lastNode);
|
||||||
|
|
||||||
if (setRoot) {
|
if (setRoot) {
|
||||||
scene.setRoot(lastNode);
|
scene.setRoot(lastNode);
|
||||||
setRoot = false;
|
setRoot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
final ViewNode parent = stack.peek();
|
final ViewNode parent = stack.peek();
|
||||||
final String edge = parent.name + lastNode.name;
|
final String edge = parent.name + lastNode.name;
|
||||||
@@ -128,7 +128,7 @@ public class ViewHierarchyLoader {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("==> DONE");
|
System.out.println("==> DONE");
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
@@ -165,7 +165,7 @@ public class ViewHierarchyLoader {
|
|||||||
int length = Integer.parseInt(data.substring(index + 1, index2));
|
int length = Integer.parseInt(data.substring(index + 1, index2));
|
||||||
start = index2 + 1 + length;
|
start = index2 + 1 + length;
|
||||||
property.value = data.substring(index2 + 1, index2 + 1 + length);
|
property.value = data.substring(index2 + 1, index2 + 1 + length);
|
||||||
|
|
||||||
node.properties.add(property);
|
node.properties.add(property);
|
||||||
node.namedProperties.put(property.name, property);
|
node.namedProperties.put(property.name, property);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.hierarchyviewer.scene;
|
package com.android.hierarchyviewer.scene;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.hierarchyviewer.device.Window;
|
import com.android.hierarchyviewer.device.Window;
|
||||||
import com.android.hierarchyviewer.device.DeviceBridge;
|
import com.android.hierarchyviewer.device.DeviceBridge;
|
||||||
|
|
||||||
@@ -27,15 +27,15 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
public class ViewManager {
|
public class ViewManager {
|
||||||
public static void invalidate(Device device, Window window, String params) {
|
public static void invalidate(IDevice device, Window window, String params) {
|
||||||
sendCommand("INVALIDATE", device, window, params);
|
sendCommand("INVALIDATE", device, window, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void requestLayout(Device device, Window window, String params) {
|
public static void requestLayout(IDevice device, Window window, String params) {
|
||||||
sendCommand("REQUEST_LAYOUT", device, window, params);
|
sendCommand("REQUEST_LAYOUT", device, window, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendCommand(String command, Device device, Window window, String params) {
|
private static void sendCommand(String command, IDevice device, Window window, String params) {
|
||||||
Socket socket = null;
|
Socket socket = null;
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.hierarchyviewer.scene;
|
package com.android.hierarchyviewer.scene;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.hierarchyviewer.device.DeviceBridge;
|
import com.android.hierarchyviewer.device.DeviceBridge;
|
||||||
import com.android.hierarchyviewer.device.Window;
|
import com.android.hierarchyviewer.device.Window;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ import java.net.Socket;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class WindowsLoader {
|
public class WindowsLoader {
|
||||||
public static Window[] loadWindows(Device device) {
|
public static Window[] loadWindows(IDevice device) {
|
||||||
Socket socket = null;
|
Socket socket = null;
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.android.hierarchyviewer.ui;
|
package com.android.hierarchyviewer.ui;
|
||||||
|
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.RawImage;
|
import com.android.ddmlib.RawImage;
|
||||||
import com.android.hierarchyviewer.util.WorkerThread;
|
import com.android.hierarchyviewer.util.WorkerThread;
|
||||||
import com.android.hierarchyviewer.scene.ViewNode;
|
import com.android.hierarchyviewer.scene.ViewNode;
|
||||||
@@ -51,14 +51,14 @@ import java.util.concurrent.ExecutionException;
|
|||||||
|
|
||||||
class ScreenViewer extends JPanel implements ActionListener {
|
class ScreenViewer extends JPanel implements ActionListener {
|
||||||
private final Workspace workspace;
|
private final Workspace workspace;
|
||||||
private final Device device;
|
private final IDevice device;
|
||||||
|
|
||||||
private GetScreenshotTask task;
|
private GetScreenshotTask task;
|
||||||
private BufferedImage image;
|
private BufferedImage image;
|
||||||
private int[] scanline;
|
private int[] scanline;
|
||||||
private volatile boolean isLoading;
|
private volatile boolean isLoading;
|
||||||
|
|
||||||
private BufferedImage overlay;
|
private BufferedImage overlay;
|
||||||
private AlphaComposite overlayAlpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
|
private AlphaComposite overlayAlpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
|
||||||
|
|
||||||
private ScreenViewer.LoupeStatus status;
|
private ScreenViewer.LoupeStatus status;
|
||||||
@@ -73,7 +73,7 @@ class ScreenViewer extends JPanel implements ActionListener {
|
|||||||
|
|
||||||
private JSlider zoomSlider;
|
private JSlider zoomSlider;
|
||||||
|
|
||||||
ScreenViewer(Workspace workspace, Device device, int spacing) {
|
ScreenViewer(Workspace workspace, IDevice device, int spacing) {
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class ScreenViewer extends JPanel implements ActionListener {
|
|||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -463,7 +463,7 @@ class ScreenViewer extends JPanel implements ActionListener {
|
|||||||
g.fillRect(0, 0, getWidth(), getHeight());
|
g.fillRect(0, 0, getWidth(), getHeight());
|
||||||
|
|
||||||
g.setColor(Color.WHITE);
|
g.setColor(Color.WHITE);
|
||||||
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.hierarchyviewer.ui;
|
package com.android.hierarchyviewer.ui;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.hierarchyviewer.device.DeviceBridge;
|
import com.android.hierarchyviewer.device.DeviceBridge;
|
||||||
import com.android.hierarchyviewer.device.Window;
|
import com.android.hierarchyviewer.device.Window;
|
||||||
import com.android.hierarchyviewer.laf.UnifiedContentBorder;
|
import com.android.hierarchyviewer.laf.UnifiedContentBorder;
|
||||||
@@ -147,7 +147,7 @@ public class Workspace extends JFrame {
|
|||||||
private DevicesTableModel devicesTableModel;
|
private DevicesTableModel devicesTableModel;
|
||||||
private WindowsTableModel windowsTableModel;
|
private WindowsTableModel windowsTableModel;
|
||||||
|
|
||||||
private Device currentDevice;
|
private IDevice currentDevice;
|
||||||
private Window currentWindow = Window.FOCUSED_WINDOW;
|
private Window currentWindow = Window.FOCUSED_WINDOW;
|
||||||
|
|
||||||
private JButton displayNodeButton;
|
private JButton displayNodeButton;
|
||||||
@@ -235,7 +235,7 @@ public class Workspace extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
devicesTableModel = new DevicesTableModel();
|
devicesTableModel = new DevicesTableModel();
|
||||||
for (Device device : DeviceBridge.getDevices()) {
|
for (IDevice device : DeviceBridge.getDevices()) {
|
||||||
DeviceBridge.setupDeviceForward(device);
|
DeviceBridge.setupDeviceForward(device);
|
||||||
devicesTableModel.addDevice(device);
|
devicesTableModel.addDevice(device);
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ public class Workspace extends JFrame {
|
|||||||
|
|
||||||
setVisibleRowCount(profilingTable, 5);
|
setVisibleRowCount(profilingTable, 5);
|
||||||
firstTableScroller.setMinimumSize(profilingTable.getPreferredScrollableViewportSize());
|
firstTableScroller.setMinimumSize(profilingTable.getPreferredScrollableViewportSize());
|
||||||
|
|
||||||
JSplitPane tablesSplitter = new JSplitPane();
|
JSplitPane tablesSplitter = new JSplitPane();
|
||||||
tablesSplitter.setBorder(null);
|
tablesSplitter.setBorder(null);
|
||||||
tablesSplitter.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
tablesSplitter.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
||||||
@@ -522,7 +522,7 @@ public class Workspace extends JFrame {
|
|||||||
showDevicesMenuItem.setEnabled(false);
|
showDevicesMenuItem.setEnabled(false);
|
||||||
viewMenu.add(showDevicesMenuItem);
|
viewMenu.add(showDevicesMenuItem);
|
||||||
|
|
||||||
menuBar.add(viewMenu);
|
menuBar.add(viewMenu);
|
||||||
|
|
||||||
viewHierarchyMenu.setText("Hierarchy");
|
viewHierarchyMenu.setText("Hierarchy");
|
||||||
|
|
||||||
@@ -855,7 +855,7 @@ public class Workspace extends JFrame {
|
|||||||
public void showDevicesSelector() {
|
public void showDevicesSelector() {
|
||||||
if (mainSplitter != null) {
|
if (mainSplitter != null) {
|
||||||
if (pixelPerfectPanel != null) {
|
if (pixelPerfectPanel != null) {
|
||||||
screenViewer.start();
|
screenViewer.start();
|
||||||
}
|
}
|
||||||
mainPanel.remove(graphViewButton.isSelected() ? mainSplitter : pixelPerfectPanel);
|
mainPanel.remove(graphViewButton.isSelected() ? mainSplitter : pixelPerfectPanel);
|
||||||
mainPanel.add(deviceSelector, BorderLayout.CENTER);
|
mainPanel.add(deviceSelector, BorderLayout.CENTER);
|
||||||
@@ -864,7 +864,7 @@ public class Workspace extends JFrame {
|
|||||||
|
|
||||||
hideStatusBarComponents();
|
hideStatusBarComponents();
|
||||||
|
|
||||||
saveMenuItem.setEnabled(false);
|
saveMenuItem.setEnabled(false);
|
||||||
showDevicesMenuItem.setEnabled(false);
|
showDevicesMenuItem.setEnabled(false);
|
||||||
showDevicesButton.setEnabled(false);
|
showDevicesButton.setEnabled(false);
|
||||||
displayNodeButton.setEnabled(false);
|
displayNodeButton.setEnabled(false);
|
||||||
@@ -926,7 +926,7 @@ public class Workspace extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cleanupDevices() {
|
public void cleanupDevices() {
|
||||||
for (Device device : devicesTableModel.getDevices()) {
|
for (IDevice device : devicesTableModel.getDevices()) {
|
||||||
DeviceBridge.removeDeviceForward(device);
|
DeviceBridge.removeDeviceForward(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -989,7 +989,7 @@ public class Workspace extends JFrame {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new CaptureNodeTask();
|
return new CaptureNodeTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SwingWorker<?, ?> startServer() {
|
public SwingWorker<?, ?> startServer() {
|
||||||
return new StartServerTask();
|
return new StartServerTask();
|
||||||
@@ -1232,7 +1232,7 @@ public class Workspace extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
endTask();
|
endTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1293,10 +1293,10 @@ public class Workspace extends JFrame {
|
|||||||
private class DevicesTableModel extends DefaultTableModel implements
|
private class DevicesTableModel extends DefaultTableModel implements
|
||||||
AndroidDebugBridge.IDeviceChangeListener {
|
AndroidDebugBridge.IDeviceChangeListener {
|
||||||
|
|
||||||
private ArrayList<Device> devices;
|
private ArrayList<IDevice> devices;
|
||||||
|
|
||||||
private DevicesTableModel() {
|
private DevicesTableModel() {
|
||||||
devices = new ArrayList<Device>();
|
devices = new ArrayList<IDevice>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1320,7 +1320,7 @@ public class Workspace extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public void deviceConnected(final Device device) {
|
public void deviceConnected(final IDevice device) {
|
||||||
DeviceBridge.setupDeviceForward(device);
|
DeviceBridge.setupDeviceForward(device);
|
||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@@ -1331,7 +1331,7 @@ public class Workspace extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public void deviceDisconnected(final Device device) {
|
public void deviceDisconnected(final IDevice device) {
|
||||||
DeviceBridge.removeDeviceForward(device);
|
DeviceBridge.removeDeviceForward(device);
|
||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@@ -1341,14 +1341,14 @@ public class Workspace extends JFrame {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDevice(Device device) {
|
public void addDevice(IDevice device) {
|
||||||
if (!devices.contains(device)) {
|
if (!devices.contains(device)) {
|
||||||
devices.add(device);
|
devices.add(device);
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDevice(Device device) {
|
public void removeDevice(IDevice device) {
|
||||||
if (device.equals(currentDevice)) {
|
if (device.equals(currentDevice)) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@@ -1360,12 +1360,12 @@ public class Workspace extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public void deviceChanged(Device device, int changeMask) {
|
public void deviceChanged(IDevice device, int changeMask) {
|
||||||
if ((changeMask & Device.CHANGE_STATE) != 0 &&
|
if ((changeMask & IDevice.CHANGE_STATE) != 0 &&
|
||||||
device.isOnline()) {
|
device.isOnline()) {
|
||||||
// if the device state changed and it's now online, we set up its port forwarding.
|
// if the device state changed and it's now online, we set up its port forwarding.
|
||||||
DeviceBridge.setupDeviceForward(device);
|
DeviceBridge.setupDeviceForward(device);
|
||||||
} else if (device == currentDevice && (changeMask & Device.CHANGE_CLIENT_LIST) != 0) {
|
} else if (device == currentDevice && (changeMask & IDevice.CHANGE_CLIENT_LIST) != 0) {
|
||||||
// if the changed device is the current one and the client list changed, we update
|
// if the changed device is the current one and the client list changed, we update
|
||||||
// the UI.
|
// the UI.
|
||||||
loadWindows().execute();
|
loadWindows().execute();
|
||||||
@@ -1378,12 +1378,12 @@ public class Workspace extends JFrame {
|
|||||||
return devices == null ? 0 : devices.size();
|
return devices == null ? 0 : devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Device getDevice(int index) {
|
public IDevice getDevice(int index) {
|
||||||
return index < devices.size() ? devices.get(index) : null;
|
return index < devices.size() ? devices.get(index) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Device[] getDevices() {
|
public IDevice[] getDevices() {
|
||||||
return devices.toArray(new Device[devices.size()]);
|
return devices.toArray(new IDevice[devices.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1441,7 +1441,7 @@ public class Workspace extends JFrame {
|
|||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
windows.clear();
|
windows.clear();
|
||||||
windows.add(Window.FOCUSED_WINDOW);
|
windows.add(Window.FOCUSED_WINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window getWindow(int index) {
|
public Window getWindow(int index) {
|
||||||
@@ -1462,7 +1462,7 @@ public class Workspace extends JFrame {
|
|||||||
if (currentDevice != null) {
|
if (currentDevice != null) {
|
||||||
if (!DeviceBridge.isViewServerRunning(currentDevice)) {
|
if (!DeviceBridge.isViewServerRunning(currentDevice)) {
|
||||||
DeviceBridge.startViewServer(currentDevice);
|
DeviceBridge.startViewServer(currentDevice);
|
||||||
checkForServerOnCurrentDevice();
|
checkForServerOnCurrentDevice();
|
||||||
}
|
}
|
||||||
loadWindows().execute();
|
loadWindows().execute();
|
||||||
windowsTableModel.setVisible(true);
|
windowsTableModel.setVisible(true);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.screenshot;
|
package com.android.screenshot;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Device;
|
import com.android.ddmlib.IDevice;
|
||||||
import com.android.ddmlib.Log;
|
import com.android.ddmlib.Log;
|
||||||
import com.android.ddmlib.RawImage;
|
import com.android.ddmlib.RawImage;
|
||||||
import com.android.ddmlib.Log.ILogOutput;
|
import com.android.ddmlib.Log.ILogOutput;
|
||||||
@@ -30,7 +30,7 @@ import java.io.IOException;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a device using ddmlib and dumps its event log as long as the device is connected.
|
* Connects to a device using ddmlib and dumps its event log as long as the device is connected.
|
||||||
*/
|
*/
|
||||||
public class Screenshot {
|
public class Screenshot {
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ public class Screenshot {
|
|||||||
String serial = null;
|
String serial = null;
|
||||||
String filepath = null;
|
String filepath = null;
|
||||||
boolean landscape = false;
|
boolean landscape = false;
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
printUsageAndQuit();
|
printUsageAndQuit();
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class Screenshot {
|
|||||||
if (device || emulator) {
|
if (device || emulator) {
|
||||||
printAndExit("-s conflicts with -d and -e", false /* terminate */);
|
printAndExit("-s conflicts with -d and -e", false /* terminate */);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial = args[index++];
|
serial = args[index++];
|
||||||
} else if ("-l".equals(argument)) {
|
} else if ("-l".equals(argument)) {
|
||||||
landscape = true;
|
landscape = true;
|
||||||
@@ -83,11 +83,11 @@ public class Screenshot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (index < args.length);
|
} while (index < args.length);
|
||||||
|
|
||||||
if (filepath == null) {
|
if (filepath == null) {
|
||||||
printUsageAndQuit();
|
printUsageAndQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.setLogOutput(new ILogOutput() {
|
Log.setLogOutput(new ILogOutput() {
|
||||||
public void printAndPromptLog(LogLevel logLevel, String tag, String message) {
|
public void printAndPromptLog(LogLevel logLevel, String tag, String message) {
|
||||||
System.err.println(logLevel.getStringValue() + ":" + tag + ":" + message);
|
System.err.println(logLevel.getStringValue() + ":" + tag + ":" + message);
|
||||||
@@ -97,7 +97,7 @@ public class Screenshot {
|
|||||||
System.err.println(logLevel.getStringValue() + ":" + tag + ":" + message);
|
System.err.println(logLevel.getStringValue() + ":" + tag + ":" + message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// init the lib
|
// init the lib
|
||||||
// [try to] ensure ADB is running
|
// [try to] ensure ADB is running
|
||||||
String adbLocation = System.getProperty("com.android.screenshot.bindir"); //$NON-NLS-1$
|
String adbLocation = System.getProperty("com.android.screenshot.bindir"); //$NON-NLS-1$
|
||||||
@@ -108,11 +108,11 @@ public class Screenshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AndroidDebugBridge.init(false /* debugger support */);
|
AndroidDebugBridge.init(false /* debugger support */);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(
|
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(
|
||||||
adbLocation, true /* forceNewBridge */);
|
adbLocation, true /* forceNewBridge */);
|
||||||
|
|
||||||
// we can't just ask for the device list right away, as the internal thread getting
|
// we can't just ask for the device list right away, as the internal thread getting
|
||||||
// them from ADB may not be done getting the first list.
|
// them from ADB may not be done getting the first list.
|
||||||
// Since we don't really want getDevices() to be blocking, we wait here manually.
|
// Since we don't really want getDevices() to be blocking, we wait here manually.
|
||||||
@@ -124,7 +124,7 @@ public class Screenshot {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's not wait > 10 sec.
|
// let's not wait > 10 sec.
|
||||||
if (count > 100) {
|
if (count > 100) {
|
||||||
System.err.println("Timeout getting device list!");
|
System.err.println("Timeout getting device list!");
|
||||||
@@ -133,16 +133,16 @@ public class Screenshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now get the devices
|
// now get the devices
|
||||||
Device[] devices = bridge.getDevices();
|
IDevice[] devices = bridge.getDevices();
|
||||||
|
|
||||||
if (devices.length == 0) {
|
if (devices.length == 0) {
|
||||||
printAndExit("No devices found!", true /* terminate */);
|
printAndExit("No devices found!", true /* terminate */);
|
||||||
}
|
}
|
||||||
|
|
||||||
Device target = null;
|
IDevice target = null;
|
||||||
|
|
||||||
if (emulator || device) {
|
if (emulator || device) {
|
||||||
for (Device d : devices) {
|
for (IDevice d : devices) {
|
||||||
// this test works because emulator and device can't both be true at the same
|
// this test works because emulator and device can't both be true at the same
|
||||||
// time.
|
// time.
|
||||||
if (d.isEmulator() == emulator) {
|
if (d.isEmulator() == emulator) {
|
||||||
@@ -159,7 +159,7 @@ public class Screenshot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (serial != null) {
|
} else if (serial != null) {
|
||||||
for (Device d : devices) {
|
for (IDevice d : devices) {
|
||||||
if (serial.equals(d.getSerialNumber())) {
|
if (serial.equals(d.getSerialNumber())) {
|
||||||
target = d;
|
target = d;
|
||||||
break;
|
break;
|
||||||
@@ -172,7 +172,7 @@ public class Screenshot {
|
|||||||
}
|
}
|
||||||
target = devices[0];
|
target = devices[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
try {
|
try {
|
||||||
System.out.println("Taking screenshot from: " + target.getSerialNumber());
|
System.out.println("Taking screenshot from: " + target.getSerialNumber());
|
||||||
@@ -188,11 +188,11 @@ public class Screenshot {
|
|||||||
AndroidDebugBridge.terminate();
|
AndroidDebugBridge.terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab an image from an ADB-connected device.
|
* Grab an image from an ADB-connected device.
|
||||||
*/
|
*/
|
||||||
private static void getDeviceImage(Device device, String filepath, boolean landscape)
|
private static void getDeviceImage(IDevice device, String filepath, boolean landscape)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
RawImage rawImage;
|
RawImage rawImage;
|
||||||
|
|
||||||
@@ -209,28 +209,28 @@ public class Screenshot {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
assert rawImage.bpp == 16;
|
assert rawImage.bpp == 16;
|
||||||
|
|
||||||
BufferedImage image;
|
BufferedImage image;
|
||||||
|
|
||||||
if (landscape) {
|
if (landscape) {
|
||||||
// convert raw data to an Image
|
// convert raw data to an Image
|
||||||
image = new BufferedImage(rawImage.height, rawImage.width,
|
image = new BufferedImage(rawImage.height, rawImage.width,
|
||||||
BufferedImage.TYPE_INT_ARGB);
|
BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
byte[] buffer = rawImage.data;
|
byte[] buffer = rawImage.data;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int y = 0 ; y < rawImage.height ; y++) {
|
for (int y = 0 ; y < rawImage.height ; y++) {
|
||||||
for (int x = 0 ; x < rawImage.width ; x++) {
|
for (int x = 0 ; x < rawImage.width ; x++) {
|
||||||
|
|
||||||
int value = buffer[index++] & 0x00FF;
|
int value = buffer[index++] & 0x00FF;
|
||||||
value |= (buffer[index++] << 8) & 0x0FF00;
|
value |= (buffer[index++] << 8) & 0x0FF00;
|
||||||
|
|
||||||
int r = ((value >> 11) & 0x01F) << 3;
|
int r = ((value >> 11) & 0x01F) << 3;
|
||||||
int g = ((value >> 5) & 0x03F) << 2;
|
int g = ((value >> 5) & 0x03F) << 2;
|
||||||
int b = ((value >> 0) & 0x01F) << 3;
|
int b = ((value >> 0) & 0x01F) << 3;
|
||||||
|
|
||||||
value = 0xFF << 24 | r << 16 | g << 8 | b;
|
value = 0xFF << 24 | r << 16 | g << 8 | b;
|
||||||
|
|
||||||
image.setRGB(y, rawImage.width - x - 1, value);
|
image.setRGB(y, rawImage.width - x - 1, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,31 +238,31 @@ public class Screenshot {
|
|||||||
// convert raw data to an Image
|
// convert raw data to an Image
|
||||||
image = new BufferedImage(rawImage.width, rawImage.height,
|
image = new BufferedImage(rawImage.width, rawImage.height,
|
||||||
BufferedImage.TYPE_INT_ARGB);
|
BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
byte[] buffer = rawImage.data;
|
byte[] buffer = rawImage.data;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int y = 0 ; y < rawImage.height ; y++) {
|
for (int y = 0 ; y < rawImage.height ; y++) {
|
||||||
for (int x = 0 ; x < rawImage.width ; x++) {
|
for (int x = 0 ; x < rawImage.width ; x++) {
|
||||||
|
|
||||||
int value = buffer[index++] & 0x00FF;
|
int value = buffer[index++] & 0x00FF;
|
||||||
value |= (buffer[index++] << 8) & 0x0FF00;
|
value |= (buffer[index++] << 8) & 0x0FF00;
|
||||||
|
|
||||||
int r = ((value >> 11) & 0x01F) << 3;
|
int r = ((value >> 11) & 0x01F) << 3;
|
||||||
int g = ((value >> 5) & 0x03F) << 2;
|
int g = ((value >> 5) & 0x03F) << 2;
|
||||||
int b = ((value >> 0) & 0x01F) << 3;
|
int b = ((value >> 0) & 0x01F) << 3;
|
||||||
|
|
||||||
value = 0xFF << 24 | r << 16 | g << 8 | b;
|
value = 0xFF << 24 | r << 16 | g << 8 | b;
|
||||||
|
|
||||||
image.setRGB(x, y, value);
|
image.setRGB(x, y, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ImageIO.write(image, "png", new File(filepath))) {
|
if (!ImageIO.write(image, "png", new File(filepath))) {
|
||||||
throw new IOException("Failed to find png writer");
|
throw new IOException("Failed to find png writer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printUsageAndQuit() {
|
private static void printUsageAndQuit() {
|
||||||
// 80 cols marker: 01234567890123456789012345678901234567890123456789012345678901234567890123456789
|
// 80 cols marker: 01234567890123456789012345678901234567890123456789012345678901234567890123456789
|
||||||
System.out.println("Usage: screenshot2 [-d | -e | -s SERIAL] [-l] OUT_FILE");
|
System.out.println("Usage: screenshot2 [-d | -e | -s SERIAL] [-l] OUT_FILE");
|
||||||
@@ -273,10 +273,10 @@ public class Screenshot {
|
|||||||
System.out.println("");
|
System.out.println("");
|
||||||
System.out.println(" -l Rotate images for landscape mode.");
|
System.out.println(" -l Rotate images for landscape mode.");
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
|
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printAndExit(String message, boolean terminate) {
|
private static void printAndExit(String message, boolean terminate) {
|
||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
if (terminate) {
|
if (terminate) {
|
||||||
|
|||||||
Reference in New Issue
Block a user