auto import from //branches/cupcake/...@125939
This commit is contained in:
@@ -69,6 +69,9 @@ public final class Device implements IDevice {
|
||||
/** Serial number of the device */
|
||||
String serialNumber = null;
|
||||
|
||||
/** Name of the vm */
|
||||
String mVmName = null;
|
||||
|
||||
/** State of the device. */
|
||||
DeviceState state = null;
|
||||
|
||||
@@ -91,6 +94,11 @@ public final class Device implements IDevice {
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return mVmName;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.android.ddmlib.IDevice#getState()
|
||||
|
||||
@@ -349,7 +349,7 @@ final class DeviceMonitor {
|
||||
}
|
||||
|
||||
if (device.getPropertyCount() == 0) {
|
||||
queryForBuild(device);
|
||||
queryNewDeviceForInfo(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ final class DeviceMonitor {
|
||||
|
||||
// look for their build info.
|
||||
if (newDevice.isOnline()) {
|
||||
queryForBuild(newDevice);
|
||||
queryNewDeviceForInfo(newDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,11 +413,20 @@ final class DeviceMonitor {
|
||||
* Queries a device for its build info.
|
||||
* @param device the device to query.
|
||||
*/
|
||||
private void queryForBuild(Device device) {
|
||||
private void queryNewDeviceForInfo(Device device) {
|
||||
// TODO: do this in a separate thread.
|
||||
try {
|
||||
// first get the list of properties.
|
||||
device.executeShellCommand(GetPropReceiver.GETPROP_COMMAND,
|
||||
new GetPropReceiver(device));
|
||||
|
||||
// now get the emulator VM name (if applicable).
|
||||
if (device.isEmulator()) {
|
||||
EmulatorConsole console = EmulatorConsole.getConsole(device);
|
||||
if (console != null) {
|
||||
device.mVmName = console.getVmName();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// if we can't get the build info, it doesn't matter too much
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public final class EmulatorConsole {
|
||||
private final static String HOST = "127.0.0.1"; //$NON-NLS-1$
|
||||
|
||||
private final static String COMMAND_PING = "help\r\n"; //$NON-NLS-1$
|
||||
private final static String COMMAND_VM_NAME = "vm name\r\n"; //$NON-NLS-1$
|
||||
private final static String COMMAND_KILL = "kill\r\n"; //$NON-NLS-1$
|
||||
private final static String COMMAND_GSM_STATUS = "gsm status\r\n"; //$NON-NLS-1$
|
||||
private final static String COMMAND_GSM_CALL = "gsm call %1$s\r\n"; //$NON-NLS-1$
|
||||
@@ -307,6 +308,24 @@ public final class EmulatorConsole {
|
||||
RemoveConsole(mPort);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized String getVmName() {
|
||||
if (sendCommand(COMMAND_VM_NAME)) {
|
||||
String[] result = readLines();
|
||||
if (result != null && result.length == 2) { // this should be the name on first line,
|
||||
// and ok on 2nd line
|
||||
return result[0];
|
||||
} else {
|
||||
// try to see if there's a message after KO
|
||||
Matcher m = RE_KO.matcher(result[result.length-1]);
|
||||
if (m.matches()) {
|
||||
return m.group(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the network status of the emulator.
|
||||
|
||||
@@ -44,6 +44,15 @@ public interface IDevice {
|
||||
* Returns the serial number of the device.
|
||||
*/
|
||||
public String getSerialNumber();
|
||||
|
||||
/**
|
||||
* Returns the name of the VM the emulator is running.
|
||||
* <p/>This is only valid if {@link #isEmulator()} returns true.
|
||||
* <p/>If the emulator is not running any VM (for instance it's running from an Android source
|
||||
* tree build), this method will return "<code><build></code>".
|
||||
* @return the name of the VM or <code>null</code> if there isn't any.
|
||||
*/
|
||||
public String getVmName();
|
||||
|
||||
/**
|
||||
* Returns the state of the device.
|
||||
|
||||
Reference in New Issue
Block a user