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));
}
});
}
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;
}
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();
}
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);
}
}
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;
}
Aggregations