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
@@ -19,7 +19,6 @@ package com.android.ide.eclipse.adt.internal.launch;
|
||||
import com.android.ddmlib.AndroidDebugBridge;
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.ClientData;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.Log;
|
||||
import com.android.ddmlib.MultiLineReceiver;
|
||||
@@ -1381,9 +1380,9 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
||||
* @see IDeviceChangeListener#deviceConnected(IDevice)
|
||||
*/
|
||||
public void deviceConnected(Device device) {
|
||||
public void deviceConnected(IDevice device) {
|
||||
synchronized (sListLock) {
|
||||
// look if there's an app waiting for a device
|
||||
if (mWaitingForEmulatorLaunches.size() > 0) {
|
||||
@@ -1415,10 +1414,10 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
||||
* @see IDeviceChangeListener#deviceDisconnected(IDevice)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void deviceDisconnected(Device device) {
|
||||
public void deviceDisconnected(IDevice device) {
|
||||
// any pending launch on this device must be canceled.
|
||||
String message = "%1$s disconnected! Cancelling '%2$s'!";
|
||||
synchronized (sListLock) {
|
||||
@@ -1451,9 +1450,9 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* @param device the device that was updated.
|
||||
* @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
|
||||
// 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.Client;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
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.ImageHelper;
|
||||
import com.android.ddmuilib.TableHelper;
|
||||
@@ -99,7 +98,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
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}.
|
||||
*/
|
||||
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}.
|
||||
* It provides labels and images for {@link Device} objects.
|
||||
* It provides labels and images for {@link IDevice} objects.
|
||||
*/
|
||||
private class LabelProvider implements ITableLabelProvider {
|
||||
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
if (element instanceof Device) {
|
||||
Device device = (Device)element;
|
||||
if (element instanceof IDevice) {
|
||||
IDevice device = (IDevice)element;
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return device.isEmulator() ? mEmulatorImage : mDeviceImage;
|
||||
@@ -175,8 +174,8 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
}
|
||||
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (element instanceof Device) {
|
||||
Device device = (Device)element;
|
||||
if (element instanceof IDevice) {
|
||||
IDevice device = (IDevice)element;
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return device.getSerialNumber();
|
||||
@@ -514,7 +513,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
* Returns a display string representing the state of the device.
|
||||
* @param d the device
|
||||
*/
|
||||
private static String getStateString(Device d) {
|
||||
private static String getStateString(IDevice d) {
|
||||
DeviceState deviceState = d.getState();
|
||||
if (deviceState == DeviceState.ONLINE) {
|
||||
return "Online";
|
||||
@@ -533,9 +532,9 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
||||
* @see IDeviceChangeListener#deviceConnected(IDevice)
|
||||
*/
|
||||
public void deviceConnected(Device device) {
|
||||
public void deviceConnected(IDevice device) {
|
||||
final DeviceChooserDialog dialog = this;
|
||||
exec(new Runnable() {
|
||||
public void run() {
|
||||
@@ -565,9 +564,9 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
||||
* @see IDeviceChangeListener#deviceDisconnected(IDevice)
|
||||
*/
|
||||
public void deviceDisconnected(Device device) {
|
||||
public void deviceDisconnected(IDevice device) {
|
||||
deviceConnected(device);
|
||||
}
|
||||
|
||||
@@ -578,10 +577,10 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
* @param device the device that was updated.
|
||||
* @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) {
|
||||
if ((changeMask & (Device.CHANGE_STATE | Device.CHANGE_BUILD_INFO)) != 0) {
|
||||
public void deviceChanged(final IDevice device, int changeMask) {
|
||||
if ((changeMask & (IDevice.CHANGE_STATE | IDevice.CHANGE_BUILD_INFO)) != 0) {
|
||||
final DeviceChooserDialog dialog = this;
|
||||
exec(new Runnable() {
|
||||
public void run() {
|
||||
@@ -663,15 +662,15 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
} else {
|
||||
int index = mDeviceTable.getSelectionIndex();
|
||||
Object data = mViewer.getElementAt(index);
|
||||
if (data instanceof Device) {
|
||||
handleSelection((Device)data);
|
||||
if (data instanceof IDevice) {
|
||||
handleSelection((IDevice)data);
|
||||
} else {
|
||||
handleSelection(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSelection(Device device) {
|
||||
private void handleSelection(IDevice device) {
|
||||
mResponse.setDeviceToUse(device);
|
||||
enableOkButton();
|
||||
}
|
||||
@@ -686,9 +685,9 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
if (mDeviceTable.getSelectionCount() == 0) {
|
||||
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
|
||||
|
||||
Device[] devices = bridge.getDevices();
|
||||
IDevice[] devices = bridge.getDevices();
|
||||
|
||||
for (Device device : devices) {
|
||||
for (IDevice device : devices) {
|
||||
Client[] clients = device.getClients();
|
||||
|
||||
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.
|
||||
if (mFullAvdList != null) {
|
||||
Device[] devices = AndroidDebugBridge.getBridge().getDevices();
|
||||
IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();
|
||||
avdLoop: for (AvdInfo info : mFullAvdList) {
|
||||
for (Device d : devices) {
|
||||
for (IDevice d : devices) {
|
||||
if (info.getName().equals(d.getAvdName())) {
|
||||
continue avdLoop;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.ide.eclipse.adt.internal.project;
|
||||
|
||||
import com.android.ddmlib.AndroidDebugBridge;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
|
||||
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).
|
||||
* <p/>
|
||||
* 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/>
|
||||
* This is a singleton. To get the instance, use {@link #getInstance()}
|
||||
*/
|
||||
public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeChangeListener,
|
||||
IProjectListener {
|
||||
|
||||
|
||||
private final static ApkInstallManager sThis = new ApkInstallManager();
|
||||
|
||||
|
||||
/**
|
||||
* Internal struct to associate a project and a device.
|
||||
*/
|
||||
@@ -60,13 +59,13 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
||||
IProject project;
|
||||
IDevice device;
|
||||
}
|
||||
|
||||
|
||||
private final ArrayList<ApkInstall> mInstallList = new ArrayList<ApkInstall>();
|
||||
|
||||
|
||||
public static ApkInstallManager getInstance() {
|
||||
return sThis;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers an installation of <var>project</var> onto <var>device</var>
|
||||
* @param project The project that was installed.
|
||||
@@ -77,7 +76,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
||||
mInstallList.add(new ApkInstall(project, device));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a <var>project</var> was installed on the <var>device</var>.
|
||||
* @param project the project that may have been installed.
|
||||
@@ -113,7 +112,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ApkInstallManager() {
|
||||
AndroidDebugBridge.addDeviceChangeListener(this);
|
||||
AndroidDebugBridge.addDebugBridgeChangeListener(this);
|
||||
@@ -138,7 +137,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
||||
* (non-Javadoc)
|
||||
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceDisconnected(com.android.ddmlib.Device)
|
||||
*/
|
||||
public void deviceDisconnected(Device device) {
|
||||
public void deviceDisconnected(IDevice device) {
|
||||
synchronized (mInstallList) {
|
||||
for (int i = 0 ; i < mInstallList.size() ;) {
|
||||
ApkInstall install = mInstallList.get(i);
|
||||
@@ -174,7 +173,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
||||
* (non-Javadoc)
|
||||
* @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.
|
||||
}
|
||||
|
||||
@@ -183,7 +182,7 @@ public class ApkInstallManager implements IDeviceChangeListener, IDebugBridgeCha
|
||||
* (non-Javadoc)
|
||||
* @see com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener#deviceConnected(com.android.ddmlib.Device)
|
||||
*/
|
||||
public void deviceConnected(Device device) {
|
||||
public void deviceConnected(IDevice device) {
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.android.ide.eclipse.ddms;
|
||||
import com.android.ddmlib.AndroidDebugBridge;
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.DdmPreferences;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.Log;
|
||||
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
||||
import com.android.ddmlib.Log.ILogOutput;
|
||||
@@ -76,11 +76,11 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
|
||||
/** Image loader object */
|
||||
private ImageLoader mLoader;
|
||||
|
||||
private Device mCurrentDevice;
|
||||
|
||||
private IDevice mCurrentDevice;
|
||||
private Client mCurrentClient;
|
||||
private boolean mListeningToUiSelection = false;
|
||||
|
||||
|
||||
private final ArrayList<ISelectionListener> mListeners = new ArrayList<ISelectionListener>();
|
||||
|
||||
private Color mRed;
|
||||
@@ -93,24 +93,24 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
public interface IDebugLauncher {
|
||||
public boolean debug(String packageName, int port);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
|
||||
/**
|
||||
* Sent when a new {@link Client} is selected.
|
||||
* @param selectedClient The selected client. If null, no clients are selected.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public void selectionChanged(Device selectedDevice);
|
||||
public void selectionChanged(IDevice selectedDevice);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,14 +128,14 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
|
||||
|
||||
final Display display = getDisplay();
|
||||
|
||||
// get the eclipse store
|
||||
final IPreferenceStore eclipseStore = getPreferenceStore();
|
||||
|
||||
AndroidDebugBridge.addDeviceChangeListener(this);
|
||||
|
||||
|
||||
DdmUiPreferences.setStore(eclipseStore);
|
||||
|
||||
//DdmUiPreferences.displayCharts();
|
||||
@@ -186,12 +186,12 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// create the loader that's able to load the images
|
||||
mLoader = new ImageLoader(this);
|
||||
|
||||
|
||||
// set the listener for the preference change
|
||||
Preferences prefs = getPluginPreferences();
|
||||
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
|
||||
// having to wait for ADT to start
|
||||
sAdbLocation = eclipseStore.getString(ADB_LOCATION);
|
||||
@@ -248,9 +248,9 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
AndroidDebugBridge.removeDeviceChangeListener(this);
|
||||
|
||||
|
||||
AndroidDebugBridge.terminate();
|
||||
|
||||
|
||||
mRed.dispose();
|
||||
|
||||
sPlugin = null;
|
||||
@@ -303,15 +303,15 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized void initDdmlib() {
|
||||
if (mDdmlibInitialized == false) {
|
||||
// set the preferences.
|
||||
PreferenceInitializer.setupPreferences();
|
||||
|
||||
|
||||
// init the lib
|
||||
AndroidDebugBridge.init(true /* debugger support */);
|
||||
|
||||
|
||||
mDdmlibInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -342,10 +342,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
public static IDebugLauncher getRunningAppDebugLauncher() {
|
||||
return sRunningAppDebugLauncher;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addSelectionListener(ISelectionListener listener) {
|
||||
mListeners.add(listener);
|
||||
|
||||
|
||||
// notify the new listener of the current selection
|
||||
listener.selectionChanged(mCurrentDevice);
|
||||
listener.selectionChanged(mCurrentClient);
|
||||
@@ -364,10 +364,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
* <p/>
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceConnected(IDevice)
|
||||
*/
|
||||
public void deviceConnected(Device device) {
|
||||
public void deviceConnected(IDevice device) {
|
||||
// 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
|
||||
// selection notification through our implementation of IUiSelectionListener.
|
||||
@@ -383,10 +383,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
* <p/>
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceDisconnected(IDevice)
|
||||
*/
|
||||
public void deviceDisconnected(Device device) {
|
||||
public void deviceDisconnected(IDevice device) {
|
||||
// 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
|
||||
// selection notification through our implementation of IUiSelectionListener.
|
||||
@@ -397,16 +397,16 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
|
||||
if (bridge != null) {
|
||||
// get the device list
|
||||
Device[] devices = bridge.getDevices();
|
||||
|
||||
IDevice[] devices = bridge.getDevices();
|
||||
|
||||
// check if we still have devices
|
||||
if (devices.length == 0) {
|
||||
handleDefaultSelection((Device)null);
|
||||
handleDefaultSelection((IDevice)null);
|
||||
} else {
|
||||
handleDefaultSelection(devices[0]);
|
||||
}
|
||||
} 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.
|
||||
* @param device the device that was updated.
|
||||
* @param changeMask the mask indicating what changed.
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceChanged(Device)
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceChanged(IDevice)
|
||||
*/
|
||||
public void deviceChanged(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
|
||||
// any change in the devices/clients, will be handled by the UI, and we'll receive
|
||||
// selection notification through our implementation of IUiSelectionListener.
|
||||
if (mListeningToUiSelection == false) {
|
||||
|
||||
|
||||
// check if this is our device
|
||||
if (device == mCurrentDevice) {
|
||||
if (mCurrentClient == null) {
|
||||
@@ -441,7 +441,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if we haven't found our client, lets look for a new one
|
||||
if (foundClient == false) {
|
||||
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 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) {
|
||||
mCurrentDevice = selectedDevice;
|
||||
|
||||
@@ -469,7 +469,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
|
||||
if (mCurrentClient != selectedClient) {
|
||||
mCurrentClient = selectedClient;
|
||||
|
||||
|
||||
// notify of the new default client
|
||||
for (ISelectionListener listener : mListeners) {
|
||||
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
|
||||
*/
|
||||
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
|
||||
// from the AndroidDebugBridge notifications, we need to run this in the UI thread.
|
||||
try {
|
||||
Display display = getDisplay();
|
||||
|
||||
|
||||
display.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
// set the new device if different.
|
||||
@@ -494,13 +494,13 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
if (mCurrentDevice != device) {
|
||||
mCurrentDevice = device;
|
||||
newDevice = true;
|
||||
|
||||
|
||||
// notify of the new default device
|
||||
for (ISelectionListener listener : mListeners) {
|
||||
listener.selectionChanged(mCurrentDevice);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (device != null) {
|
||||
// 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.
|
||||
@@ -522,16 +522,16 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
// display is disposed. Do nothing since we're quitting anyway.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handleDefaultSelection(Client client) {
|
||||
mCurrentClient = client;
|
||||
|
||||
|
||||
// notify of the new default client
|
||||
for (ISelectionListener listener : mListeners) {
|
||||
listener.selectionChanged(mCurrentClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a message, associated with a project to the specified stream
|
||||
* @param stream The stream to write to
|
||||
@@ -545,7 +545,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
|
||||
stream.print(dateTag);
|
||||
stream.println(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a string containing the current date/time, and the tag
|
||||
* @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.ClientData;
|
||||
import com.android.ddmlib.AndroidDebugBridge;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmuilib.DevicePanel;
|
||||
import com.android.ddmuilib.ScreenShotDialog;
|
||||
import com.android.ddmuilib.DevicePanel.IUiSelectionListener;
|
||||
@@ -42,7 +42,7 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
|
||||
public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
|
||||
|
||||
private final static boolean USE_SELECTED_DEBUG_PORT = true;
|
||||
|
||||
public static final String ID =
|
||||
@@ -69,7 +69,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
public static DeviceView getInstance() {
|
||||
return sThis;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the {@link IDebugLauncher}.
|
||||
* @param debugLauncher
|
||||
@@ -89,7 +89,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
mDeviceList = new DevicePanel(DdmsPlugin.getImageLoader(), USE_SELECTED_DEBUG_PORT);
|
||||
mDeviceList.createPanel(parent);
|
||||
mDeviceList.addSelectionListener(this);
|
||||
|
||||
|
||||
DdmsPlugin plugin = DdmsPlugin.getDefault();
|
||||
mDeviceList.addSelectionListener(plugin);
|
||||
plugin.setListeningState(true);
|
||||
@@ -212,7 +212,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
if (packageName != null) {
|
||||
if (mDebugLauncher.debug(packageName,
|
||||
currentClient.getDebuggerListenPort()) == false) {
|
||||
|
||||
|
||||
// if we get to this point, then we failed to find a project
|
||||
// that matched the application to debug
|
||||
Display display = DdmsPlugin.getDisplay();
|
||||
@@ -233,7 +233,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
if (mDebugLauncher == null) {
|
||||
mDebugAction.setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
placeActions();
|
||||
}
|
||||
|
||||
@@ -241,13 +241,13 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
public void 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 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
|
||||
doSelectionChanged(selectedClient);
|
||||
doSelectionChanged(selectedDevice);
|
||||
@@ -264,7 +264,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
mDebugAction.setEnabled(mDebugLauncher != null);
|
||||
mKillAppAction.setEnabled(true);
|
||||
mGcAction.setEnabled(true);
|
||||
|
||||
|
||||
mUpdateHeapAction.setEnabled(true);
|
||||
mUpdateHeapAction.setChecked(selectedClient.isHeapUpdateEnabled());
|
||||
|
||||
@@ -278,7 +278,7 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
bridge.setSelectedClient(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mDebugAction.setEnabled(false);
|
||||
mKillAppAction.setEnabled(false);
|
||||
mGcAction.setEnabled(false);
|
||||
@@ -288,8 +288,8 @@ public class DeviceView extends ViewPart implements IUiSelectionListener {
|
||||
mUpdateThreadAction.setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void doSelectionChanged(Device selectedDevice) {
|
||||
|
||||
private void doSelectionChanged(IDevice selectedDevice) {
|
||||
mCaptureAction.setEnabled(selectedDevice != null);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.ide.eclipse.ddms.views;
|
||||
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.Device;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmuilib.explorer.DeviceExplorer;
|
||||
import com.android.ide.eclipse.ddms.CommonAction;
|
||||
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.IToolBarManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.swt.graphics.Device;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.ISharedImages;
|
||||
@@ -128,7 +129,7 @@ public class FileExplorerView extends ViewPart implements ISelectionListener {
|
||||
toolBarManager.add(pushAction);
|
||||
toolBarManager.add(new Separator());
|
||||
toolBarManager.add(deleteAction);
|
||||
|
||||
|
||||
mExplorer.createPanel(parent);
|
||||
|
||||
DdmsPlugin.getDefault().addSelectionListener(this);
|
||||
@@ -146,20 +147,20 @@ public class FileExplorerView extends ViewPart implements ISelectionListener {
|
||||
public void selectionChanged(Client selectedClient) {
|
||||
// pass
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sent when a new {@link Device} is selected.
|
||||
* @param selectedDevice the selected device.
|
||||
*/
|
||||
public void selectionChanged(Device selectedDevice) {
|
||||
public void selectionChanged(IDevice selectedDevice) {
|
||||
mExplorer.switchDevice(selectedDevice);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sent when there is no current selection.
|
||||
*/
|
||||
public void selectionRemoved() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
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.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;
|
||||
|
||||
/**
|
||||
@@ -29,17 +30,17 @@ import org.eclipse.ui.part.ViewPart;
|
||||
* from {@link DdmsPlugin} through the {@link ISelectionListener} interface.
|
||||
*/
|
||||
public abstract class SelectionDependentViewPart extends ViewPart implements ISelectionListener {
|
||||
|
||||
|
||||
private SelectionDependentPanel mPanel;
|
||||
|
||||
|
||||
protected final void setSelectionDependentPanel(SelectionDependentPanel panel) {
|
||||
// remember the panel
|
||||
mPanel = panel;
|
||||
|
||||
|
||||
// and add ourself as listener of selection events.
|
||||
DdmsPlugin.getDefault().addSelectionListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
DdmsPlugin.getDefault().removeSelectionListener(this);
|
||||
@@ -49,20 +50,20 @@ public abstract class SelectionDependentViewPart extends ViewPart implements ISe
|
||||
/**
|
||||
* Sent when a new {@link Client} is selected.
|
||||
* @param selectedClient The selected client.
|
||||
*
|
||||
*
|
||||
* @see ISelectionListener
|
||||
*/
|
||||
public final void selectionChanged(Client selectedClient) {
|
||||
mPanel.clientSelected(selectedClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sent when a new {@link Device} is selected.
|
||||
* @param selectedDevice the selected device.
|
||||
*
|
||||
* @see ISelectionListener
|
||||
*/
|
||||
public final void selectionChanged(Device selectedDevice) {
|
||||
public final void selectionChanged(IDevice selectedDevice) {
|
||||
mPanel.deviceSelected(selectedDevice);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user