diff options
author | Xavier Ducrohet <xav@android.com> | 2010-11-11 15:49:31 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-11-11 16:19:55 -0800 |
commit | ad11cf8ec9e9efcbfdb42e426a08af5423d28a3f (patch) | |
tree | 2fc1e2e34d88632857f20b3586078ccea39122e8 /eclipse/plugins/com.android.ide.eclipse.ddms | |
parent | d6c3d2b33c09c1fc16605f19689409b818345e3c (diff) | |
download | sdk-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')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml | 2 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.ddms/schema/toolsLocator.exsd (renamed from eclipse/plugins/com.android.ide.eclipse.ddms/schema/adbLocator.exsd) | 12 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java | 84 | ||||
-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 |
4 files changed, 64 insertions, 50 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml index 4fe6786d0..02d570e4c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.2"?> <plugin> - <extension-point id="adbLocator" name="ADB Locator" schema="schema/adbLocator.exsd"/> + <extension-point id="toolsLocator" name="Tools Locator" schema="schema/toolsLocator.exsd"/> <extension-point id="debuggerConnector" name="Debugger Connector" schema="schema/debuggerConnector.exsd"/> <extension-point id="sourceRevealer" name="Source Revealer" schema="schema/sourceRevealer.exsd"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/schema/adbLocator.exsd b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/toolsLocator.exsd index e2c246cc2..da5192172 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/schema/adbLocator.exsd +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/toolsLocator.exsd @@ -3,10 +3,10 @@ <schema targetNamespace="com.android.ide.eclipse.ddms" xmlns="http://www.w3.org/2001/XMLSchema"> <annotation> <appInfo> - <meta.schema plugin="com.android.ide.eclipse.ddms" id="adbLocator" name="ADB Locator"/> + <meta.schema plugin="com.android.ide.eclipse.ddms" id="toolsLocator" name="Tools Locator"/> </appInfo> <documentation> - Extension Point to provide the location of adb to DDMS. + Extension Point to provide the location of SDK Tools to DDMS. </documentation> </annotation> @@ -18,7 +18,7 @@ </documentation> <appInfo> - <meta.attribute kind="java" basedOn=":com.android.ide.eclipse.ddms.IAdbLocator"/> + <meta.attribute kind="java" basedOn=":com.android.ide.eclipse.ddms.IToolsLocator"/> </appInfo> </annotation> </attribute> @@ -76,8 +76,8 @@ <meta.section type="examples"/> </appInfo> <documentation> - <extension point="com.android.ide.eclipse.ddms.adbLocator"> - <locator class="com.android.ide.eclipse.adt.AdbLocator"/> + <extension point="com.android.ide.eclipse.ddms.toolsLocator"> + <locator class="com.android.ide.eclipse.adt.ToolsLocator"/> </extension> </documentation> </annotation> @@ -87,7 +87,7 @@ <meta.section type="apiinfo"/> </appInfo> <documentation> - The class must implement com.android.ide.ddms.IAdbLocator. + The class must implement com.android.ide.ddms.IToolsLocator. </documentation> </annotation> 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(); } |