Search in sources :

Example 1 with Client

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());
        }
    });
}
Also used : IDevice(com.android.ddmlib.IDevice) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) Client(com.android.ddmlib.Client)

Example 2 with Client

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();
}
Also used : IDevice(com.android.ddmlib.IDevice) Client(com.android.ddmlib.Client) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge)

Example 3 with Client

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();
    }
}
Also used : Client(com.android.ddmlib.Client)

Example 4 with Client

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();
    }
}
Also used : Client(com.android.ddmlib.Client) DumpData(com.android.preload.DumpData) Date(java.util.Date)

Example 5 with Client

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);
    }
}
Also used : Client(com.android.ddmlib.Client)

Aggregations

Client (com.android.ddmlib.Client)50 IDevice (com.android.ddmlib.IDevice)6 DumpData (com.android.preload.DumpData)5 Date (java.util.Date)5 AndroidDebugBridge (com.android.ddmlib.AndroidDebugBridge)4 ClientData (com.android.ddmlib.ClientData)3 ProcessHandler (com.intellij.execution.process.ProcessHandler)3 IOException (java.io.IOException)3 Project (com.intellij.openapi.project.Project)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 TreePath (javax.swing.tree.TreePath)2 IClientChangeListener (com.android.ddmlib.AndroidDebugBridge.IClientChangeListener)1 NullOutputReceiver (com.android.ddmlib.NullOutputReceiver)1 InstantRunClient (com.android.tools.fd.client.InstantRunClient)1 InstantRunPushFailedException (com.android.tools.fd.client.InstantRunPushFailedException)1 HierarchyViewAction (com.android.tools.idea.ddms.actions.HierarchyViewAction)1 GfxinfoHandler (com.android.tools.idea.monitor.gpu.gfxinfohandlers.GfxinfoHandler)1 AllocationTrackingSample (com.android.tools.idea.monitor.ui.memory.model.AllocationTrackingSample)1 MemoryPoller (com.android.tools.idea.monitor.ui.memory.model.MemoryPoller)1