Make the ddmlib API use IDevice instead of Device
Device is now private. All the API is using IDevice. Updated ddms, ADT, hierarchyviewer and other tools that relied on ddmlib.
This commit is contained in:
@@ -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.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user