From ad11cf8ec9e9efcbfdb42e426a08af5423d28a3f Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Thu, 11 Nov 2010 15:49:31 -0800 Subject: 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 --- .../com.android.ide.eclipse.ddms/plugin.xml | 2 +- .../schema/adbLocator.exsd | 104 --------------------- .../schema/toolsLocator.exsd | 104 +++++++++++++++++++++ .../com/android/ide/eclipse/ddms/DdmsPlugin.java | 84 +++++++++-------- .../com/android/ide/eclipse/ddms/IAdbLocator.java | 29 ------ .../android/ide/eclipse/ddms/IToolsLocator.java | 41 ++++++++ 6 files changed, 189 insertions(+), 175 deletions(-) delete mode 100644 eclipse/plugins/com.android.ide.eclipse.ddms/schema/adbLocator.exsd create mode 100644 eclipse/plugins/com.android.ide.eclipse.ddms/schema/toolsLocator.exsd delete mode 100644 eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IAdbLocator.java create mode 100644 eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IToolsLocator.java (limited to 'eclipse/plugins/com.android.ide.eclipse.ddms') 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 @@ - + diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/schema/adbLocator.exsd b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/adbLocator.exsd deleted file mode 100644 index e2c246cc2..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/schema/adbLocator.exsd +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - Extension Point to provide the location of adb to DDMS. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8.0.0 - - - - - - - - - <extension point="com.android.ide.eclipse.ddms.adbLocator"> - <locator class="com.android.ide.eclipse.adt.AdbLocator"/> -</extension> - - - - - - - - - The class must implement com.android.ide.ddms.IAdbLocator. - - - - - - - - - - Copyright (C) 2010 The Android Open Source Project - - - - diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/schema/toolsLocator.exsd b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/toolsLocator.exsd new file mode 100644 index 000000000..da5192172 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/toolsLocator.exsd @@ -0,0 +1,104 @@ + + + + + + + + + Extension Point to provide the location of SDK Tools to DDMS. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8.0.0 + + + + + + + + + <extension point="com.android.ide.eclipse.ddms.toolsLocator"> + <locator class="com.android.ide.eclipse.adt.ToolsLocator"/> +</extension> + + + + + + + + + The class must implement com.android.ide.ddms.IToolsLocator. + + + + + + + + + + Copyright (C) 2010 The Android Open Source Project + + + + 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 list = new ArrayList(); + ArrayList list = new ArrayList(); 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/IAdbLocator.java deleted file mode 100644 index c31dfc45e..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IAdbLocator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.ide.eclipse.ddms; - -/** - * Classes which implement this interface provides the location of ADB. - */ -public interface IAdbLocator { - - /** - * Queries the location of ADB - * @return A full OS path to the location of adb. - */ - String getAdbLocation(); -} diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IToolsLocator.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IToolsLocator.java new file mode 100644 index 000000000..5b53db3fb --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IToolsLocator.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.ddms; + +/** + * Classes which implement this interface provides the location of various SDK tools. + */ +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(); +} -- cgit v1.2.3