use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class DeployTargetPickerDialog method canLaunchDevices.
/**
* Check the AVDs for missing system images and offer to download them.
* @return true if the devices are able to launch, false if the user cancelled.
*/
private boolean canLaunchDevices(@NotNull List<AndroidDevice> devices) {
Set<String> requiredPackages = Sets.newHashSet();
for (AndroidDevice device : devices) {
if (device instanceof LaunchableAndroidDevice) {
LaunchableAndroidDevice avd = (LaunchableAndroidDevice) device;
AvdInfo info = avd.getAvdInfo();
if (AvdManagerConnection.isSystemImageDownloadProblem(info.getStatus())) {
requiredPackages.add(AvdManagerConnection.getRequiredSystemImagePath(info));
}
}
}
if (requiredPackages.isEmpty()) {
return true;
}
String title;
StringBuilder message = new StringBuilder();
if (requiredPackages.size() == 1) {
title = "Download System Image";
message.append("The system image: ").append(Iterables.getOnlyElement(requiredPackages)).append(" is missing.\n\n");
message.append("Download it now?");
} else {
title = "Download System Images";
message.append("The following system images are missing:\n");
for (String packageName : requiredPackages) {
message.append(packageName).append("\n");
}
message.append("\nDownload them now?");
}
int response = Messages.showOkCancelDialog(message.toString(), title, Messages.getQuestionIcon());
if (response != Messages.OK) {
return false;
}
ModelWizardDialog sdkQuickfixWizard = SdkQuickfixUtils.createDialogForPaths(myFacet.getModule().getProject(), requiredPackages);
if (sdkQuickfixWizard == null) {
return false;
}
sdkQuickfixWizard.show();
myDevicePicker.refreshAvds(null);
if (!sdkQuickfixWizard.isOK()) {
return false;
}
AvdManagerConnection manager = AvdManagerConnection.getDefaultAvdManagerConnection();
for (AndroidDevice device : devices) {
if (device instanceof LaunchableAndroidDevice) {
LaunchableAndroidDevice avd = (LaunchableAndroidDevice) device;
AvdInfo info = avd.getAvdInfo();
String problem;
try {
AvdInfo reloadedAvdInfo = manager.reloadAvd(info);
problem = reloadedAvdInfo.getErrorMessage();
} catch (AndroidLocation.AndroidLocationException e) {
problem = "AVD cannot be loaded";
}
if (problem != null) {
Messages.showErrorDialog(myFacet.getModule().getProject(), problem, "Emulator Launch Failed");
return false;
}
}
}
return true;
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class DevicePicker method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == myCreateEmulatorButton) {
AvdOptionsModel avdOptionsModel = new AvdOptionsModel(null);
ModelWizardDialog dialog = AvdWizardUtils.createAvdWizard(myPanel, myFacet.getModule().getProject(), avdOptionsModel);
if (dialog.showAndGet()) {
AvdInfo createdAvd = avdOptionsModel.getCreatedAvd();
refreshAvds(createdAvd);
}
}
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class AndroidFacet method getValidCompatibleAvds.
@NotNull
public AvdInfo[] getValidCompatibleAvds() {
AvdManager manager = getAvdManagerSilently();
List<AvdInfo> result = Lists.newArrayList();
if (manager != null && reloadAvds(manager)) {
addCompatibleAvds(result, manager.getValidAvds());
}
return result.toArray(new AvdInfo[result.size()]);
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class AvdDisplayList method valueChanged.
/**
* This class implements the table selection interface and passes the selection events on to its listeners.
* @param e
*/
@Override
public void valueChanged(ListSelectionEvent e) {
// Required so the editor component is updated to know it's selected.
myTable.editCellAt(myTable.getSelectedRow(), myTable.getSelectedColumn());
AvdInfo selected = myTable.getSelectedObject();
for (AvdSelectionListener listener : myListeners) {
listener.onAvdSelected(selected);
}
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class AvdSummaryAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
AvdInfo info = getAvdInfo();
if (info == null) {
return;
}
HtmlBuilder htmlBuilder = new HtmlBuilder();
htmlBuilder.openHtmlBody();
htmlBuilder.addHtml("<br>Name: ").add(info.getName());
htmlBuilder.addHtml("<br>CPU/ABI: ").add(AvdInfo.getPrettyAbiType(info));
htmlBuilder.addHtml("<br>Path: ").add(info.getDataFolderPath());
if (info.getStatus() != AvdInfo.AvdStatus.OK) {
htmlBuilder.addHtml("<br>Error: ").add(info.getErrorMessage());
} else {
AndroidVersion version = info.getAndroidVersion();
htmlBuilder.addHtml("<br>Target: ").add(String.format("%1$s (API level %2$s)", info.getTag(), version.getApiString()));
// display some extra values.
Map<String, String> properties = info.getProperties();
String skin = properties.get(AvdManager.AVD_INI_SKIN_NAME);
if (skin != null) {
htmlBuilder.addHtml("<br>Skin: ").add(skin);
}
String sdcard = properties.get(AvdManager.AVD_INI_SDCARD_SIZE);
if (sdcard == null) {
sdcard = properties.get(AvdManager.AVD_INI_SDCARD_PATH);
}
if (sdcard != null) {
htmlBuilder.addHtml("<br>SD Card: ").add(sdcard);
}
String snapshot = properties.get(AvdManager.AVD_INI_SNAPSHOT_PRESENT);
if (snapshot != null) {
htmlBuilder.addHtml("<br>Snapshot: ").add(snapshot);
}
// display other hardware
HashMap<String, String> copy = new HashMap<String, String>(properties);
// remove stuff we already displayed (or that we don't want to display)
copy.remove(AvdManager.AVD_INI_ABI_TYPE);
copy.remove(AvdManager.AVD_INI_CPU_ARCH);
copy.remove(AvdManager.AVD_INI_SKIN_NAME);
copy.remove(AvdManager.AVD_INI_SKIN_PATH);
copy.remove(AvdManager.AVD_INI_SDCARD_SIZE);
copy.remove(AvdManager.AVD_INI_SDCARD_PATH);
copy.remove(AvdManager.AVD_INI_IMAGES_2);
if (copy.size() > 0) {
for (Map.Entry<String, String> entry : copy.entrySet()) {
htmlBuilder.addHtml("<br>").add(entry.getKey()).add(": ").add(entry.getValue());
}
}
}
htmlBuilder.closeHtmlBody();
String[] options = { "Copy to Clipboard and Close", "Close" };
int i = Messages.showDialog((Project) null, htmlBuilder.getHtml(), "Details for " + info.getName(), options, 0, AllIcons.General.InformationDialog);
if (i == 0) {
CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.stripHtml(htmlBuilder.getHtml(), true)));
}
}
Aggregations