use of com.android.sdklib.ISystemImage in project android by JetBrains.
the class AvdOptionsModel method updateValuesWithAvdInfo.
private void updateValuesWithAvdInfo(@NotNull AvdInfo avdInfo) {
List<Device> devices = DeviceManagerConnection.getDefaultDeviceManagerConnection().getDevices();
Device selectedDevice = null;
String manufacturer = avdInfo.getDeviceManufacturer();
String deviceId = avdInfo.getProperties().get(AvdManager.AVD_INI_DEVICE_NAME);
for (Device device : devices) {
if (manufacturer.equals(device.getManufacturer()) && deviceId.equals(device.getId())) {
selectedDevice = device;
break;
}
}
myDevice.setNullableValue(selectedDevice);
SystemImageDescription systemImageDescription = null;
ISystemImage selectedImage = avdInfo.getSystemImage();
if (selectedImage != null) {
systemImageDescription = new SystemImageDescription(selectedImage);
mySystemImage.setValue(systemImageDescription);
}
myAvdDeviceData = new AvdDeviceData(selectedDevice, systemImageDescription);
Map<String, String> properties = avdInfo.getProperties();
myUseQemu2.set(properties.containsKey(AvdWizardUtils.CPU_CORES_KEY));
String cpuCoreCount = properties.get(AvdWizardUtils.CPU_CORES_KEY);
myCpuCoreCount.setValue(cpuCoreCount == null ? 1 : Integer.parseInt(cpuCoreCount));
Storage storage = getStorageFromIni(properties.get(AvdWizardUtils.RAM_STORAGE_KEY));
if (storage != null) {
myAvdDeviceData.ramStorage().set(storage);
}
storage = getStorageFromIni(properties.get(AvdWizardUtils.VM_HEAP_STORAGE_KEY));
if (storage != null) {
myVmHeapStorage.set(storage);
}
storage = getStorageFromIni(properties.get(AvdWizardUtils.INTERNAL_STORAGE_KEY));
if (storage != null) {
myInternalStorage.set(storage);
}
String sdCardLocation = null;
if (properties.get(AvdWizardUtils.EXISTING_SD_LOCATION) != null) {
sdCardLocation = properties.get(AvdWizardUtils.EXISTING_SD_LOCATION);
} else if (properties.get(AvdWizardUtils.SD_CARD_STORAGE_KEY) != null) {
sdCardLocation = FileUtil.join(avdInfo.getDataFolderPath(), "sdcard.img");
}
existingSdLocation = new StringValueProperty(nullToEmpty(sdCardLocation));
String dataFolderPath = avdInfo.getDataFolderPath();
File sdLocationFile = null;
if (sdCardLocation != null) {
sdLocationFile = new File(sdCardLocation);
}
if (sdLocationFile != null) {
if (Objects.equal(sdLocationFile.getParent(), dataFolderPath)) {
// the image is in the AVD folder, consider it to be internal
File sdFile = new File(sdCardLocation);
Storage sdCardSize = new Storage(sdFile.length());
myUseExternalSdCard.set(false);
myUseBuiltInSdCard.set(true);
myOriginalSdCard = new ObjectValueProperty<>(sdCardSize);
mySdCardStorage.setValue(sdCardSize);
} else {
// the image is external
myUseExternalSdCard.set(true);
myUseBuiltInSdCard.set(false);
externalSdCardLocation().set(sdCardLocation);
}
}
myUseHostGpu.set(fromIniString(properties.get(AvdWizardUtils.USE_HOST_GPU_KEY)));
mySelectedAvdFrontCamera.set(AvdCamera.fromName(properties.get(AvdWizardUtils.FRONT_CAMERA_KEY)));
mySelectedAvdBackCamera.set(AvdCamera.fromName(properties.get(AvdWizardUtils.BACK_CAMERA_KEY)));
mySelectedNetworkLatency.set(AvdNetworkLatency.fromName(properties.get(AvdWizardUtils.NETWORK_LATENCY_KEY)));
mySelectedNetworkSpeed.set(AvdNetworkSpeed.fromName(properties.get(AvdWizardUtils.NETWORK_SPEED_KEY)));
myEnableHardwareKeyboard.set(fromIniString(properties.get(AvdWizardUtils.HAS_HARDWARE_KEYBOARD_KEY)));
myAvdDisplayName.set(AvdManagerConnection.getAvdDisplayName(avdInfo));
myHasDeviceFrame.set(fromIniString(properties.get(AvdWizardUtils.DEVICE_FRAME_KEY)));
ScreenOrientation screenOrientation = null;
String orientation = properties.get(HardwareProperties.HW_INITIAL_ORIENTATION);
if (!Strings.isNullOrEmpty(orientation)) {
screenOrientation = ScreenOrientation.getByShortDisplayName(orientation);
}
mySelectedAvdOrientation.set((screenOrientation == null) ? ScreenOrientation.PORTRAIT : screenOrientation);
String skinPath = properties.get(AvdWizardUtils.CUSTOM_SKIN_FILE_KEY);
if (skinPath != null) {
File skinFile = (skinPath.equals(AvdWizardUtils.NO_SKIN.getPath())) ? AvdWizardUtils.NO_SKIN : new File(skinPath);
if (skinFile.isDirectory()) {
myAvdDeviceData.customSkinFile().setValue(skinFile);
}
}
String backupSkinPath = properties.get(AvdWizardUtils.BACKUP_SKIN_FILE_KEY);
if (backupSkinPath != null) {
File skinFile = new File(backupSkinPath);
if (skinFile.isDirectory() || FileUtil.filesEqual(skinFile, AvdWizardUtils.NO_SKIN)) {
backupSkinFile().setValue(skinFile);
}
}
String modeString = properties.get(AvdWizardUtils.HOST_GPU_MODE_KEY);
myHostGpuMode.setValue(GpuMode.fromGpuSetting(modeString));
myIsInEditMode.set(true);
}
use of com.android.sdklib.ISystemImage in project android by JetBrains.
the class SystemImageListModel method getLocalImages.
private List<SystemImageDescription> getLocalImages() {
SystemImageManager systemImageManager = mySdkHandler.getSystemImageManager(LOGGER);
List<SystemImageDescription> items = Lists.newArrayList();
for (ISystemImage image : systemImageManager.getImages()) {
SystemImageDescription desc = new SystemImageDescription(image);
items.add(desc);
}
return items;
}
use of com.android.sdklib.ISystemImage in project android by JetBrains.
the class SkinChooser method getSkins.
private List<File> getSkins() {
List<Device> devices = DeviceManagerConnection.getDefaultDeviceManagerConnection().getDevices();
Set<File> result = Sets.newTreeSet();
for (Device device : devices) {
File skinFile = AvdWizardUtils.resolveSkinPath(device.getDefaultHardware().getSkinFile(), null, FileOpUtils.create());
if (skinFile != null && skinFile.exists()) {
result.add(skinFile);
}
}
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(SkinChooser.class);
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
for (IAndroidTarget target : sdkHandler.getAndroidTargetManager(progress).getTargets(progress)) {
Arrays.stream(target.getSkins()).map(this::resolve).forEach(result::add);
}
for (ISystemImage img : sdkHandler.getSystemImageManager(progress).getImages()) {
Arrays.stream(img.getSkins()).map(this::resolve).forEach(result::add);
}
List<File> resultList = Lists.newArrayList();
resultList.add(NO_SKIN);
resultList.addAll(result);
return resultList;
}
Aggregations