Search in sources :

Example 11 with AndroidDebugBridge

use of com.android.ddmlib.AndroidDebugBridge in project android by JetBrains.

the class GetAdbAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Notifications.Bus.notify(new Notification("Android", "ADB", "ADB requested.", NotificationType.INFORMATION));
    Project project = getEventProject(e);
    File adb = project == null ? null : AndroidSdkUtils.getAdb(project);
    if (adb == null) {
        return;
    }
    ListenableFuture<AndroidDebugBridge> bridge = AdbService.getInstance().getDebugBridge(adb);
    Futures.addCallback(bridge, new FutureCallback<AndroidDebugBridge>() {

        @Override
        public void onSuccess(AndroidDebugBridge result) {
            Notifications.Bus.notify(new Notification("Android", "ADB", "ADB obtained", NotificationType.INFORMATION));
        }

        @Override
        public void onFailure(Throwable t) {
            Notifications.Bus.notify(new Notification("Android", "ADB", "ADB error: " + t.toString(), NotificationType.INFORMATION));
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) File(java.io.File) Notification(com.intellij.notification.Notification) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge)

Example 12 with AndroidDebugBridge

use of com.android.ddmlib.AndroidDebugBridge in project android by JetBrains.

the class DeployTargetPickerDialog method createCenterPanel.

@Nullable
@Override
protected JComponent createCenterPanel() {
    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), getDisposable());
    loadingPanel.add(myDeployTargetProvider == null ? myDevicesPanel : myContentPane);
    loadingPanel.setLoadingText("Initializing ADB");
    if (!myAdbFuture.isDone()) {
        loadingPanel.startLoading();
        Futures.addCallback(myAdbFuture, new FutureCallback<AndroidDebugBridge>() {

            @Override
            public void onSuccess(AndroidDebugBridge result) {
                loadingPanel.stopLoading();
                Logger.getInstance(DeployTargetPickerDialog.class).info("Successfully obtained debug bridge");
            }

            @Override
            public void onFailure(Throwable t) {
                loadingPanel.stopLoading();
                Logger.getInstance(DeployTargetPickerDialog.class).info("Unable to obtain debug bridge", t);
            // TODO: show an inline banner to restart adb?
            }
        }, EdtExecutor.INSTANCE);
    }
    return loadingPanel;
}
Also used : JBLoadingPanel(com.intellij.ui.components.JBLoadingPanel) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with AndroidDebugBridge

use of com.android.ddmlib.AndroidDebugBridge in project android by JetBrains.

the class DevicePicker method updateModel.

private void updateModel() {
    AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
    if (bridge == null || !bridge.isConnected()) {
        return;
    }
    if (!ApplicationManager.getApplication().isDispatchThread()) {
        UIUtil.invokeLaterIfNeeded(this::updateModel);
        return;
    }
    if (myDevicesList == null) {
        // happens if this was scheduled post disposal of the dialog
        return;
    }
    Set<String> selectedSerials = getSelectedSerials(myDevicesList.getSelectedValues());
    List<IDevice> connectedDevices = Lists.newArrayList(bridge.getDevices());
    myModel.reset(connectedDevices, myAvdInfos);
    myDeviceCount = connectedDevices.size();
    if (selectedSerials.isEmpty()) {
        selectedSerials = getDefaultSelection();
    }
    myDevicesList.setSelectedIndices(getIndices(myModel.getItems(), selectedSerials));
    // The help hyper link is shown only when there is no inline troubleshoot link
    myHelpHyperlink.setVisible(!connectedDevices.isEmpty());
    updateErrorCheck();
}
Also used : IDevice(com.android.ddmlib.IDevice) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge)

Example 14 with AndroidDebugBridge

use of com.android.ddmlib.AndroidDebugBridge in project android by JetBrains.

the class AvdComboBox method doUpdateAvds.

private void doUpdateAvds() {
    final Module module = getModule();
    if (module == null || module.isDisposed()) {
        return;
    }
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    final IdDisplay[] newAvds;
    if (facet != null) {
        final Set<String> filteringSet = new HashSet<String>();
        if (myShowNotLaunchedOnly) {
            final AndroidDebugBridge debugBridge = AndroidSdkUtils.getDebugBridge(facet.getModule().getProject());
            if (debugBridge != null) {
                for (IDevice device : debugBridge.getDevices()) {
                    final String avdName = device.getAvdName();
                    if (avdName != null && avdName.length() > 0) {
                        filteringSet.add(avdName);
                    }
                }
            }
        }
        final List<IdDisplay> newAvdList = new ArrayList<IdDisplay>();
        if (myAddEmptyElement) {
            newAvdList.add(IdDisplay.create("", ""));
        }
        for (AvdInfo avd : facet.getAllAvds()) {
            String displayName = avd.getProperties().get(AvdManager.AVD_INI_DISPLAY_NAME);
            final String avdName = displayName == null || displayName.isEmpty() ? avd.getName() : displayName;
            if (!filteringSet.contains(avdName)) {
                newAvdList.add(IdDisplay.create(avd.getName(), avdName));
            }
        }
        newAvds = ArrayUtil.toObjectArray(newAvdList, IdDisplay.class);
    } else {
        newAvds = new IdDisplay[0];
    }
    if (!Arrays.equals(myOldAvds, newAvds)) {
        myOldAvds = newAvds;
        final Object selected = getComboBox().getSelectedItem();
        getComboBox().setModel(new DefaultComboBoxModel(newAvds));
        getComboBox().setSelectedItem(selected);
    }
}
Also used : ArrayList(java.util.ArrayList) IDevice(com.android.ddmlib.IDevice) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) IdDisplay(com.android.sdklib.repository.IdDisplay) Module(com.intellij.openapi.module.Module) HashSet(com.intellij.util.containers.HashSet) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge)

Example 15 with AndroidDebugBridge

use of com.android.ddmlib.AndroidDebugBridge in project buck by facebook.

the class InstrumentationTestRunner method getDevice.

@Nullable
private IDevice getDevice(String serial) throws InterruptedException {
    AndroidDebugBridge adb = createAdb();
    if (adb == null) {
        System.err.println("Unable to set up adb.");
        System.exit(1);
    }
    IDevice[] allDevices = adb.getDevices();
    for (IDevice device : allDevices) {
        if (device.getSerialNumber().equals(serial)) {
            return device;
        }
    }
    return null;
}
Also used : IDevice(com.android.ddmlib.IDevice) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge)

Aggregations

AndroidDebugBridge (com.android.ddmlib.AndroidDebugBridge)23 IDevice (com.android.ddmlib.IDevice)11 NotNull (org.jetbrains.annotations.NotNull)4 File (java.io.File)3 Client (com.android.ddmlib.Client)2 Project (com.intellij.openapi.project.Project)2 JBLoadingPanel (com.intellij.ui.components.JBLoadingPanel)2 TIntArrayList (gnu.trove.TIntArrayList)2 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)1 IdDisplay (com.android.sdklib.repository.IdDisplay)1 DeviceContext (com.android.tools.idea.ddms.DeviceContext)1 DevicePanel (com.android.tools.idea.ddms.DevicePanel)1 OpenVmTraceHandler (com.android.tools.idea.ddms.OpenVmTraceHandler)1 AndroidLogcatView (com.android.tools.idea.logcat.AndroidLogcatView)1 SuppressForbidden (com.facebook.buck.annotations.SuppressForbidden)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)1