use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class AvdDisplayListTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
myAvdInfo = new AvdInfo("name", new File("ini"), "folder", null, myPropertiesMap);
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class AndroidVirtualDeviceTest method testCreateDevice.
public void testCreateDevice() throws Exception {
MockFileOp fop = new MockFileOp();
recordPlatform23(fop);
recordGoogleApisAddon23(fop);
recordGoogleApisSysImg23(fop);
fop.recordExistingFile(new File(DeviceArtDescriptor.getBundledDescriptorsFolder(), "nexus_5x"));
AndroidSdkHandler sdkHandler = new AndroidSdkHandler(new File("/sdk"), new File("/android-home"), fop);
final AvdManagerConnection connection = new AvdManagerConnection(sdkHandler);
FakePackage.FakeRemotePackage remotePlatform = new FakePackage.FakeRemotePackage("platforms;android-23");
RepoFactory factory = AndroidSdkHandler.getRepositoryModule().createLatestFactory();
DetailsTypes.PlatformDetailsType platformDetailsType = factory.createPlatformDetailsType();
platformDetailsType.setApiLevel(23);
remotePlatform.setTypeDetails((TypeDetails) platformDetailsType);
Map<String, RemotePackage> remotes = Maps.newHashMap();
remotes.put("platforms;android-23", remotePlatform);
AndroidVirtualDevice avd = new AndroidVirtualDevice(new ScopedStateStore(ScopedStateStore.Scope.STEP, null, null), remotes, true, fop);
final AvdInfo avdInfo = avd.createAvd(connection, sdkHandler);
assertNotNull(avdInfo);
disposeOnTearDown(() -> connection.deleteAvd(avdInfo));
assertNotNull(avdInfo);
Map<String, String> properties = avdInfo.getProperties();
Map<String, String> referenceMap = getReferenceMap();
for (Map.Entry<String, String> entry : referenceMap.entrySet()) {
assertEquals(entry.getKey(), entry.getValue(), FileUtil.toSystemIndependentName(properties.get(entry.getKey())));
}
// AVD manager will set some extra properties that we don't care about and that may be system dependant.
// We do not care about those so we only ensure we have the ones we need.
File skin = new File(properties.get(AvdManager.AVD_INI_SKIN_PATH));
assertEquals("nexus_5x", skin.getName());
}
use of com.android.sdklib.internal.avd.AvdInfo in project otertool by wuntee.
the class AvdWorkshop method isAvdExist.
public static boolean isAvdExist(String avd) throws AndroidLocationException {
ISdkLog sdkLogger = AvdWorkshop.getAvdLogger();
SdkManager sdkManager = SdkManager.createManager(OterStatics.getAndroidHome(), sdkLogger);
AvdManager avdManager = new AvdManager(sdkManager, sdkLogger);
for (AvdInfo i : avdManager.getAllAvds()) {
if (i.getName().equals(avd)) {
return (true);
}
}
return (false);
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class DeviceMenuAction method createPopupActionGroup.
@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup() {
DefaultActionGroup group = new DefaultActionGroup(null, true);
Configuration configuration = myRenderContext.getConfiguration();
if (configuration == null) {
return group;
}
Device current = configuration.getDevice();
ConfigurationManager configurationManager = configuration.getConfigurationManager();
List<Device> deviceList = configurationManager.getDevices();
if (LIST_RECENT_DEVICES) {
List<Device> recent = configurationManager.getDevices();
if (recent.size() > 1) {
boolean separatorNeeded = false;
for (Device device : recent) {
String label = getLabel(device, isNexus(device));
Icon icon = getDeviceClassIcon(device);
group.add(new SetDeviceAction(myRenderContext, label, device, icon, device == current));
separatorNeeded = true;
}
if (separatorNeeded) {
group.addSeparator();
}
}
}
AndroidFacet facet = AndroidFacet.getInstance(configurationManager.getModule());
if (facet == null) {
// Unlikely, but has happened - see http://b.android.com/68091
return group;
}
if (!deviceList.isEmpty()) {
Map<String, List<Device>> manufacturers = new TreeMap<>();
for (Device device : deviceList) {
List<Device> devices;
if (manufacturers.containsKey(device.getManufacturer())) {
devices = manufacturers.get(device.getManufacturer());
} else {
devices = new ArrayList<>();
manufacturers.put(device.getManufacturer(), devices);
}
devices.add(device);
}
List<Device> nexus = new ArrayList<>();
Map<FormFactor, List<Device>> deviceMap = Maps.newEnumMap(FormFactor.class);
for (FormFactor factor : FormFactor.values()) {
deviceMap.put(factor, Lists.newArrayList());
}
for (List<Device> devices : manufacturers.values()) {
for (Device device : devices) {
if (isNexus(device) && !device.getManufacturer().equals(MANUFACTURER_GENERIC) && !isWear(device) && !isTv(device)) {
nexus.add(device);
} else {
deviceMap.get(FormFactor.getFormFactor(device)).add(device);
}
}
}
sortDevicesByScreenSize(nexus);
for (List<Device> list : splitDevicesByScreenSize(nexus)) {
addNexusDeviceSection(group, current, list);
group.addSeparator();
}
addDeviceSection(group, current, deviceMap, false, FormFactor.WEAR);
group.addSeparator();
addDeviceSection(group, current, deviceMap, false, FormFactor.TV);
group.addSeparator();
final AvdManager avdManager = facet.getAvdManagerSilently();
if (avdManager != null) {
boolean separatorNeeded = false;
boolean first = true;
for (AvdInfo avd : avdManager.getValidAvds()) {
Device device = configurationManager.createDeviceForAvd(avd);
if (device != null) {
String avdName = "AVD: " + avd.getName();
boolean selected = current != null && (current.getDisplayName().equals(avdName) || current.getId().equals(avdName));
Icon icon = first ? getDeviceClassIcon(device) : null;
group.add(new SetDeviceAction(myRenderContext, avdName, device, icon, selected));
first = false;
separatorNeeded = true;
}
}
if (separatorNeeded) {
group.addSeparator();
}
}
DefaultActionGroup genericGroup = new DefaultActionGroup("_Generic Phones and Tablets", true);
sortDevicesByScreenSize(deviceMap.get(FormFactor.MOBILE));
addDeviceSection(genericGroup, current, deviceMap, true, FormFactor.MOBILE);
group.add(genericGroup);
}
group.add(new RunAndroidAvdManagerAction("Add Device Definition..."));
return group;
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class DeviceRenderer method renderDeviceName.
static void renderDeviceName(@NotNull IDevice d, @NotNull ColoredTextContainer component, @Nullable AvdManager avdManager) {
component.setIcon(d.isEmulator() ? AndroidIcons.Ddms.Emulator2 : AndroidIcons.Ddms.RealDevice);
String name;
if (d.isEmulator()) {
String avdName = d.getAvdName();
if (avdManager != null) {
AvdInfo info = avdManager.getAvd(avdName, true);
if (info != null) {
avdName = info.getProperties().get(AvdManager.AVD_INI_DISPLAY_NAME);
}
}
if (avdName == null) {
avdName = "unknown";
}
name = String.format("%1$s %2$s ", AndroidBundle.message("android.emulator"), avdName);
} else {
name = String.format("%1$s %2$s ", DevicePropertyUtil.getManufacturer(d, ""), DevicePropertyUtil.getModel(d, ""));
}
component.append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES);
IDevice.DeviceState deviceState = d.getState();
if (deviceState != IDevice.DeviceState.ONLINE) {
String state = String.format("%1$s [%2$s] ", d.getSerialNumber(), d.getState());
component.append(state, SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES);
}
if (deviceState != IDevice.DeviceState.DISCONNECTED && deviceState != IDevice.DeviceState.OFFLINE) {
component.append(DevicePropertyUtil.getBuild(d), SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}
Aggregations