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