Search in sources :

Example 1 with AndroidProcessHandler

use of com.android.tools.idea.run.AndroidProcessHandler in project android by JetBrains.

the class AndroidConnectDebuggerAction method terminateRunSessions.

// Disconnect any active run sessions to the same client
private static void terminateRunSessions(@NotNull Project project, @NotNull Client selectedClient) {
    int pid = selectedClient.getClientData().getPid();
    // find if there are any active run sessions to the same client, and terminate them if so
    for (ProcessHandler handler : ExecutionManager.getInstance(project).getRunningProcesses()) {
        if (handler instanceof AndroidProcessHandler) {
            Client client = ((AndroidProcessHandler) handler).getClient(selectedClient.getDevice());
            if (client != null && client.getClientData().getPid() == pid) {
                ((AndroidProcessHandler) handler).setNoKill();
                handler.detachProcess();
                handler.notifyTextAvailable("Disconnecting run session: a new debug session will be established.\n", ProcessOutputTypes.STDOUT);
                break;
            }
        }
    }
}
Also used : AndroidProcessHandler(com.android.tools.idea.run.AndroidProcessHandler) AndroidProcessHandler(com.android.tools.idea.run.AndroidProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) Client(com.android.ddmlib.Client)

Aggregations

Client (com.android.ddmlib.Client)1 AndroidProcessHandler (com.android.tools.idea.run.AndroidProcessHandler)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1