Update ADT to use the refactored sdklib from previous patch.
This commit is contained in:
@@ -41,8 +41,8 @@ import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||
import com.android.prefs.AndroidLocation.AndroidLocationException;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.SdkManager;
|
||||
import com.android.sdklib.avd.AvdManager;
|
||||
import com.android.sdklib.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdklib.internal.avd.AvdManager;
|
||||
import com.android.sdklib.internal.avd.AvdManager.AvdInfo;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -85,7 +85,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public final class AndroidLaunchController implements IDebugBridgeChangeListener,
|
||||
IDeviceChangeListener, IClientChangeListener, ILaunchController {
|
||||
|
||||
|
||||
private static final String FLAG_AVD = "-avd"; //$NON-NLS-1$
|
||||
private static final String FLAG_NETDELAY = "-netdelay"; //$NON-NLS-1$
|
||||
private static final String FLAG_NETSPEED = "-netspeed"; //$NON-NLS-1$
|
||||
@@ -94,7 +94,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
|
||||
/**
|
||||
* Map to store {@link ILaunchConfiguration} objects that must be launched as simple connection
|
||||
* to running application. The integer is the port on which to connect.
|
||||
* to running application. The integer is the port on which to connect.
|
||||
* <b>ALL ACCESS MUST BE INSIDE A <code>synchronized (sListLock)</code> block!</b>
|
||||
*/
|
||||
private static final HashMap<ILaunchConfiguration, Integer> sRunningAppMap =
|
||||
@@ -118,35 +118,35 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* */
|
||||
private final ArrayList<DelayedLaunchInfo> mWaitingForReadyEmulatorList =
|
||||
new ArrayList<DelayedLaunchInfo>();
|
||||
|
||||
|
||||
/**
|
||||
* Application waiting to show up as waiting for debugger.
|
||||
* <b>ALL ACCESS MUST BE INSIDE A <code>synchronized (sListLock)</code> block!</b>
|
||||
*/
|
||||
private final ArrayList<DelayedLaunchInfo> mWaitingForDebuggerApplications =
|
||||
new ArrayList<DelayedLaunchInfo>();
|
||||
|
||||
|
||||
/**
|
||||
* List of clients that have appeared as waiting for debugger before their name was available.
|
||||
* <b>ALL ACCESS MUST BE INSIDE A <code>synchronized (sListLock)</code> block!</b>
|
||||
*/
|
||||
private final ArrayList<Client> mUnknownClientsWaitingForDebugger = new ArrayList<Client>();
|
||||
|
||||
|
||||
/** static instance for singleton */
|
||||
private static AndroidLaunchController sThis = new AndroidLaunchController();
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output receiver for "pm install package.apk" command line.
|
||||
*/
|
||||
private static final class InstallReceiver extends MultiLineReceiver {
|
||||
|
||||
|
||||
private static final String SUCCESS_OUTPUT = "Success"; //$NON-NLS-1$
|
||||
private static final Pattern FAILURE_PATTERN = Pattern.compile("Failure\\s+\\[(.*)\\]"); //$NON-NLS-1$
|
||||
|
||||
|
||||
private String mSuccess = null;
|
||||
|
||||
|
||||
public InstallReceiver() {
|
||||
}
|
||||
|
||||
@@ -199,15 +199,15 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
public static void debugRunningApp(IProject project, int debugPort) {
|
||||
// get an existing or new launch configuration
|
||||
ILaunchConfiguration config = AndroidLaunchController.getLaunchConfig(project);
|
||||
|
||||
|
||||
if (config != null) {
|
||||
setPortLaunchConfigAssociation(config, debugPort);
|
||||
|
||||
|
||||
// and launch
|
||||
DebugUITools.launch(config, ILaunchManager.DEBUG_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an {@link ILaunchConfiguration} for the specified {@link IProject}.
|
||||
* @param project the project
|
||||
@@ -259,20 +259,20 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
// and delay
|
||||
wc.setAttribute(LaunchConfigDelegate.ATTR_DELAY,
|
||||
LaunchConfigDelegate.DEFAULT_DELAY);
|
||||
|
||||
|
||||
// default wipe data mode
|
||||
wc.setAttribute(LaunchConfigDelegate.ATTR_WIPE_DATA,
|
||||
LaunchConfigDelegate.DEFAULT_WIPE_DATA);
|
||||
|
||||
|
||||
// default disable boot animation option
|
||||
wc.setAttribute(LaunchConfigDelegate.ATTR_NO_BOOT_ANIM,
|
||||
LaunchConfigDelegate.DEFAULT_NO_BOOT_ANIM);
|
||||
|
||||
|
||||
// set default emulator options
|
||||
IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
|
||||
String emuOptions = store.getString(AdtPlugin.PREFS_EMU_OPTIONS);
|
||||
wc.setAttribute(LaunchConfigDelegate.ATTR_COMMANDLINE, emuOptions);
|
||||
|
||||
|
||||
// map the config and the project
|
||||
wc.setMappedResources(getResourcesToMap(project));
|
||||
|
||||
@@ -289,10 +289,10 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the list of resources to map to a Launch Configuration.
|
||||
* @param project the project associated to the launch configuration.
|
||||
@@ -300,12 +300,12 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
public static IResource[] getResourcesToMap(IProject project) {
|
||||
ArrayList<IResource> array = new ArrayList<IResource>(2);
|
||||
array.add(project);
|
||||
|
||||
|
||||
IFile manifest = AndroidManifestParser.getManifest(project);
|
||||
if (manifest != null) {
|
||||
array.add(manifest);
|
||||
}
|
||||
|
||||
|
||||
return array.toArray(new IResource[array.size()]);
|
||||
}
|
||||
|
||||
@@ -327,10 +327,10 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* @param launch the launch object
|
||||
*/
|
||||
public void launch(final IProject project, String mode, IFile apk,
|
||||
String packageName, String debugPackageName, Boolean debuggable, int requiredApiVersionNumber,
|
||||
final IAndroidLaunchAction launchAction, final AndroidLaunchConfiguration config,
|
||||
String packageName, String debugPackageName, Boolean debuggable, int requiredApiVersionNumber,
|
||||
final IAndroidLaunchAction launchAction, final AndroidLaunchConfiguration config,
|
||||
final AndroidLaunch launch, IProgressMonitor monitor) {
|
||||
|
||||
|
||||
String message = String.format("Performing %1$s", launchAction.getLaunchDescription());
|
||||
AdtPlugin.printToConsole(project, message);
|
||||
|
||||
@@ -345,7 +345,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
// get the SDK
|
||||
Sdk currentSdk = Sdk.getCurrent();
|
||||
AvdManager avdManager = currentSdk.getAvdManager();
|
||||
|
||||
|
||||
// reload the AVDs to make sure we are up to date
|
||||
try {
|
||||
avdManager.reloadAvds();
|
||||
@@ -358,12 +358,12 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
|
||||
// get the project target
|
||||
final IAndroidTarget projectTarget = currentSdk.getTarget(project);
|
||||
|
||||
|
||||
// FIXME: check errors on missing sdk, AVD manager, or project target.
|
||||
|
||||
|
||||
// device chooser response object.
|
||||
final DeviceChooserResponse response = new DeviceChooserResponse();
|
||||
|
||||
|
||||
/*
|
||||
* Launch logic:
|
||||
* - Manually Mode
|
||||
@@ -379,11 +379,11 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* If != 1, display a UI similar to manual mode.
|
||||
* If == 1, launch the application on this AVD/device.
|
||||
*/
|
||||
|
||||
|
||||
if (config.mTargetMode == TargetMode.AUTO) {
|
||||
// if we are in automatic target mode, we need to find the current devices
|
||||
IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();
|
||||
|
||||
|
||||
// first check if we have a preferred AVD name, and if it actually exists, and is valid
|
||||
// (ie able to run the project).
|
||||
// We need to check this in case the AVD was recreated with a different target that is
|
||||
@@ -399,7 +399,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
config.mAvdName, projectTarget.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (preferredAvd != null) {
|
||||
// look for a matching device
|
||||
for (IDevice d : devices) {
|
||||
@@ -415,7 +415,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// at this point we have a valid preferred AVD that is not running.
|
||||
// We need to start it.
|
||||
response.setAvdToLaunch(preferredAvd);
|
||||
@@ -459,13 +459,13 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
hasDevice = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// depending on the number of devices, we'll simulate an automatic choice
|
||||
// from the device chooser or simply show up the device chooser.
|
||||
if (hasDevice == false && compatibleRunningAvds.size() == 0) {
|
||||
// if zero emulators/devices, we launch an emulator.
|
||||
// We need to figure out which AVD first.
|
||||
|
||||
|
||||
// we are going to take the closest AVD. ie a compatible AVD that has the API level
|
||||
// closest to the project target.
|
||||
AvdInfo defaultAvd = findMatchingAvd(avdManager, projectTarget);
|
||||
@@ -501,7 +501,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
if (searchAgain[0]) {
|
||||
// attempt to reload the AVDs and find one compatible.
|
||||
defaultAvd = findMatchingAvd(avdManager, projectTarget);
|
||||
|
||||
|
||||
if (defaultAvd == null) {
|
||||
AdtPlugin.printErrorToConsole(project, String.format(
|
||||
"Still no compatible AVDs with target '%1$s': Aborting launch.",
|
||||
@@ -540,14 +540,14 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
|
||||
// if more than one device, we'll bring up the DeviceChooser dialog below.
|
||||
if (compatibleRunningAvds.size() >= 2) {
|
||||
message = "Automatic Target Mode: Several compatible targets. Please select a target device.";
|
||||
message = "Automatic Target Mode: Several compatible targets. Please select a target device.";
|
||||
} else if (hasDevice) {
|
||||
message = "Automatic Target Mode: Unable to detect device compatibility. Please select a target device.";
|
||||
message = "Automatic Target Mode: Unable to detect device compatibility. Please select a target device.";
|
||||
}
|
||||
|
||||
AdtPlugin.printToConsole(project, message);
|
||||
}
|
||||
|
||||
|
||||
// bring up the device chooser.
|
||||
AdtPlugin.getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
@@ -599,7 +599,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
return defaultAvd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Continues the launch based on the DeviceChooser response.
|
||||
* @param response the device chooser response
|
||||
@@ -626,19 +626,19 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
"Launching a new emulator with Virtual Device '%1$s'",
|
||||
info.getName()));
|
||||
boolean status = launchEmulator(config, info);
|
||||
|
||||
|
||||
if (status == false) {
|
||||
// launching the emulator failed!
|
||||
AdtPlugin.displayError("Emulator Launch",
|
||||
"Couldn't launch the emulator! Make sure the SDK directory is properly setup and the emulator is not missing.");
|
||||
|
||||
|
||||
// stop the launch and return
|
||||
mWaitingForEmulatorLaunches.remove(launchInfo);
|
||||
AdtPlugin.printErrorToConsole(project, "Launch canceled!");
|
||||
stopLaunch(launchInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (response.getDeviceToUse() != null) {
|
||||
@@ -648,7 +648,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Queries for a debugger port for a specific {@link ILaunchConfiguration}.
|
||||
* <p/>
|
||||
@@ -667,10 +667,10 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return LaunchConfigDelegate.INVALID_DEBUG_PORT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a {@link ILaunchConfiguration} and its associated debug port, in the list of
|
||||
* launch config to connect directly to a running app instead of doing full launch (sync,
|
||||
@@ -684,7 +684,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
sRunningAppMap.put(launchConfig, port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks the build information, and returns whether the launch should continue.
|
||||
* <p/>The value tested are:
|
||||
@@ -699,7 +699,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
private boolean checkBuildInfo(DelayedLaunchInfo launchInfo, IDevice device) {
|
||||
if (device != null) {
|
||||
// check the app required API level versus the target device API level
|
||||
|
||||
|
||||
String deviceApiVersionName = device.getProperty(IDevice.PROP_BUILD_VERSION);
|
||||
String value = device.getProperty(IDevice.PROP_BUILD_VERSION_NUMBER);
|
||||
int deviceApiVersionNumber = AndroidManifestParser.INVALID_MIN_SDK;
|
||||
@@ -708,7 +708,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
} catch (NumberFormatException e) {
|
||||
// pass, we'll keep the deviceVersionNumber value at 0.
|
||||
}
|
||||
|
||||
|
||||
if (launchInfo.getRequiredApiVersionNumber() == AndroidManifestParser.INVALID_MIN_SDK) {
|
||||
// warn the API level requirement is not set.
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(),
|
||||
@@ -735,7 +735,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
launchInfo.getRequiredApiVersionNumber(), deviceApiVersionNumber,
|
||||
deviceApiVersionName);
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg);
|
||||
|
||||
|
||||
// abort the launch
|
||||
return false;
|
||||
}
|
||||
@@ -753,7 +753,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
String message2 = String.format("Application '%1$s' does not have the attribute 'debuggable' set to TRUE in its manifest and cannot be debugged.",
|
||||
launchInfo.getPackageName());
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(), message1, message2);
|
||||
|
||||
|
||||
// because am -D does not check for ro.debuggable and the
|
||||
// 'debuggable' attribute, it is important we do not use the -D option
|
||||
// in this case or the app will wait for a debugger forever and never
|
||||
@@ -773,7 +773,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
private boolean syncApp(DelayedLaunchInfo launchInfo, IDevice device) {
|
||||
boolean alreadyInstalled = ApkInstallManager.getInstance().isApplicationInstalled(
|
||||
launchInfo.getProject(), device);
|
||||
|
||||
|
||||
if (alreadyInstalled) {
|
||||
AdtPlugin.printToConsole(launchInfo.getProject(),
|
||||
"Application already deployed. No need to reinstall.");
|
||||
@@ -836,7 +836,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -873,7 +873,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
// This will check that there isn't another apk declaring the same package, or
|
||||
// that another install used a different key.
|
||||
boolean installResult = installPackage(launchInfo, remotePath, device);
|
||||
|
||||
|
||||
// now we delete the app we sync'ed
|
||||
try {
|
||||
device.executeShellCommand("rm " + remotePath, new MultiLineReceiver() { //$NON-NLS-1$
|
||||
@@ -890,13 +890,13 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
"Failed to delete temporary package: %1$s", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// if the installation succeeded, we register it.
|
||||
if (installResult) {
|
||||
ApkInstallManager.getInstance().registerInstallation(
|
||||
launchInfo.getProject(), device);
|
||||
}
|
||||
|
||||
|
||||
return installResult;
|
||||
}
|
||||
|
||||
@@ -911,8 +911,8 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
/**
|
||||
* For the current launchInfo, create additional DelayedLaunchInfo that should be used to
|
||||
* sync APKs that we are dependent on to the device.
|
||||
*
|
||||
* @param launchInfo the original launch info that we want to find the
|
||||
*
|
||||
* @param launchInfo the original launch info that we want to find the
|
||||
* @return a list of DelayedLaunchInfo (may be empty if no dependencies were found or error)
|
||||
*/
|
||||
public List<DelayedLaunchInfo> getDependenciesLaunchInfo(DelayedLaunchInfo launchInfo) {
|
||||
@@ -928,7 +928,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(), e);
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
|
||||
// Get all projects that this depends on
|
||||
List<IJavaProject> androidProjectList;
|
||||
try {
|
||||
@@ -938,7 +938,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(), e);
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
|
||||
// for each project, parse manifest and create launch information
|
||||
for (IJavaProject androidProject : androidProjectList) {
|
||||
// Parse the Manifest to get various required information
|
||||
@@ -950,35 +950,35 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
true /* gatherData */, false /* markErrors */);
|
||||
} catch (CoreException e) {
|
||||
AdtPlugin.printErrorToConsole(
|
||||
launchInfo.getProject(),
|
||||
String.format("Error parsing manifest of %s",
|
||||
launchInfo.getProject(),
|
||||
String.format("Error parsing manifest of %s",
|
||||
androidProject.getElementName()));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Get the APK location (can return null)
|
||||
IFile apk = ProjectHelper.getApplicationPackage(androidProject.getProject());
|
||||
if (apk == null) {
|
||||
// getApplicationPackage will have logged an error message
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Create new launchInfo as an hybrid between parent and dependency information
|
||||
DelayedLaunchInfo delayedLaunchInfo = new DelayedLaunchInfo(
|
||||
androidProject.getProject(),
|
||||
androidProject.getProject(),
|
||||
manifestParser.getPackage(),
|
||||
manifestParser.getPackage(),
|
||||
launchInfo.getLaunchAction(),
|
||||
apk,
|
||||
manifestParser.getDebuggable(),
|
||||
manifestParser.getApiLevelRequirement(),
|
||||
launchInfo.getLaunch(),
|
||||
launchInfo.getLaunchAction(),
|
||||
apk,
|
||||
manifestParser.getDebuggable(),
|
||||
manifestParser.getApiLevelRequirement(),
|
||||
launchInfo.getLaunch(),
|
||||
launchInfo.getMonitor());
|
||||
|
||||
|
||||
// Add to the list
|
||||
dependencies.add(delayedLaunchInfo);
|
||||
}
|
||||
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
@@ -998,7 +998,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
|
||||
try {
|
||||
String result = doInstall(launchInfo, remotePath, device, false /* reinstall */);
|
||||
|
||||
|
||||
/* For now we force to retry the install (after uninstalling) because there's no
|
||||
* other way around it: adb install does not want to update a package w/o uninstalling
|
||||
* the old one first!
|
||||
@@ -1008,7 +1008,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
} catch (IOException e) {
|
||||
// do nothing, we'll return false
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1100,7 +1100,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* @param device the device on which to install the application.
|
||||
* @param launchInfo the {@link DelayedLaunchInfo}.
|
||||
* @return a {@link String} with an error code, or <code>null</code> if success.
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private String doUninstall(IDevice device, DelayedLaunchInfo launchInfo) throws IOException {
|
||||
@@ -1114,7 +1114,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
return receiver.getSuccess();
|
||||
}
|
||||
|
||||
@@ -1124,9 +1124,9 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* @param launchInfo the {@link DelayedLaunchInfo}.
|
||||
* @param remotePath the path of the application package in the device tmp folder.
|
||||
* @param device the device on which to install the application.
|
||||
* @param reinstall
|
||||
* @param reinstall
|
||||
* @return a {@link String} with an error code, or <code>null</code> if success.
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
private String doInstall(DelayedLaunchInfo launchInfo, final String remotePath,
|
||||
final IDevice device, boolean reinstall) throws IOException {
|
||||
@@ -1139,15 +1139,15 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
} catch (IOException e) {
|
||||
String msg = String.format(
|
||||
"Failed to install %1$s on device '%2$s': %3$s",
|
||||
launchInfo.getPackageFile().getName(), device.getSerialNumber(),
|
||||
launchInfo.getPackageFile().getName(), device.getSerialNumber(),
|
||||
e.getMessage());
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
return receiver.getSuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* launches an application on a device or emulator
|
||||
*
|
||||
@@ -1202,24 +1202,24 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
needsWipeData = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// build the command line based on the available parameters.
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
|
||||
list.add(AdtPlugin.getOsAbsoluteEmulator());
|
||||
list.add(FLAG_AVD);
|
||||
list.add(avdToLaunch.getName());
|
||||
|
||||
|
||||
if (config.mNetworkSpeed != null) {
|
||||
list.add(FLAG_NETSPEED);
|
||||
list.add(config.mNetworkSpeed);
|
||||
}
|
||||
|
||||
|
||||
if (config.mNetworkDelay != null) {
|
||||
list.add(FLAG_NETDELAY);
|
||||
list.add(config.mNetworkDelay);
|
||||
}
|
||||
|
||||
|
||||
if (needsWipeData) {
|
||||
list.add(FLAG_WIPE_DATA);
|
||||
}
|
||||
@@ -1229,7 +1229,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
|
||||
list.addAll(customArgs);
|
||||
|
||||
|
||||
// convert the list into an array for the call to exec.
|
||||
String[] command = list.toArray(new String[list.size()]);
|
||||
|
||||
@@ -1243,7 +1243,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Looks for and returns an existing {@link ILaunchConfiguration} object for a
|
||||
* specified project.
|
||||
@@ -1344,7 +1344,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* <p/>
|
||||
* This is sent from a non UI thread.
|
||||
* @param bridge the new {@link AndroidDebugBridge} object.
|
||||
*
|
||||
*
|
||||
* @see IDebugBridgeChangeListener#bridgeChanged(AndroidDebugBridge)
|
||||
*/
|
||||
public void bridgeChanged(AndroidDebugBridge bridge) {
|
||||
@@ -1358,7 +1358,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
for (DelayedLaunchInfo launchInfo : mWaitingForDebuggerApplications) {
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(),
|
||||
String.format(message,
|
||||
String.format(message,
|
||||
launchInfo.getLaunchAction().getLaunchDescription()));
|
||||
stopLaunch(launchInfo);
|
||||
}
|
||||
@@ -1373,7 +1373,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* <p/>
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
||||
*/
|
||||
public void deviceConnected(Device device) {
|
||||
@@ -1390,7 +1390,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
|
||||
// and move it to the other list
|
||||
mWaitingForReadyEmulatorList.add(launchInfo);
|
||||
|
||||
|
||||
// and tell the user about it
|
||||
AdtPlugin.printToConsole(launchInfo.getProject(),
|
||||
String.format("New emulator found: %1$s", device.getSerialNumber()));
|
||||
@@ -1407,7 +1407,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* <p/>
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -1420,7 +1420,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
for (DelayedLaunchInfo launchInfo : copyList) {
|
||||
if (launchInfo.getDevice() == device) {
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(),
|
||||
String.format(message, device.getSerialNumber(),
|
||||
String.format(message, device.getSerialNumber(),
|
||||
launchInfo.getLaunchAction().getLaunchDescription()));
|
||||
stopLaunch(launchInfo);
|
||||
}
|
||||
@@ -1429,7 +1429,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
for (DelayedLaunchInfo launchInfo : copyList) {
|
||||
if (launchInfo.getDevice() == device) {
|
||||
AdtPlugin.printErrorToConsole(launchInfo.getProject(),
|
||||
String.format(message, device.getSerialNumber(),
|
||||
String.format(message, device.getSerialNumber(),
|
||||
launchInfo.getLaunchAction().getLaunchDescription()));
|
||||
stopLaunch(launchInfo);
|
||||
}
|
||||
@@ -1443,7 +1443,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the device that was updated.
|
||||
* @param changeMask the mask indicating what changed.
|
||||
*
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceChanged(Device, int)
|
||||
*/
|
||||
public void deviceChanged(Device device, int changeMask) {
|
||||
@@ -1460,8 +1460,8 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
* any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
|
||||
* {@link Client#CHANGE_DEBUGGER_INTEREST}, {@link Client#CHANGE_THREAD_MODE},
|
||||
* {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
|
||||
* {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
|
||||
*
|
||||
* {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
|
||||
*
|
||||
* @see IClientChangeListener#clientChanged(Client, int)
|
||||
*/
|
||||
public void clientChanged(final Client client, int changeMask) {
|
||||
@@ -1471,12 +1471,12 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
if (applicationName != null) {
|
||||
IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
|
||||
String home = store.getString(AdtPlugin.PREFS_HOME_PACKAGE);
|
||||
|
||||
|
||||
if (home.equals(applicationName)) {
|
||||
|
||||
|
||||
// looks like home is up, get its device
|
||||
IDevice device = client.getDevice();
|
||||
|
||||
|
||||
// look for application waiting for home
|
||||
synchronized (sListLock) {
|
||||
for (int i = 0; i < mWaitingForReadyEmulatorList.size(); ) {
|
||||
@@ -1484,7 +1484,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
if (launchInfo.getDevice() == device) {
|
||||
// it's match, remove from the list
|
||||
mWaitingForReadyEmulatorList.remove(i);
|
||||
|
||||
|
||||
// We couldn't check earlier the API level of the device
|
||||
// (it's asynchronous when the device boot, and usually
|
||||
// deviceConnected is called before it's queried for its build info)
|
||||
@@ -1496,11 +1496,11 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
stopLaunch(launchInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
AdtPlugin.printToConsole(launchInfo.getProject(),
|
||||
String.format("HOME is up on device '%1$s'",
|
||||
device.getSerialNumber()));
|
||||
|
||||
|
||||
// attempt to sync the new package onto the device.
|
||||
if (syncApp(launchInfo, device)) {
|
||||
// application package is sync'ed, lets attempt to launch it.
|
||||
@@ -1511,7 +1511,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
"Launch canceled!");
|
||||
stopLaunch(launchInfo);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
@@ -1519,7 +1519,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check if it's already waiting for a debugger, and if so we connect to it.
|
||||
if (client.getClientData().getDebuggerConnectionStatus() == ClientData.DEBUGGER_WAITING) {
|
||||
// search for this client in the list;
|
||||
@@ -1533,7 +1533,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if it's not home, it could be an app that is now in debugger mode that we're waiting for
|
||||
// lets check it
|
||||
|
||||
@@ -1567,20 +1567,20 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
applicationName.equals(launchInfo.getDebugPackageName())) {
|
||||
// this is a match. We remove the launch info from the list
|
||||
mWaitingForDebuggerApplications.remove(i);
|
||||
|
||||
|
||||
// and connect the debugger.
|
||||
String msg = String.format(
|
||||
"Attempting to connect debugger to '%1$s' on port %2$d",
|
||||
launchInfo.getDebugPackageName(), client.getDebuggerListenPort());
|
||||
AdtPlugin.printToConsole(launchInfo.getProject(), msg);
|
||||
|
||||
|
||||
new Thread("Debugger Connection") { //$NON-NLS-1$
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (connectRemoteDebugger(
|
||||
client.getDebuggerListenPort(),
|
||||
launchInfo.getLaunch(),
|
||||
launchInfo.getLaunch(),
|
||||
launchInfo.getMonitor()) == false) {
|
||||
return;
|
||||
}
|
||||
@@ -1595,7 +1595,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
launchInfo.getMonitor().done();
|
||||
}
|
||||
}.start();
|
||||
|
||||
|
||||
// we're done processing this client.
|
||||
return;
|
||||
|
||||
@@ -1604,18 +1604,18 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if we get here, we haven't found an app that we were launching, so we look
|
||||
// for opened android projects that contains the app asking for a debugger.
|
||||
// If we find one, we automatically connect to it.
|
||||
IProject project = ProjectHelper.findAndroidProjectByAppName(applicationName);
|
||||
|
||||
|
||||
if (project != null) {
|
||||
debugRunningApp(project, client.getDebuggerListenPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the stderr/stdout outputs of a process and return when the process is done.
|
||||
* Both <b>must</b> be read or the process will block on windows.
|
||||
@@ -1676,7 +1676,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener
|
||||
synchronized (sListLock) {
|
||||
mWaitingForReadyEmulatorList.remove(launchInfo);
|
||||
mWaitingForDebuggerApplications.remove(launchInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ import com.android.ide.eclipse.adt.sdk.Sdk;
|
||||
import com.android.ide.eclipse.adt.wizards.actions.AvdManagerAction;
|
||||
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.avd.AvdManager;
|
||||
import com.android.sdklib.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdklib.internal.avd.AvdManager;
|
||||
import com.android.sdklib.internal.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdkuilib.AvdSelector;
|
||||
import com.android.sdkuilib.AvdSelector.SelectionMode;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
private Table mDeviceTable;
|
||||
private TableViewer mViewer;
|
||||
private AvdSelector mPreferredAvdSelector;
|
||||
|
||||
|
||||
private Image mDeviceImage;
|
||||
private Image mEmulatorImage;
|
||||
private Image mMatchImage;
|
||||
@@ -97,7 +97,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
private Button mDeviceRadioButton;
|
||||
|
||||
private boolean mDisableAvdSelectionChange = false;
|
||||
|
||||
|
||||
/**
|
||||
* Basic Content Provider for a table full of {@link Device} objects. The input is
|
||||
* a {@link AndroidDebugBridge}.
|
||||
@@ -119,7 +119,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A Label Provider for the {@link TableViewer} in {@link DeviceChooserDialog}.
|
||||
@@ -133,7 +133,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return device.isEmulator() ? mEmulatorImage : mDeviceImage;
|
||||
|
||||
|
||||
case 2:
|
||||
// check for compatibility.
|
||||
if (device.isEmulator() == false) { // physical device
|
||||
@@ -233,30 +233,30 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DeviceChooserResponse {
|
||||
private AvdInfo mAvdToLaunch;
|
||||
private IDevice mDeviceToUse;
|
||||
|
||||
|
||||
public void setDeviceToUse(IDevice d) {
|
||||
mDeviceToUse = d;
|
||||
mAvdToLaunch = null;
|
||||
}
|
||||
|
||||
|
||||
public void setAvdToLaunch(AvdInfo avd) {
|
||||
mAvdToLaunch = avd;
|
||||
mDeviceToUse = null;
|
||||
}
|
||||
|
||||
|
||||
public IDevice getDeviceToUse() {
|
||||
return mDeviceToUse;
|
||||
}
|
||||
|
||||
|
||||
public AvdInfo getAvdToLaunch() {
|
||||
return mAvdToLaunch;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DeviceChooserDialog(Shell parent, DeviceChooserResponse response, String packageName,
|
||||
IAndroidTarget projectTarget) {
|
||||
super(parent);
|
||||
@@ -264,7 +264,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
mPackageName = packageName;
|
||||
mProjectTarget = projectTarget;
|
||||
mSdk = Sdk.getCurrent();
|
||||
|
||||
|
||||
loadImages();
|
||||
}
|
||||
|
||||
@@ -278,23 +278,23 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
mNoMatchImage.dispose();
|
||||
mWarningImage.dispose();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
cleanup();
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void cancelPressed() {
|
||||
cleanup();
|
||||
super.cancelPressed();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
Control content = super.createContents(parent);
|
||||
|
||||
|
||||
// this must be called after createContents() has happened so that the
|
||||
// ok button has been created (it's created after the call to createDialogArea)
|
||||
updateDefaultSelection();
|
||||
@@ -302,19 +302,19 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
// set dialog title
|
||||
getShell().setText("Android Device Chooser");
|
||||
|
||||
|
||||
Composite top = new Composite(parent, SWT.NONE);
|
||||
top.setLayout(new GridLayout(1, true));
|
||||
|
||||
Label label = new Label(top, SWT.NONE);
|
||||
label.setText(String.format("Select a device compatible with target %s.",
|
||||
mProjectTarget.getFullName()));
|
||||
|
||||
|
||||
mDeviceRadioButton = new Button(top, SWT.RADIO);
|
||||
mDeviceRadioButton.setText("Choose a running Android device");
|
||||
mDeviceRadioButton.addSelectionListener(new SelectionAdapter() {
|
||||
@@ -330,12 +330,12 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
} else {
|
||||
mResponse.setAvdToLaunch(mPreferredAvdSelector.getSelected());
|
||||
}
|
||||
|
||||
|
||||
enableOkButton();
|
||||
}
|
||||
});
|
||||
mDeviceRadioButton.setSelection(true);
|
||||
|
||||
|
||||
|
||||
// offset the selector from the radio button
|
||||
Composite offsetComp = new Composite(top, SWT.NONE);
|
||||
@@ -345,7 +345,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
layout.marginLeft = 30;
|
||||
offsetComp.setLayout(layout);
|
||||
|
||||
IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
|
||||
IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
|
||||
mDeviceTable = new Table(offsetComp, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
|
||||
GridData gd;
|
||||
mDeviceTable.setLayoutData(gd = new GridData(GridData.FILL_BOTH));
|
||||
@@ -403,7 +403,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Button radio2 = new Button(top, SWT.RADIO);
|
||||
radio2.setText("Launch a new Android Virtual Device");
|
||||
|
||||
@@ -414,7 +414,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
layout.marginRight = layout.marginHeight = 0;
|
||||
layout.marginLeft = 30;
|
||||
offsetComp.setLayout(layout);
|
||||
|
||||
|
||||
mPreferredAvdSelector = new AvdSelector(offsetComp,
|
||||
getNonRunningAvds(false /*reloadAvds*/),
|
||||
mProjectTarget,
|
||||
@@ -448,13 +448,13 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
enableOkButton();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles double-click selection on the AVD selector.
|
||||
*
|
||||
*
|
||||
* Note that the single-click handler will probably already have been called
|
||||
* but the selected item can have changed in between.
|
||||
*
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@@ -465,11 +465,11 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
|
||||
private void loadImages() {
|
||||
IImageLoader ddmsLoader = DdmsPlugin.getImageLoader();
|
||||
Display display = DdmsPlugin.getDisplay();
|
||||
@@ -486,7 +486,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
"emulator.png", ICON_WIDTH, ICON_WIDTH, //$NON-NLS-1$
|
||||
display.getSystemColor(SWT.COLOR_BLUE));
|
||||
}
|
||||
|
||||
|
||||
if (mMatchImage == null) {
|
||||
mMatchImage = ImageHelper.loadImage(adtLoader, display,
|
||||
"match.png", //$NON-NLS-1$
|
||||
@@ -509,7 +509,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a display string representing the state of the device.
|
||||
* @param d the device
|
||||
@@ -532,7 +532,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
* <p/>
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceConnected(Device)
|
||||
*/
|
||||
public void deviceConnected(Device device) {
|
||||
@@ -542,10 +542,10 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
if (mDeviceTable.isDisposed() == false) {
|
||||
// refresh all
|
||||
mViewer.refresh();
|
||||
|
||||
|
||||
// update the selection
|
||||
updateDefaultSelection();
|
||||
|
||||
|
||||
// update the display of AvdInfo (since it's filtered to only display
|
||||
// non running AVD.)
|
||||
refillAvdList(false /*reloadAvds*/);
|
||||
@@ -564,7 +564,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
* <p/>
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the new device.
|
||||
*
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceDisconnected(Device)
|
||||
*/
|
||||
public void deviceDisconnected(Device device) {
|
||||
@@ -577,7 +577,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
* This is sent from a non UI thread.
|
||||
* @param device the device that was updated.
|
||||
* @param changeMask the mask indicating what changed.
|
||||
*
|
||||
*
|
||||
* @see IDeviceChangeListener#deviceChanged(Device, int)
|
||||
*/
|
||||
public void deviceChanged(final Device device, int changeMask) {
|
||||
@@ -588,10 +588,10 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
if (mDeviceTable.isDisposed() == false) {
|
||||
// refresh the device
|
||||
mViewer.refresh(device);
|
||||
|
||||
|
||||
// update the defaultSelection.
|
||||
updateDefaultSelection();
|
||||
|
||||
|
||||
// update the display of AvdInfo (since it's filtered to only display
|
||||
// non running AVD). This is done on deviceChanged because the avd name
|
||||
// of a (emulator) device may be updated as the emulator boots.
|
||||
@@ -612,20 +612,20 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the dialog is in "device" mode (true), or in "avd" mode (false).
|
||||
*/
|
||||
private boolean isDeviceMode() {
|
||||
return mDeviceRadioButton.getSelection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables or disables the OK button of the dialog based on various selections in the dialog.
|
||||
*/
|
||||
private void enableOkButton() {
|
||||
Button okButton = getButton(IDialogConstants.OK_ID);
|
||||
|
||||
|
||||
if (isDeviceMode()) {
|
||||
okButton.setEnabled(mResponse.getDeviceToUse() != null &&
|
||||
mResponse.getDeviceToUse().isOnline());
|
||||
@@ -641,7 +641,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
Button okButton = getButton(IDialogConstants.OK_ID);
|
||||
return okButton.isEnabled();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes the {@link Runnable} in the UI thread.
|
||||
* @param runnable the runnable to execute.
|
||||
@@ -655,7 +655,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
AndroidDebugBridge.removeDeviceChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handleDeviceSelection() {
|
||||
int count = mDeviceTable.getSelectionCount();
|
||||
if (count != 1) {
|
||||
@@ -675,7 +675,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
mResponse.setDeviceToUse(device);
|
||||
enableOkButton();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Look for a default device to select. This is done by looking for the running
|
||||
* clients on each device and finding one similar to the one being launched.
|
||||
@@ -685,19 +685,19 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
private void updateDefaultSelection() {
|
||||
if (mDeviceTable.getSelectionCount() == 0) {
|
||||
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
|
||||
|
||||
|
||||
Device[] devices = bridge.getDevices();
|
||||
|
||||
|
||||
for (Device device : devices) {
|
||||
Client[] clients = device.getClients();
|
||||
|
||||
|
||||
for (Client client : clients) {
|
||||
|
||||
|
||||
if (mPackageName.equals(client.getClientData().getClientDescription())) {
|
||||
// found a match! Select it.
|
||||
mViewer.setSelection(new StructuredSelection(device));
|
||||
handleSelection(device);
|
||||
|
||||
|
||||
// and we're done.
|
||||
return;
|
||||
}
|
||||
@@ -707,13 +707,13 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
|
||||
handleDeviceSelection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the list of {@link AvdInfo} that are not already running in an emulator.
|
||||
*/
|
||||
private AvdInfo[] getNonRunningAvds(boolean reloadAvds) {
|
||||
ArrayList<AvdInfo> list = new ArrayList<AvdInfo>();
|
||||
|
||||
|
||||
// get the full list of Android Virtual Devices
|
||||
if (reloadAvds || mFullAvdList == null) {
|
||||
AvdManager avdManager = mSdk.getAvdManager();
|
||||
@@ -734,25 +734,25 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
list.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list.toArray(new AvdInfo[list.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Refills the AVD list keeping the current selection.
|
||||
*/
|
||||
private void refillAvdList(boolean reloadAvds) {
|
||||
AvdInfo[] array = getNonRunningAvds(reloadAvds);
|
||||
|
||||
|
||||
// save the current selection
|
||||
AvdInfo selected = mPreferredAvdSelector.getSelected();
|
||||
|
||||
|
||||
// disable selection change.
|
||||
mDisableAvdSelectionChange = true;
|
||||
|
||||
|
||||
// set the new list in the selector
|
||||
mPreferredAvdSelector.setAvds(array, mProjectTarget);
|
||||
|
||||
|
||||
// attempt to reselect the proper avd if needed
|
||||
if (selected != null) {
|
||||
if (mPreferredAvdSelector.setSelection(selected) == false) {
|
||||
@@ -762,7 +762,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
|
||||
enableOkButton();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// enable the selection change
|
||||
mDisableAvdSelectionChange = false;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
||||
import com.android.prefs.AndroidLocation.AndroidLocationException;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.avd.AvdManager;
|
||||
import com.android.sdklib.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdklib.internal.avd.AvdManager;
|
||||
import com.android.sdklib.internal.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdkuilib.AvdSelector;
|
||||
import com.android.sdkuilib.AvdSelector.SelectionMode;
|
||||
|
||||
@@ -131,7 +131,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
Font font = parent.getFont();
|
||||
|
||||
|
||||
// reload the AVDs to make sure we are up to date
|
||||
try {
|
||||
Sdk.getCurrent().getAvdManager().reloadAvds();
|
||||
@@ -150,7 +150,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
|
||||
|
||||
GridData gd;
|
||||
GridLayout layout;
|
||||
|
||||
|
||||
// radio button for the target mode
|
||||
Group targetModeGroup = new Group(topComp, SWT.NONE);
|
||||
targetModeGroup.setText("Deployment Target Selection Mode");
|
||||
@@ -175,7 +175,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateLaunchConfigurationDialog();
|
||||
|
||||
|
||||
boolean auto = mAutoTargetButton.getSelection();
|
||||
mPreferredAvdSelector.setEnabled(auto);
|
||||
mPreferredAvdLabel.setEnabled(auto);
|
||||
@@ -285,7 +285,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// custom command line option for emulator
|
||||
Label l = new Label(mEmulatorOptionsGroup, SWT.NONE);
|
||||
l.setText("Additional Emulator Command Line Options");
|
||||
@@ -316,12 +316,12 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
|
||||
return DdmsPlugin.getImageLoader().loadImage("emulator.png", null); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateAvdList(AvdManager avdManager) {
|
||||
if (avdManager == null) {
|
||||
avdManager = Sdk.getCurrent().getAvdManager();
|
||||
}
|
||||
|
||||
|
||||
AvdInfo[] avds = null;
|
||||
// no project? we don't want to display any "compatible" AVDs.
|
||||
if (avdManager != null && mProjectTarget != null) {
|
||||
@@ -346,7 +346,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
|
||||
}
|
||||
mAutoTargetButton.setSelection(mode.getValue());
|
||||
mManualTargetButton.setSelection(!mode.getValue());
|
||||
|
||||
|
||||
// look for the project name to get its target.
|
||||
String stringValue = "";
|
||||
try {
|
||||
@@ -487,7 +487,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
|
||||
LaunchConfigDelegate.DEFAULT_WIPE_DATA);
|
||||
configuration.setAttribute(LaunchConfigDelegate.ATTR_NO_BOOT_ANIM,
|
||||
LaunchConfigDelegate.DEFAULT_NO_BOOT_ANIM);
|
||||
|
||||
|
||||
IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
|
||||
String emuOptions = store.getString(AdtPlugin.PREFS_EMU_OPTIONS);
|
||||
configuration.setAttribute(LaunchConfigDelegate.ATTR_COMMANDLINE, emuOptions);
|
||||
|
||||
@@ -26,10 +26,10 @@ import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.ISdkLog;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.android.sdklib.SdkManager;
|
||||
import com.android.sdklib.avd.AvdManager;
|
||||
import com.android.sdklib.project.ApkConfigurationHelper;
|
||||
import com.android.sdklib.project.ProjectProperties;
|
||||
import com.android.sdklib.project.ProjectProperties.PropertyType;
|
||||
import com.android.sdklib.internal.avd.AvdManager;
|
||||
import com.android.sdklib.internal.project.ApkConfigurationHelper;
|
||||
import com.android.sdklib.internal.project.ProjectProperties;
|
||||
import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
@@ -50,10 +50,10 @@ import java.util.Map;
|
||||
/**
|
||||
* Central point to load, manipulate and deal with the Android SDK. Only one SDK can be used
|
||||
* at the same time.
|
||||
*
|
||||
*
|
||||
* To start using an SDK, call {@link #loadSdk(String)} which returns the instance of
|
||||
* the Sdk object.
|
||||
*
|
||||
*
|
||||
* To get the list of platforms or add-ons present in the SDK, call {@link #getTargets()}.
|
||||
*/
|
||||
public class Sdk implements IProjectListener {
|
||||
@@ -64,12 +64,12 @@ public class Sdk implements IProjectListener {
|
||||
|
||||
private final HashMap<IProject, IAndroidTarget> mProjectTargetMap =
|
||||
new HashMap<IProject, IAndroidTarget>();
|
||||
private final HashMap<IAndroidTarget, AndroidTargetData> mTargetDataMap =
|
||||
private final HashMap<IAndroidTarget, AndroidTargetData> mTargetDataMap =
|
||||
new HashMap<IAndroidTarget, AndroidTargetData>();
|
||||
private final HashMap<IProject, Map<String, String>> mProjectApkConfigMap =
|
||||
new HashMap<IProject, Map<String, String>>();
|
||||
new HashMap<IProject, Map<String, String>>();
|
||||
private final String mDocBaseUrl;
|
||||
|
||||
|
||||
/**
|
||||
* Classes implementing this interface will receive notification when targets are changed.
|
||||
*/
|
||||
@@ -78,14 +78,14 @@ public class Sdk implements IProjectListener {
|
||||
* Sent when project has its target changed.
|
||||
*/
|
||||
void onProjectTargetChange(IProject changedProject);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the targets are loaded (either the SDK finished loading when Eclipse starts,
|
||||
* or the SDK is changed).
|
||||
*/
|
||||
void onTargetsLoaded();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads an SDK and returns an {@link Sdk} object if success.
|
||||
* @param sdkLocation the OS path to the SDK.
|
||||
@@ -102,7 +102,7 @@ public class Sdk implements IProjectListener {
|
||||
if (errorFormat != null) {
|
||||
logMessages.add(String.format("Error: " + errorFormat, arg));
|
||||
}
|
||||
|
||||
|
||||
if (throwable != null) {
|
||||
logMessages.add(throwable.getMessage());
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class Sdk implements IProjectListener {
|
||||
public void warning(String warningFormat, Object... arg) {
|
||||
logMessages.add(String.format("Warning: " + warningFormat, arg));
|
||||
}
|
||||
|
||||
|
||||
public void printf(String msgFormat, Object... arg) {
|
||||
logMessages.add(String.format(msgFormat, arg));
|
||||
}
|
||||
@@ -145,18 +145,18 @@ public class Sdk implements IProjectListener {
|
||||
public static Sdk getCurrent() {
|
||||
return sCurrentSdk;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the location (OS path) of the current SDK.
|
||||
*/
|
||||
public String getSdkLocation() {
|
||||
return mManager.getLocation();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the URL to the local documentation.
|
||||
* Can return null if no documentation is found in the current SDK.
|
||||
*
|
||||
*
|
||||
* @return A file:// URL on the local documentation folder if it exists or null.
|
||||
*/
|
||||
public String getDocumentationBaseUrl() {
|
||||
@@ -169,20 +169,20 @@ public class Sdk implements IProjectListener {
|
||||
public IAndroidTarget[] getTargets() {
|
||||
return mManager.getTargets();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a target from a hash that was generated by {@link IAndroidTarget#hashString()}.
|
||||
*
|
||||
*
|
||||
* @param hash the {@link IAndroidTarget} hash string.
|
||||
* @return The matching {@link IAndroidTarget} or null.
|
||||
*/
|
||||
public IAndroidTarget getTargetFromHashString(String hash) {
|
||||
return mManager.getTargetFromHashString(hash);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a new target and a new list of Apk configuration for a given project.
|
||||
*
|
||||
*
|
||||
* @param project the project to receive the new apk configurations
|
||||
* @param target The new target to set, or <code>null</code> to not change the current target.
|
||||
* @param apkConfigMap a map of apk configurations. The map contains (name, filter) where name
|
||||
@@ -212,21 +212,21 @@ public class Sdk implements IProjectListener {
|
||||
if (target != previousTarget) {
|
||||
// save the target hash string in the project persistent property
|
||||
properties.setAndroidTarget(target);
|
||||
|
||||
|
||||
// put it in a local map for easy access.
|
||||
mProjectTargetMap.put(project, target);
|
||||
|
||||
|
||||
resolveProject = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (apkConfigMap != null) {
|
||||
// save the apk configs in the project persistent property
|
||||
cleanProject = ApkConfigurationHelper.setConfigs(properties, apkConfigMap);
|
||||
|
||||
// put it in a local map for easy access.
|
||||
mProjectApkConfigMap.put(project, apkConfigMap);
|
||||
|
||||
|
||||
compileProject = true;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public class Sdk implements IProjectListener {
|
||||
AdtPlugin.log(e, "Failed to save default.properties for project '%s'",
|
||||
project.getName());
|
||||
}
|
||||
|
||||
|
||||
if (resolveProject) {
|
||||
// force a resolve of the project by updating the classpath container.
|
||||
IJavaProject javaProject = JavaCore.create(project);
|
||||
@@ -258,14 +258,14 @@ public class Sdk implements IProjectListener {
|
||||
new IJavaProject[] { javaProject });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// finally, update the opened editors.
|
||||
if (resolveProject) {
|
||||
AdtPlugin.getDefault().updateTargetListener(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@link IAndroidTarget} object associated with the given {@link IProject}.
|
||||
*/
|
||||
@@ -284,7 +284,7 @@ public class Sdk implements IProjectListener {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parses the project properties and returns the hash string uniquely identifying the
|
||||
@@ -294,7 +294,7 @@ public class Sdk implements IProjectListener {
|
||||
* the root folder of the project.
|
||||
* <p/>The returned string is equivalent to the return of {@link IAndroidTarget#hashString()}.
|
||||
* @param project The project for which to return the target hash string.
|
||||
* @param sdkStorage The sdk in which to store the Apk Configs. Can be null.
|
||||
* @param sdkStorage The sdk in which to store the Apk Configs. Can be null.
|
||||
* @return the hash string or null if the project does not have a target set.
|
||||
*/
|
||||
private static String loadProjectProperties(IProject project, Sdk sdkStorage) {
|
||||
@@ -311,18 +311,18 @@ public class Sdk implements IProjectListener {
|
||||
project.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (sdkStorage != null) {
|
||||
Map<String, String> configMap = ApkConfigurationHelper.getConfigs(properties);
|
||||
|
||||
|
||||
if (configMap != null) {
|
||||
sdkStorage.mProjectApkConfigMap.put(project, configMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return properties.getProperty(ProjectProperties.PROPERTY_TARGET);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash string uniquely identifying the target of a project.
|
||||
* <p/>
|
||||
@@ -352,10 +352,10 @@ public class Sdk implements IProjectListener {
|
||||
properties = ProjectProperties.create(project.getLocation().toOSString(),
|
||||
PropertyType.DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
// add/change the target hash string.
|
||||
properties.setProperty(ProjectProperties.PROPERTY_TARGET, targetHashString);
|
||||
|
||||
|
||||
// and rewrite the file.
|
||||
try {
|
||||
properties.save();
|
||||
@@ -372,7 +372,7 @@ public class Sdk implements IProjectListener {
|
||||
return mTargetDataMap.get(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the configuration map for a given project.
|
||||
* <p/>The Map key are name to be used in the apk filename, while the values are comma separated
|
||||
@@ -381,7 +381,7 @@ public class Sdk implements IProjectListener {
|
||||
public Map<String, String> getProjectApkConfigs(IProject project) {
|
||||
return mProjectApkConfigMap.get(project);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@link AvdManager}. If the AvdManager failed to parse the AVD folder, this could
|
||||
* be <code>null</code>.
|
||||
@@ -389,15 +389,15 @@ public class Sdk implements IProjectListener {
|
||||
public AvdManager getAvdManager() {
|
||||
return mAvdManager;
|
||||
}
|
||||
|
||||
|
||||
private Sdk(SdkManager manager, AvdManager avdManager) {
|
||||
mManager = manager;
|
||||
mAvdManager = avdManager;
|
||||
|
||||
|
||||
// listen to projects closing
|
||||
ResourceMonitor monitor = ResourceMonitor.getMonitor();
|
||||
monitor.addProjectListener(this);
|
||||
|
||||
|
||||
// pre-compute some paths
|
||||
mDocBaseUrl = getDocumentationBaseUrl(mManager.getLocation() +
|
||||
SdkConstants.OS_SDK_DOCS_FOLDER);
|
||||
@@ -409,17 +409,17 @@ public class Sdk implements IProjectListener {
|
||||
private void dispose() {
|
||||
ResourceMonitor.getMonitor().removeProjectListener(this);
|
||||
}
|
||||
|
||||
|
||||
void setTargetData(IAndroidTarget target, AndroidTargetData data) {
|
||||
synchronized (mTargetDataMap) {
|
||||
mTargetDataMap.put(target, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the URL to the local documentation.
|
||||
* Can return null if no documentation is found in the current SDK.
|
||||
*
|
||||
*
|
||||
* @param osDocsPath Path to the documentation folder in the current SDK.
|
||||
* The folder may not actually exist.
|
||||
* @return A file:// URL on the local documentation folder if it exists or null.
|
||||
@@ -434,12 +434,12 @@ public class Sdk implements IProjectListener {
|
||||
// Windows, namely "C:\\foo" is converted to "file:/C:/foo" instead of
|
||||
// "file:///C:/foo" (i.e. there should be 3 / after "file:"). So we'll
|
||||
// do the correct thing manually.
|
||||
|
||||
|
||||
String path = f.getAbsolutePath();
|
||||
if (File.separatorChar != '/') {
|
||||
path = path.replace(File.separatorChar, '/');
|
||||
}
|
||||
|
||||
|
||||
// For some reason the URL class doesn't add the mandatory "//" after
|
||||
// the "file:" protocol name, so it has to be hacked into the path.
|
||||
URL url = new URL("file", null, "//" + path); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -467,7 +467,7 @@ public class Sdk implements IProjectListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now remove the project for the maps.
|
||||
mProjectTargetMap.remove(project);
|
||||
mProjectApkConfigMap.remove(project);
|
||||
|
||||
@@ -24,8 +24,8 @@ import com.android.prefs.AndroidLocation;
|
||||
import com.android.prefs.AndroidLocation.AndroidLocationException;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.ISdkLog;
|
||||
import com.android.sdklib.avd.AvdManager;
|
||||
import com.android.sdklib.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdklib.internal.avd.AvdManager;
|
||||
import com.android.sdklib.internal.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdkuilib.AvdSelector;
|
||||
import com.android.sdkuilib.AvdSelector.SelectionMode;
|
||||
|
||||
@@ -67,7 +67,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
private HashSet<String> mKnownAvdNames = new HashSet<String>();
|
||||
private TreeMap<String, IAndroidTarget> mCurrentTargets = new TreeMap<String, IAndroidTarget>();
|
||||
private ITargetChangeListener mSdkTargetChangeListener;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new {@link AvdManagerListPage}.
|
||||
* <p/>
|
||||
@@ -80,9 +80,9 @@ class AvdManagerListPage extends WizardPage {
|
||||
|
||||
/**
|
||||
* Called by the parent Wizard to create the UI for this Wizard Page.
|
||||
*
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
@@ -108,7 +108,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
reloadTargetCombo();
|
||||
validatePage();
|
||||
}
|
||||
|
||||
|
||||
private void registerSdkChangeListener() {
|
||||
|
||||
mSdkTargetChangeListener = new ITargetChangeListener() {
|
||||
@@ -123,9 +123,9 @@ class AvdManagerListPage extends WizardPage {
|
||||
reloadTargetCombo();
|
||||
validatePage();
|
||||
}
|
||||
};
|
||||
};
|
||||
AdtPlugin.getDefault().addTargetListener(mSdkTargetChangeListener);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,7 +134,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
AdtPlugin.getDefault().removeTargetListener(mSdkTargetChangeListener);
|
||||
mSdkTargetChangeListener = null;
|
||||
}
|
||||
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
final Composite grid2 = new Composite(parent, SWT.NONE);
|
||||
grid2.setLayout(new GridLayout(2, false /*makeColumnsEqualWidth*/));
|
||||
grid2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
|
||||
Label label = new Label(grid2, SWT.NONE);
|
||||
label.setText("List of existing Android Virtual Devices:");
|
||||
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
|
||||
@@ -178,12 +178,12 @@ class AvdManagerListPage extends WizardPage {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the "Create" group
|
||||
*/
|
||||
private void createCreateGroup(Composite parent) {
|
||||
|
||||
|
||||
Group grid = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||
grid.setLayout(new GridLayout(4, false /*makeColumnsEqualWidth*/));
|
||||
grid.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
@@ -194,14 +194,14 @@ class AvdManagerListPage extends WizardPage {
|
||||
|
||||
Label label = new Label(grid, SWT.NONE);
|
||||
label.setText("Name");
|
||||
|
||||
|
||||
mCreateName = new Text(grid, SWT.BORDER);
|
||||
mCreateName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
mCreateName.addModifyListener(new CreateNameModifyListener());
|
||||
|
||||
label = new Label(grid, SWT.NONE);
|
||||
label.setText("Target");
|
||||
|
||||
|
||||
mCreateTargetCombo = new Combo(grid, SWT.READ_ONLY | SWT.DROP_DOWN);
|
||||
mCreateTargetCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
mCreateTargetCombo.addSelectionListener(new SelectionAdapter() {
|
||||
@@ -210,30 +210,30 @@ class AvdManagerListPage extends WizardPage {
|
||||
super.widgetSelected(e);
|
||||
reloadSkinCombo();
|
||||
validatePage();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// second line
|
||||
|
||||
|
||||
label = new Label(grid, SWT.NONE);
|
||||
label.setText("SDCard");
|
||||
|
||||
|
||||
ValidateListener validateListener = new ValidateListener();
|
||||
|
||||
|
||||
mCreateSdCard = new Text(grid, SWT.BORDER);
|
||||
mCreateSdCard.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
mCreateSdCard.addModifyListener(validateListener);
|
||||
|
||||
label = new Label(grid, SWT.NONE);
|
||||
label.setText("Skin");
|
||||
|
||||
|
||||
mCreateSkinCombo = new Combo(grid, SWT.READ_ONLY | SWT.DROP_DOWN);
|
||||
mCreateSkinCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
|
||||
// dummies for alignment
|
||||
label = new Label(grid, SWT.NONE);
|
||||
label = new Label(grid, SWT.NONE);
|
||||
|
||||
label = new Label(grid, SWT.NONE);
|
||||
|
||||
mCreateForce = new Button(grid, SWT.CHECK);
|
||||
mCreateForce.setText("Force");
|
||||
mCreateForce.setEnabled(false);
|
||||
@@ -250,7 +250,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback when the AVD name is changed.
|
||||
* Enables the force checkbox if the name is a duplicate.
|
||||
@@ -268,34 +268,34 @@ class AvdManagerListPage extends WizardPage {
|
||||
validatePage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class ValidateListener extends SelectionAdapter implements ModifyListener {
|
||||
|
||||
public void modifyText(ModifyEvent e) {
|
||||
validatePage();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
super.widgetSelected(e);
|
||||
validatePage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void reloadTargetCombo() {
|
||||
|
||||
|
||||
String selected = null;
|
||||
int index = mCreateTargetCombo.getSelectionIndex();
|
||||
if (index >= 0) {
|
||||
selected = mCreateTargetCombo.getItem(index);
|
||||
}
|
||||
|
||||
|
||||
mCurrentTargets.clear();
|
||||
mCreateTargetCombo.removeAll();
|
||||
|
||||
boolean found = false;
|
||||
index = -1;
|
||||
|
||||
|
||||
Sdk sdk = Sdk.getCurrent();
|
||||
if (sdk != null) {
|
||||
for (IAndroidTarget target : sdk.getTargets()) {
|
||||
@@ -312,11 +312,11 @@ class AvdManagerListPage extends WizardPage {
|
||||
}
|
||||
|
||||
mCreateTargetCombo.setEnabled(mCurrentTargets.size() > 0);
|
||||
|
||||
|
||||
if (found) {
|
||||
mCreateTargetCombo.select(index);
|
||||
}
|
||||
|
||||
|
||||
reloadSkinCombo();
|
||||
}
|
||||
|
||||
@@ -326,13 +326,13 @@ class AvdManagerListPage extends WizardPage {
|
||||
if (index >= 0) {
|
||||
selected = mCreateSkinCombo.getItem(index);
|
||||
}
|
||||
|
||||
|
||||
mCreateSkinCombo.removeAll();
|
||||
mCreateSkinCombo.setEnabled(false);
|
||||
|
||||
|
||||
index = mCreateTargetCombo.getSelectionIndex();
|
||||
if (index >= 0) {
|
||||
|
||||
|
||||
String targetName = mCreateTargetCombo.getItem(index);
|
||||
|
||||
boolean found = false;
|
||||
@@ -371,7 +371,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
String warning = null;
|
||||
|
||||
|
||||
// Validate AVD name
|
||||
// Validate AVD name
|
||||
String avdName = mCreateName.getText().trim();
|
||||
boolean hasAvdName = avdName.length() > 0;
|
||||
if (hasAvdName && !AvdManager.RE_AVD_NAME.matcher(avdName).matches()) {
|
||||
@@ -379,7 +379,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
"AVD name '%1$s' contains invalid characters. Allowed characters are: %2$s",
|
||||
avdName, AvdManager.CHARS_AVD_NAME);
|
||||
}
|
||||
|
||||
|
||||
// Validate target
|
||||
if (hasAvdName && error == null && mCreateTargetCombo.getSelectionIndex() < 0) {
|
||||
error = "A target must be selected in order to create an AVD.";
|
||||
@@ -388,14 +388,14 @@ class AvdManagerListPage extends WizardPage {
|
||||
// Validate SDCard path or value
|
||||
if (error == null) {
|
||||
String sdName = mCreateSdCard.getText().trim();
|
||||
|
||||
|
||||
if (sdName.length() > 0 &&
|
||||
!new File(sdName).isFile() &&
|
||||
!AvdManager.SDCARD_SIZE_PATTERN.matcher(sdName).matches()) {
|
||||
error = "SD Card must be either a file path or a size such as 128K or 64M.";
|
||||
error = "SD Card must be either a file path or a size such as 128K or 64M.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check for duplicate AVD name
|
||||
if (hasAvdName && error == null) {
|
||||
if (mKnownAvdNames.contains(avdName) && !mCreateForce.getSelection()) {
|
||||
@@ -405,7 +405,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
avdName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Validate the create button
|
||||
boolean can_create = hasAvdName && error == null;
|
||||
if (can_create) {
|
||||
@@ -434,7 +434,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
|
||||
AvdManager avdm = getAvdManager();
|
||||
AvdInfo[] avds = null;
|
||||
|
||||
|
||||
// For the AVD manager to reload the list, in case AVDs where created using the
|
||||
// command line tool.
|
||||
// The AVD manager may not exist yet, typically when loading the SDK.
|
||||
@@ -447,7 +447,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
|
||||
avds = avdm.getValidAvds();
|
||||
}
|
||||
|
||||
|
||||
mAvdSelector.setAvds(avds, null /*filter*/);
|
||||
|
||||
// Keep the list of known AVD names to check if they exist quickly. however
|
||||
@@ -462,7 +462,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mAvdSelector.setSelection(selected);
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
if (avdInfo == null || avdm == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Confirm you want to delete this AVD
|
||||
if (!AdtPlugin.displayPrompt("Delete Android Virtual Device",
|
||||
String.format("Please confirm that you want to delete the Android Virtual Device named '%s'. This operation cannot be reverted.",
|
||||
@@ -485,9 +485,9 @@ class AvdManagerListPage extends WizardPage {
|
||||
}
|
||||
|
||||
SdkLog log = new SdkLog(String.format("Result of deleting AVD '%s':", avdInfo.getName()));
|
||||
|
||||
|
||||
boolean success = avdm.deleteAvd(avdInfo, log);
|
||||
|
||||
|
||||
log.display(success);
|
||||
reloadAvdList();
|
||||
}
|
||||
@@ -514,13 +514,13 @@ class AvdManagerListPage extends WizardPage {
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String skinName = null;
|
||||
if (skinIndex > 0) {
|
||||
// index 0 is the default, we don't use it
|
||||
skinName = mCreateSkinCombo.getItem(skinIndex);
|
||||
}
|
||||
|
||||
|
||||
SdkLog log = new SdkLog(String.format("Result of creating AVD '%s':", avdName));
|
||||
|
||||
File avdFolder;
|
||||
@@ -541,9 +541,9 @@ class AvdManagerListPage extends WizardPage {
|
||||
// takes a logger argument.
|
||||
// TODO revisit this later. See comments in AvdManager#mSdkLog.
|
||||
oldLog = avdm.setSdkLog(log);
|
||||
|
||||
|
||||
AvdInfo avdInfo = avdm.createAvd(
|
||||
avdFolder,
|
||||
avdFolder,
|
||||
avdName,
|
||||
target,
|
||||
skinName,
|
||||
@@ -552,13 +552,13 @@ class AvdManagerListPage extends WizardPage {
|
||||
force);
|
||||
|
||||
success = avdInfo != null;
|
||||
|
||||
|
||||
} finally {
|
||||
avdm.setSdkLog(oldLog);
|
||||
}
|
||||
|
||||
|
||||
log.display(success);
|
||||
|
||||
|
||||
if (success) {
|
||||
// clear the name field on success
|
||||
mCreateName.setText(""); //$NON-NLS-1$
|
||||
@@ -571,19 +571,19 @@ class AvdManagerListPage extends WizardPage {
|
||||
* Collects all log from the AVD action and displays it in a dialog.
|
||||
*/
|
||||
private class SdkLog implements ISdkLog {
|
||||
|
||||
|
||||
final ArrayList<String> logMessages = new ArrayList<String>();
|
||||
private final String mMessage;
|
||||
|
||||
public SdkLog(String message) {
|
||||
mMessage = message;
|
||||
}
|
||||
|
||||
|
||||
public void error(Throwable throwable, String errorFormat, Object... arg) {
|
||||
if (errorFormat != null) {
|
||||
logMessages.add(String.format("Error: " + errorFormat, arg));
|
||||
}
|
||||
|
||||
|
||||
if (throwable != null) {
|
||||
logMessages.add(throwable.getMessage());
|
||||
}
|
||||
@@ -592,7 +592,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
public void warning(String warningFormat, Object... arg) {
|
||||
logMessages.add(String.format("Warning: " + warningFormat, arg));
|
||||
}
|
||||
|
||||
|
||||
public void printf(String msgFormat, Object... arg) {
|
||||
logMessages.add(String.format(msgFormat, arg));
|
||||
}
|
||||
@@ -613,7 +613,7 @@ class AvdManagerListPage extends WizardPage {
|
||||
AdtPlugin.displayError("Android Virtual Devices Manager", sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,8 +31,8 @@ import com.android.ide.eclipse.common.project.AndroidManifestParser;
|
||||
import com.android.ide.eclipse.common.project.AndroidManifestParser.Activity;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.android.sdklib.project.ProjectProperties;
|
||||
import com.android.sdklib.project.ProjectProperties.PropertyType;
|
||||
import com.android.sdklib.internal.project.ProjectProperties;
|
||||
import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
|
||||
import com.android.sdkuilib.SdkTargetSelector;
|
||||
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
|
||||
Reference in New Issue
Block a user