Search in sources :

Example 16 with AvdInfo

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;
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AvdManagerConnection(com.android.tools.idea.avdmanager.AvdManagerConnection) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) AndroidLocation(com.android.prefs.AndroidLocation)

Example 17 with AvdInfo

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);
        }
    }
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog)

Example 18 with AvdInfo

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()]);
}
Also used : AvdManager(com.android.sdklib.internal.avd.AvdManager) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with AvdInfo

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);
    }
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo)

Example 20 with AvdInfo

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)));
    }
}
Also used : HashMap(java.util.HashMap) HtmlBuilder(com.android.utils.HtmlBuilder) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AndroidVersion(com.android.sdklib.AndroidVersion) HashMap(java.util.HashMap) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

AvdInfo (com.android.sdklib.internal.avd.AvdInfo)25 AvdManager (com.android.sdklib.internal.avd.AvdManager)9 NotNull (org.jetbrains.annotations.NotNull)5 IDevice (com.android.ddmlib.IDevice)4 File (java.io.File)4 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)4 AndroidLocation (com.android.prefs.AndroidLocation)3 AndroidVersion (com.android.sdklib.AndroidVersion)3 AvdManagerConnection (com.android.tools.idea.avdmanager.AvdManagerConnection)3 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)3 Nullable (org.jetbrains.annotations.Nullable)3 IAndroidTarget (com.android.sdklib.IAndroidTarget)2 ISdkLog (com.android.sdklib.ISdkLog)2 ISystemImage (com.android.sdklib.ISystemImage)2 SdkManager (com.android.sdklib.SdkManager)2 Device (com.android.sdklib.devices.Device)2 IdDisplay (com.android.sdklib.repository.IdDisplay)2 Module (com.intellij.openapi.module.Module)2 Map (java.util.Map)2 AndroidDebugBridge (com.android.ddmlib.AndroidDebugBridge)1