use of com.android.sdklib.internal.avd.AvdInfo in project otertool by wuntee.
the class AvdWorkshop method createAvd.
public static AvdInfo createAvd(CreateAvdBean bean) throws AndroidLocationException, IOException, GenericException {
ISdkLog sdkLogger = AvdWorkshop.getAvdLogger();
SdkManager sdkManager = SdkManager.createManager(OterStatics.getAndroidHome(), sdkLogger);
AvdManager avdManager = new AvdManager(sdkManager, sdkLogger);
File avdFolder = new File(AndroidLocation.getFolder() + "avd", bean.getName() + ".avd");
//newAvdInfo = avdManager.createAvd(avdFolder, avdName, target, skin, this.mSdkCommandLine.getParamSdCard(), hardwareConfig, removePrevious, this.mSdkCommandLine.getFlagSnapshot(), this.mSdkLog);
IAndroidTarget target = getAndroidTargetFromString(sdkManager, bean.getTarget());
ISystemImage[] abiTypes = target.getSystemImages();
if (abiTypes.length == 0) {
throw new GenericException("There are no images associated with the target.");
}
//ABI = Android Base Image ?
String abiType = abiTypes[0].getAbiType();
// /Applications/android-sdk-macosx/system-images/android-15/armeabi-v7a//system.img
// avdManager. createAvd(avdFolder, avdName, avdTarget, ABI, skin, sdCard, hadwareConfig, snapshot, force, false, logger)
//AvdInfo ret = avdManager.createAvd(avdFolder, bean.getName(), target, null, null, null, false, false, sdkLogger);
// createAvd(File arg0, String arg1, IAndroidTarget arg2, String arg3, String arg4, Map<String, String> arg5, boolean arg6, boolean arg7, ISdkLog arg8)
AvdInfo ret = avdManager.createAvd(avdFolder, bean.getName(), target, abiType, null, null, null, false, false, false, sdkLogger);
if (ret == null) {
logger.error("There was an error createing AVD, the manager returned a null info object.");
throw new GenericException("Could not create AVD for an unknown reason.");
}
if (bean.isPersistant() == true) {
makeAvdPersistant(ret);
}
return (ret);
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class AvdManagerConnection method getAvds.
/**
* @param forceRefresh if true the manager will read the AVD list from disk. If false, the cached version in memory
* is returned if available
* @return a list of AVDs currently present on the system.
*/
@NotNull
public List<AvdInfo> getAvds(boolean forceRefresh) {
if (!initIfNecessary()) {
return ImmutableList.of();
}
if (forceRefresh) {
try {
myAvdManager.reloadAvds(SDK_LOG);
} catch (AndroidLocation.AndroidLocationException e) {
IJ_LOG.error("Could not find Android SDK!", e);
}
}
ArrayList<AvdInfo> avdInfos = Lists.newArrayList(myAvdManager.getAllAvds());
boolean needsRefresh = false;
for (AvdInfo info : avdInfos) {
if (info.getStatus() == AvdInfo.AvdStatus.ERROR_DEVICE_CHANGED) {
updateDeviceChanged(info);
needsRefresh = true;
}
}
if (needsRefresh) {
return getAvds(true);
} else {
return avdInfos;
}
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class DeleteAvdAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
AvdManagerConnection connection = AvdManagerConnection.getDefaultAvdManagerConnection();
AvdInfo info = getAvdInfo();
if (info == null) {
return;
}
if (connection.isAvdRunning(info)) {
Messages.showErrorDialog(myAvdInfoProvider.getComponent(), "The selected AVD is currently running in the Emulator. Please exit the emulator instance and try deleting again.", "Cannot Delete A Running AVD");
return;
}
int result = Messages.showYesNoDialog(myAvdInfoProvider.getComponent(), "Do you really want to delete AVD " + info.getName() + "?", "Confirm Deletion", AllIcons.General.QuestionDialog);
if (result == Messages.YES) {
if (!connection.deleteAvd(info)) {
Messages.showErrorDialog(myAvdInfoProvider.getComponent(), "An error occurred while deleting the AVD. See idea.log for details.", "Error Deleting AVD");
}
refreshAvds();
}
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class AndroidFacet method addCompatibleAvds.
@NotNull
private AvdInfo[] addCompatibleAvds(@NotNull List<AvdInfo> to, @NotNull AvdInfo[] from) {
AndroidVersion minSdk = AndroidModuleInfo.get(this).getRuntimeMinSdkVersion();
AndroidPlatform platform = getConfiguration().getAndroidPlatform();
if (platform == null) {
LOG.error("Android Platform not set for module: " + getModule().getName());
return new AvdInfo[0];
}
for (AvdInfo avd : from) {
ISystemImage systemImage = avd.getSystemImage();
if (systemImage == null || LaunchCompatibility.canRunOnAvd(minSdk, platform.getTarget(), systemImage).isCompatible() != ThreeState.NO) {
to.add(avd);
}
}
return to.toArray(new AvdInfo[to.size()]);
}
use of com.android.sdklib.internal.avd.AvdInfo in project android by JetBrains.
the class WipeAvdDataAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
AvdManagerConnection connection = AvdManagerConnection.getDefaultAvdManagerConnection();
AvdInfo avdInfo = getAvdInfo();
if (avdInfo == null) {
return;
}
if (connection.isAvdRunning(avdInfo)) {
Messages.showErrorDialog(myAvdInfoProvider.getComponent(), "The selected AVD is currently running in the Emulator. " + "Please exit the emulator instance and try wiping again.", "Cannot Wipe A Running AVD");
return;
}
int result = Messages.showYesNoDialog(myAvdInfoProvider.getComponent(), "Do you really want to wipe user files from AVD " + avdInfo.getName() + "?", "Confirm Data Wipe", AllIcons.General.QuestionDialog);
if (result == Messages.YES) {
connection.wipeUserData(avdInfo);
refreshAvds();
}
}
Aggregations