aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-11-11 15:49:31 -0800
committerXavier Ducrohet <xav@android.com>2010-11-11 16:19:55 -0800
commitad11cf8ec9e9efcbfdb42e426a08af5423d28a3f (patch)
tree2fc1e2e34d88632857f20b3586078ccea39122e8 /eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android
parentd6c3d2b33c09c1fc16605f19689409b818345e3c (diff)
downloadsdk-ad11cf8ec9e9efcbfdb42e426a08af5423d28a3f.tar.gz
Change the adbLocation ddms extension to provide more tools location.
Previously DDMS used the adb location to find the location of other tools, but adb moved to a different tool folder. adbLocator extension changed to toolsLocation and provide explicit locations for all the tools DDMS cares about. This way the logic of the tools location is only in ADT instead of being duplicated in DDMS. Change-Id: I87f19c7705cb822dc793264f11e680ba09eb7f40
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java84
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IToolsLocator.java (renamed from eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IAdbLocator.java)16
2 files changed, 57 insertions, 43 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
index 7d2c36ba4..4ce8d00d0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
@@ -18,7 +18,6 @@ package com.android.ide.eclipse.ddms;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.Client;
-import com.android.ddmlib.DdmConstants;
import com.android.ddmlib.DdmPreferences;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.Log;
@@ -256,16 +255,21 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
// get the available adb locators
IConfigurationElement[] elements = findConfigElements(
- "com.android.ide.eclipse.ddms.adbLocator"); //$NON-NLS-1$
+ "com.android.ide.eclipse.ddms.toolsLocator"); //$NON-NLS-1$
- IAdbLocator[] locators = instantiateAdbLocators(elements);
+ IToolsLocator[] locators = instantiateToolsLocators(elements);
- for (IAdbLocator locator : locators) {
+ for (IToolsLocator locator : locators) {
try {
String adbLocation = locator.getAdbLocation();
- if (adbLocation != null) {
+ String traceviewLocation = locator.getTraceViewLocation();
+ String hprofConvLocation = locator.getHprofConvLocation();
+ if (adbLocation != null && traceviewLocation != null &&
+ hprofConvLocation != null) {
// checks if the location is valid.
- if (setAdbLocation(adbLocation)) {
+ if (setToolsLocation(adbLocation, hprofConvLocation,
+ traceviewLocation)) {
+
AndroidDebugBridge.createBridge(sAdbLocation,
true /* forceNewBridge */);
@@ -311,9 +315,9 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
*
* @return an array of all locators found, or an empty array if none were found.
*/
- private IAdbLocator[] instantiateAdbLocators(IConfigurationElement[] configElements)
+ private IToolsLocator[] instantiateToolsLocators(IConfigurationElement[] configElements)
throws CoreException {
- ArrayList<IAdbLocator> list = new ArrayList<IAdbLocator>();
+ ArrayList<IToolsLocator> list = new ArrayList<IToolsLocator>();
if (configElements.length > 0) {
// only use the first one, ignore the others.
@@ -321,12 +325,12 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
// instantiate the clas
Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$
- if (obj instanceof IAdbLocator) {
- list.add((IAdbLocator) obj);
+ if (obj instanceof IToolsLocator) {
+ list.add((IToolsLocator) obj);
}
}
- return list.toArray(new IAdbLocator[list.size()]);
+ return list.toArray(new IToolsLocator[list.size()]);
}
/**
@@ -413,7 +417,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
return sAdbLocation;
}
- public static String getToolsFolder() {
+ public static String getToolsFolder2() {
return sToolsFolder;
}
@@ -424,24 +428,23 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
/**
* Stores the adb location. This returns true if the location is an existing file.
*/
- private static boolean setAdbLocation(String adbLocation) {
- File adb = new File(adbLocation);
- if (adb.isFile()) {
- sAdbLocation = adbLocation;
-
- File toolsFolder = adb.getParentFile();
- sToolsFolder = toolsFolder.getAbsolutePath();
+ private static boolean setToolsLocation(String adbLocation, String hprofConvLocation,
+ String traceViewLocation) {
- File hprofConverter = new File(toolsFolder, DdmConstants.FN_HPROF_CONVERTER);
- sHprofConverter = hprofConverter.getAbsolutePath();
-
- File traceview = new File(toolsFolder, DdmConstants.FN_TRACEVIEW);
- DdmUiPreferences.setTraceviewLocation(traceview.getAbsolutePath());
+ File adb = new File(adbLocation);
+ File hprofConverter = new File(hprofConvLocation);
+ File traceview = new File(traceViewLocation);
- return true;
+ if (adb.isFile() == false || hprofConverter.isFile() == false ||
+ traceview.isFile() == false) {
+ return false;
}
- return false;
+ sAdbLocation = adbLocation;
+ sHprofConverter = hprofConverter.getAbsolutePath();
+ DdmUiPreferences.setTraceviewLocation(traceview.getAbsolutePath());
+
+ return true;
}
/**
@@ -449,21 +452,20 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
* @param adb location of adb
* @param startAdb flag to start adb
*/
- public static void setAdb(String adb, boolean startAdb) {
- if (adb != null) {
- if (setAdbLocation(adb)) {
-
- // starts the server in a thread in case this is blocking.
- if (startAdb) {
- new Thread() {
- @Override
- public void run() {
- // create and start the bridge
- AndroidDebugBridge.createBridge(sAdbLocation,
- false /* forceNewBridge */);
- }
- }.start();
- }
+ public static void setToolsLocation(String adbLocation, boolean startAdb,
+ String hprofConvLocation, String traceViewLocation) {
+
+ if (setToolsLocation(adbLocation, hprofConvLocation, traceViewLocation)) {
+ // starts the server in a thread in case this is blocking.
+ if (startAdb) {
+ new Thread() {
+ @Override
+ public void run() {
+ // create and start the bridge
+ AndroidDebugBridge.createBridge(sAdbLocation,
+ false /* forceNewBridge */);
+ }
+ }.start();
}
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IAdbLocator.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IToolsLocator.java
index c31dfc45e..5b53db3fb 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IAdbLocator.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IToolsLocator.java
@@ -17,13 +17,25 @@
package com.android.ide.eclipse.ddms;
/**
- * Classes which implement this interface provides the location of ADB.
+ * Classes which implement this interface provides the location of various SDK tools.
*/
-public interface IAdbLocator {
+public interface IToolsLocator {
/**
* Queries the location of ADB
* @return A full OS path to the location of adb.
*/
String getAdbLocation();
+
+ /**
+ * Queries the location of Traceview
+ * @return A full OS path to the location of traceview
+ */
+ String getTraceViewLocation();
+
+ /**
+ * Queries the location of hprof-conv
+ * @return A full OS path to the location of hprof-conv.
+ */
+ String getHprofConvLocation();
}