Automated import from //branches/master/...@140701,140701

This commit is contained in:
Xavier Ducrohet
2009-03-24 18:15:58 -07:00
committed by The Android Open Source Project
parent f7ddba037d
commit ea2f618d74
4 changed files with 60 additions and 10 deletions

View File

@@ -32,7 +32,29 @@ public class AndroidLaunchConfiguration {
*/ */
public int mLaunchAction = LaunchConfigDelegate.DEFAULT_LAUNCH_ACTION; public int mLaunchAction = LaunchConfigDelegate.DEFAULT_LAUNCH_ACTION;
public static final boolean AUTO_TARGET_MODE = true; public enum TargetMode {
AUTO(true), MANUAL(false);
private boolean mValue;
TargetMode(boolean value) {
mValue = value;
}
public boolean getValue() {
return mValue;
}
public static TargetMode getMode(boolean value) {
for (TargetMode mode : values()) {
if (mode.mValue == value) {
return mode;
}
}
return null;
}
}
/** /**
* Target selection mode. * Target selection mode.
@@ -41,7 +63,7 @@ public class AndroidLaunchConfiguration {
* <li><code>false</code>: manual mode</li> * <li><code>false</code>: manual mode</li>
* </ul> * </ul>
*/ */
public boolean mTargetMode = LaunchConfigDelegate.DEFAULT_TARGET_MODE; public TargetMode mTargetMode = LaunchConfigDelegate.DEFAULT_TARGET_MODE;
/** /**
* Indicates whether the emulator should be called with -wipe-data * Indicates whether the emulator should be called with -wipe-data
@@ -81,8 +103,9 @@ public class AndroidLaunchConfiguration {
} }
try { try {
mTargetMode = config.getAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE, boolean value = config.getAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE,
mTargetMode); mTargetMode.getValue());
mTargetMode = TargetMode.getMode(value);
} catch (CoreException e) { } catch (CoreException e) {
// nothing to be done here, we'll use the default value // nothing to be done here, we'll use the default value
} }

View File

@@ -29,11 +29,13 @@ import com.android.ddmlib.MultiLineReceiver;
import com.android.ddmlib.SyncService; import com.android.ddmlib.SyncService;
import com.android.ddmlib.SyncService.SyncResult; import com.android.ddmlib.SyncService.SyncResult;
import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.launch.AndroidLaunchConfiguration.TargetMode;
import com.android.ide.eclipse.adt.launch.DelayedLaunchInfo.InstallRetryMode; import com.android.ide.eclipse.adt.launch.DelayedLaunchInfo.InstallRetryMode;
import com.android.ide.eclipse.adt.launch.DeviceChooserDialog.DeviceChooserResponse; import com.android.ide.eclipse.adt.launch.DeviceChooserDialog.DeviceChooserResponse;
import com.android.ide.eclipse.adt.project.ProjectHelper; import com.android.ide.eclipse.adt.project.ProjectHelper;
import com.android.ide.eclipse.adt.sdk.Sdk; import com.android.ide.eclipse.adt.sdk.Sdk;
import com.android.ide.eclipse.common.project.AndroidManifestParser; import com.android.ide.eclipse.common.project.AndroidManifestParser;
import com.android.prefs.AndroidLocation.AndroidLocationException;
import com.android.sdklib.IAndroidTarget; import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.SdkManager; import com.android.sdklib.SdkManager;
import com.android.sdklib.avd.AvdManager; import com.android.sdklib.avd.AvdManager;
@@ -236,7 +238,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
// set default target mode // set default target mode
wc.setAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE, wc.setAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE,
LaunchConfigDelegate.DEFAULT_TARGET_MODE); LaunchConfigDelegate.DEFAULT_TARGET_MODE.getValue());
// default AVD: None // default AVD: None
wc.setAttribute(LaunchConfigDelegate.ATTR_AVD_NAME, (String) null); wc.setAttribute(LaunchConfigDelegate.ATTR_AVD_NAME, (String) null);
@@ -332,6 +334,16 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
Sdk currentSdk = Sdk.getCurrent(); Sdk currentSdk = Sdk.getCurrent();
AvdManager avdManager = currentSdk.getAvdManager(); AvdManager avdManager = currentSdk.getAvdManager();
// reload the AVDs to make sure we are up to date
try {
avdManager.reloadAvds();
} catch (AndroidLocationException e1) {
// this happens if the AVD Manager failed to find the folder in which the AVDs are
// stored. This is unlikely to happen, but if it does, we should force to go manual
// to allow using physical devices.
config.mTargetMode = TargetMode.MANUAL;
}
// get the project target // get the project target
final IAndroidTarget projectTarget = currentSdk.getTarget(project); final IAndroidTarget projectTarget = currentSdk.getTarget(project);
@@ -356,7 +368,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
* If == 1, launch the application on this AVD/device. * If == 1, launch the application on this AVD/device.
*/ */
if (config.mTargetMode == AndroidLaunchConfiguration.AUTO_TARGET_MODE) { if (config.mTargetMode == TargetMode.AUTO) {
// if we are in automatic target mode, we need to find the current devices // if we are in automatic target mode, we need to find the current devices
IDevice[] devices = AndroidDebugBridge.getBridge().getDevices(); IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();

View File

@@ -18,6 +18,7 @@ package com.android.ide.eclipse.adt.launch;
import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.AndroidDebugBridge;
import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.launch.AndroidLaunchConfiguration.TargetMode;
import com.android.ide.eclipse.adt.project.ProjectHelper; import com.android.ide.eclipse.adt.project.ProjectHelper;
import com.android.ide.eclipse.common.AndroidConstants; import com.android.ide.eclipse.common.AndroidConstants;
import com.android.ide.eclipse.common.project.AndroidManifestParser; import com.android.ide.eclipse.common.project.AndroidManifestParser;
@@ -51,7 +52,7 @@ public class LaunchConfigDelegate extends LaunchConfigurationDelegate {
/** Target mode parameters: true is automatic, false is manual */ /** Target mode parameters: true is automatic, false is manual */
public static final String ATTR_TARGET_MODE = AdtPlugin.PLUGIN_ID + ".target"; //$NON-NLS-1$ public static final String ATTR_TARGET_MODE = AdtPlugin.PLUGIN_ID + ".target"; //$NON-NLS-1$
public static final boolean DEFAULT_TARGET_MODE = true; //automatic mode public static final TargetMode DEFAULT_TARGET_MODE = TargetMode.AUTO;
/** /**
* Launch action: * Launch action:

View File

@@ -177,7 +177,7 @@ public final class AvdManager {
public AvdManager(SdkManager sdk, ISdkLog sdkLog) throws AndroidLocationException { public AvdManager(SdkManager sdk, ISdkLog sdkLog) throws AndroidLocationException {
mSdk = sdk; mSdk = sdk;
mSdkLog = sdkLog; mSdkLog = sdkLog;
buildAvdList(); buildAvdList(mAvdList);
} }
/** /**
@@ -202,6 +202,20 @@ public final class AvdManager {
return null; return null;
} }
/**
* Reloads the AVD list.
* @throws AndroidLocationException if there was an error finding the location of the
* AVD folder.
*/
public void reloadAvds() throws AndroidLocationException {
// build the list in a temp list first, in case the method throws an exception.
// It's better than deleting the whole list before reading the new one.
ArrayList<AvdInfo> list = new ArrayList<AvdInfo>();
buildAvdList(list);
mAvdList.clear();
mAvdList.addAll(list);
}
/** /**
* Creates a new AVD. It is expected that there is no existing AVD with this name already. * Creates a new AVD. It is expected that there is no existing AVD with this name already.
* @param avdFolder the data folder for the AVD. It will be created as needed. * @param avdFolder the data folder for the AVD. It will be created as needed.
@@ -620,7 +634,7 @@ public final class AvdManager {
} }
} }
private void buildAvdList() throws AndroidLocationException { private void buildAvdList(ArrayList<AvdInfo> list) throws AndroidLocationException {
// get the Android prefs location. // get the Android prefs location.
String avdRoot = AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD; String avdRoot = AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD;
@@ -664,7 +678,7 @@ public final class AvdManager {
for (File avd : avds) { for (File avd : avds) {
AvdInfo info = parseAvdInfo(avd); AvdInfo info = parseAvdInfo(avd);
if (info != null) { if (info != null) {
mAvdList.add(info); list.add(info);
if (avdListDebug) { if (avdListDebug) {
mSdkLog.printf("[AVD LIST DEBUG] Added AVD '%s'\n", info.getPath()); mSdkLog.printf("[AVD LIST DEBUG] Added AVD '%s'\n", info.getPath());
} }