diff options
author | Raphael Moll <ralf@android.com> | 2012-10-22 14:33:54 -0700 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2012-10-22 14:37:29 -0700 |
commit | bb2737044cc852fa3ca1b31983da9a2a24c0d2e1 (patch) | |
tree | 66e98679b7b4142af654aeed1ac8d7d48c3d7695 /sdkmanager/libs | |
parent | 8cf807a3f15931accf414eb6b94a6e3a96fe9818 (diff) | |
download | sdk-bb2737044cc852fa3ca1b31983da9a2a24c0d2e1.zip sdk-bb2737044cc852fa3ca1b31983da9a2a24c0d2e1.tar.gz sdk-bb2737044cc852fa3ca1b31983da9a2a24c0d2e1.tar.bz2 |
AVD Manager: use device RAM/VM when creating AVD.
Also set default target if there's only one in the current SDK.
SDK Bug: 38785
Change-Id: I76d92ea4c43f94275f3d4373251a87ec3a6610a1
Diffstat (limited to 'sdkmanager/libs')
-rw-r--r-- | sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java | 101 |
1 files changed, 59 insertions, 42 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java index 657dbda..e3bd5f7 100644 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java @@ -519,47 +519,7 @@ public class AvdCreationDialog extends GridDialog { } if (currentDevice != null) { - Hardware hw = currentDevice.getDefaultHardware(); - Long ram = hw.getRam().getSizeAsUnit(Storage.Unit.MiB); - mRam.setText(Long.toString(ram)); - - // Set the default VM heap size. This is based on the Android CDD minimums for each - // screen size and density. - Screen s = hw.getScreen(); - ScreenSize size = s.getSize(); - Density density = s.getPixelDensity(); - int vmHeapSize = 32; - if (size.equals(ScreenSize.XLARGE)) { - switch (density) { - case LOW: - case MEDIUM: - vmHeapSize = 32; - break; - case TV: - case HIGH: - vmHeapSize = 64; - break; - case XHIGH: - case XXHIGH: - vmHeapSize = 128; - } - } else { - switch (density) { - case LOW: - case MEDIUM: - vmHeapSize = 16; - break; - case TV: - case HIGH: - vmHeapSize = 32; - break; - case XHIGH: - case XXHIGH: - vmHeapSize = 64; - - } - } - mVmHeap.setText(Integer.toString(vmHeapSize)); + fillDeviceProperties(currentDevice); } toggleCameras(); @@ -568,6 +528,50 @@ public class AvdCreationDialog extends GridDialog { } + private void fillDeviceProperties(Device device) { + Hardware hw = device.getDefaultHardware(); + Long ram = hw.getRam().getSizeAsUnit(Storage.Unit.MiB); + mRam.setText(Long.toString(ram)); + + // Set the default VM heap size. This is based on the Android CDD minimums for each + // screen size and density. + Screen s = hw.getScreen(); + ScreenSize size = s.getSize(); + Density density = s.getPixelDensity(); + int vmHeapSize = 32; + if (size.equals(ScreenSize.XLARGE)) { + switch (density) { + case LOW: + case MEDIUM: + vmHeapSize = 32; + break; + case TV: + case HIGH: + vmHeapSize = 64; + break; + case XHIGH: + case XXHIGH: + vmHeapSize = 128; + } + } else { + switch (density) { + case LOW: + case MEDIUM: + vmHeapSize = 16; + break; + case TV: + case HIGH: + vmHeapSize = 32; + break; + case XHIGH: + case XXHIGH: + vmHeapSize = 64; + + } + } + mVmHeap.setText(Integer.toString(vmHeapSize)); + } + private void toggleCameras() { mFrontCamera.setEnabled(false); mBackCamera.setEnabled(false); @@ -1148,7 +1152,9 @@ public class AvdCreationDialog extends GridDialog { private void fillInitialDeviceInfo(Device device) { String name = device.getManufacturer(); - if (!name.equals("Generic") && !name.equals("User")) { // TODO define & use constants + if (!name.equals("Generic") && // TODO define & use constants + !name.equals("User") && + device.getName().indexOf(name) == -1) { name = " by " + name; } else { name = ""; @@ -1158,6 +1164,7 @@ public class AvdCreationDialog extends GridDialog { name = name.replaceAll("[^0-9a-zA-Z_-]+", " ").trim().replaceAll("[ _]+", "_"); mAvdName.setText(name); + // Select the manufacturer of the device String manufacturer = device.getManufacturer(); for (int i = 0; i < mDeviceManufacturer.getItemCount(); i++) { if (mDeviceManufacturer.getItem(i).equals(manufacturer)) { @@ -1167,6 +1174,7 @@ public class AvdCreationDialog extends GridDialog { } reloadDeviceNameCombo(); + // Select the device String deviceName = device.getName(); for (int i = 0; i < mDeviceName.getItemCount(); i++) { if (mDeviceName.getItem(i).equals(deviceName)) { @@ -1176,6 +1184,15 @@ public class AvdCreationDialog extends GridDialog { } toggleCameras(); + // If there's only one target, select it by default. + // TODO: if there are more than 1 target, select the higher platform target as + // a likely default. + if (mTarget.getItemCount() == 1) { + mTarget.select(0); + reloadAbiTypeCombo(); + } + + fillDeviceProperties(device); } /** |