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