Search in sources :

Example 1 with AvdInfo

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);
}
Also used : AvdManager(com.android.sdklib.internal.avd.AvdManager) SdkManager(com.android.sdklib.SdkManager) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) IAndroidTarget(com.android.sdklib.IAndroidTarget) ISystemImage(com.android.sdklib.ISystemImage) File(java.io.File) GenericException(com.wuntee.oter.exception.GenericException) ISdkLog(com.android.sdklib.ISdkLog)

Example 2 with AvdInfo

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;
    }
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AndroidLocation(com.android.prefs.AndroidLocation) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with AvdInfo

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();
    }
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo)

Example 4 with AvdInfo

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()]);
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo) ISystemImage(com.android.sdklib.ISystemImage) AndroidVersion(com.android.sdklib.AndroidVersion) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with AvdInfo

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();
    }
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo)

Aggregations

AvdInfo (com.android.sdklib.internal.avd.AvdInfo)25 AvdManager (com.android.sdklib.internal.avd.AvdManager)9 NotNull (org.jetbrains.annotations.NotNull)5 IDevice (com.android.ddmlib.IDevice)4 File (java.io.File)4 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)4 AndroidLocation (com.android.prefs.AndroidLocation)3 AndroidVersion (com.android.sdklib.AndroidVersion)3 AvdManagerConnection (com.android.tools.idea.avdmanager.AvdManagerConnection)3 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)3 Nullable (org.jetbrains.annotations.Nullable)3 IAndroidTarget (com.android.sdklib.IAndroidTarget)2 ISdkLog (com.android.sdklib.ISdkLog)2 ISystemImage (com.android.sdklib.ISystemImage)2 SdkManager (com.android.sdklib.SdkManager)2 Device (com.android.sdklib.devices.Device)2 IdDisplay (com.android.sdklib.repository.IdDisplay)2 Module (com.intellij.openapi.module.Module)2 Map (java.util.Map)2 AndroidDebugBridge (com.android.ddmlib.AndroidDebugBridge)1