Search in sources :

Example 1 with SystemImageDescription

use of com.android.tools.idea.avdmanager.SystemImageDescription in project android by JetBrains.

the class AndroidVirtualDevice method getSystemImageDescription.

private SystemImageDescription getSystemImageDescription(AndroidSdkHandler sdkHandler) throws WizardException {
    StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
    Collection<SystemImage> systemImages = sdkHandler.getSystemImageManager(progress).lookup(ID_ADDON_GOOGLE_API_IMG, myLatestVersion, ID_VENDOR_GOOGLE);
    if (systemImages.isEmpty()) {
        throw new WizardException("Missing system image required for an AVD setup");
    }
    return new SystemImageDescription(systemImages.iterator().next());
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) SystemImage(com.android.sdklib.repository.targets.SystemImage) SystemImageDescription(com.android.tools.idea.avdmanager.SystemImageDescription)

Example 2 with SystemImageDescription

use of com.android.tools.idea.avdmanager.SystemImageDescription in project android by JetBrains.

the class AndroidVirtualDevice method isSelectedByDefault.

@Override
protected boolean isSelectedByDefault() {
    if (mySdkHandler == null) {
        return false;
    }
    SystemImageDescription desired;
    try {
        desired = getSystemImageDescription(mySdkHandler);
    } catch (WizardException e) {
        // ignore, error will be shown during configure if they opt to try to create.
        return false;
    }
    AvdManagerConnection connection = AvdManagerConnection.getAvdManagerConnection(mySdkHandler);
    List<AvdInfo> avds = connection.getAvds(false);
    for (AvdInfo avd : avds) {
        if (avd.getAbiType().equals(desired.getAbiType()) && avd.getAndroidVersion().equals(desired.getVersion())) {
            // We have a similar avd already installed. Deselect by default.
            return false;
        }
    }
    return true;
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AvdManagerConnection(com.android.tools.idea.avdmanager.AvdManagerConnection) SystemImageDescription(com.android.tools.idea.avdmanager.SystemImageDescription)

Example 3 with SystemImageDescription

use of com.android.tools.idea.avdmanager.SystemImageDescription in project android by JetBrains.

the class AndroidVirtualDevice method createAvd.

@Nullable
@VisibleForTesting
AvdInfo createAvd(@NotNull AvdManagerConnection connection, @NotNull AndroidSdkHandler sdkHandler) throws WizardException {
    Device d = getDevice(sdkHandler.getLocation());
    SystemImageDescription systemImageDescription = getSystemImageDescription(sdkHandler);
    String cardSize = AvdOptionsModel.toIniString(DEFAULT_INTERNAL_STORAGE, false);
    File hardwareSkinPath = resolveSkinPath(d.getDefaultHardware().getSkinFile(), systemImageDescription, myFileOp);
    String displayName = String.format("%1$s %2$s %3$s", d.getDisplayName(), systemImageDescription.getVersion(), systemImageDescription.getAbiType());
    displayName = connection.uniquifyDisplayName(displayName);
    String internalName = cleanAvdName(connection, displayName, true);
    Abi abi = Abi.getEnum(systemImageDescription.getAbiType());
    boolean useRanchu = AvdManagerConnection.doesSystemImageSupportQemu2(systemImageDescription, myFileOp);
    boolean supportsSmp = abi != null && abi.supportsMultipleCpuCores() && getMaxCpuCores() > 1;
    Map<String, String> settings = getAvdSettings(internalName, d);
    settings.put(AVD_INI_DISPLAY_NAME, displayName);
    if (useRanchu) {
        settings.put(CPU_CORES_KEY, String.valueOf(supportsSmp ? getMaxCpuCores() : 1));
    }
    return connection.createOrUpdateAvd(null, internalName, d, systemImageDescription, ScreenOrientation.PORTRAIT, false, cardSize, hardwareSkinPath, settings, false);
}
Also used : Device(com.android.sdklib.devices.Device) Abi(com.android.sdklib.devices.Abi) SystemImageDescription(com.android.tools.idea.avdmanager.SystemImageDescription) File(java.io.File) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SystemImageDescription (com.android.tools.idea.avdmanager.SystemImageDescription)3 Abi (com.android.sdklib.devices.Abi)1 Device (com.android.sdklib.devices.Device)1 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)1 SystemImage (com.android.sdklib.repository.targets.SystemImage)1 AvdManagerConnection (com.android.tools.idea.avdmanager.AvdManagerConnection)1 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 File (java.io.File)1 Nullable (org.jetbrains.annotations.Nullable)1