use of com.android.ddmlib.Client in project buck by facebook.
the class AndroidDebugger method attachDebugger.
public static void attachDebugger(final String packageName, final Project project) throws InterruptedException {
IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();
if (devices.length == 0) {
return;
}
IDevice device = devices[0];
Client client;
int currentRetryNumber = 0;
int currentRetryTime = RETRY_TIME;
// It takes some time to get the updated client process list, so wait for it
do {
client = device.getClient(packageName);
currentRetryTime *= 2;
Thread.sleep(currentRetryTime);
currentRetryNumber++;
} while (client == null && currentRetryNumber < MAX_RETRIES);
if (client == null) {
throw new RuntimeException("Connecting to the adb debug server timed out." + "Can't find package with name " + packageName + ".");
}
String debugPort = String.valueOf(client.getDebuggerListenPort());
final RunnerAndConfigurationSettings settings = createRunConfiguration(project, debugPort);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
// Needs read access which is available on the read thread.
ProgramRunnerUtil.executeConfiguration(project, settings, DefaultDebugExecutor.getDebugExecutorInstance());
}
});
}
use of com.android.ddmlib.Client in project otertool by wuntee.
the class Test method main.
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
AndroidDebugBridge.init(true);
AndroidDebugBridge adb = AndroidDebugBridge.createBridge("/Applications/android-sdk-macosx/platform-tools/adb", true);
while (!adb.hasInitialDeviceList()) {
System.out.println("Waiting...");
Thread.sleep(1000);
}
for (IDevice dev : adb.getDevices()) {
System.out.println(dev);
for (Client client : dev.getClients()) {
System.out.println(" -" + client);
}
}
IDevice dev = adb.getDevices()[0];
Client cli = dev.getClients()[0];
AndroidDebugBridge.disconnectBridge();
}
use of com.android.ddmlib.Client in project android_frameworks_base by ResurrectionRemix.
the class ScanPackageAction method run.
@Override
public void run() {
Main.getUI().showWaitDialog();
try {
Client client = Main.getUI().getSelectedClient();
if (client != null) {
work(client);
} else {
Client[] clients = clientUtils.findAllClients(device);
if (clients.length > 0) {
ClientWrapper[] clientWrappers = new ClientWrapper[clients.length];
for (int i = 0; i < clientWrappers.length; i++) {
clientWrappers[i] = new ClientWrapper(clients[i]);
}
Main.getUI().hideWaitDialog();
ClientWrapper ret = Main.getUI().showChoiceDialog("Choose a package to scan", "Choose package", clientWrappers);
if (ret != null) {
work(ret.client);
}
}
}
} finally {
Main.getUI().hideWaitDialog();
}
}
use of com.android.ddmlib.Client in project android_frameworks_base by ResurrectionRemix.
the class ScanAllPackagesAction method run.
@Override
public void run() {
Main.getUI().showWaitDialog();
try {
Client[] clients = clientUtils.findAllClients(device);
for (Client c : clients) {
String pkg = c.getClientData().getClientDescription();
Main.getUI().showWaitDialog();
Main.getUI().updateWaitDialog("Retrieving heap data for " + pkg);
try {
Map<String, String> data = Main.getClassDataRetriever().getClassData(c);
DumpData dumpData = new DumpData(pkg, data, new Date());
dataTableModel.addData(dumpData);
} catch (Exception e) {
e.printStackTrace();
}
}
} finally {
Main.getUI().hideWaitDialog();
}
}
use of com.android.ddmlib.Client in project android_frameworks_base by DirtyUnicorns.
the class ReloadListAction method run.
@Override
public void run() {
Client[] clients = clientUtils.findAllClients(device);
if (clients != null) {
Arrays.sort(clients, new ClientComparator());
}
clientListModel.removeAllElements();
for (Client c : clients) {
clientListModel.addElement(c);
}
}
Aggregations