Make the tools work with the new location of adb.
adb has been moved to the platform-tools folder.
This changes ADT, DDMS, HierarchyViewer which all care
where adb is (to launch it).
Also fixed the local SDK parser of the SDK Updater to find
the platform-tools package.
Change-Id: I3c869159d7b0e0ad9aaea06f376b7ba3e53bfc7f
diff --git a/ddms/app/src/com/android/ddms/UIThread.java b/ddms/app/src/com/android/ddms/UIThread.java
index 9ba1ea0..d9ea3f1 100644
--- a/ddms/app/src/com/android/ddms/UIThread.java
+++ b/ddms/app/src/com/android/ddms/UIThread.java
@@ -455,9 +455,18 @@
ClientData.setMethodProfilingHandler(new MethodProfilingHandler(shell));
// [try to] ensure ADB is running
+ // in the new SDK, adb is in the platform-tools, but when run from the command line
+ // in the Android source tree, then adb is next to ddms.
String adbLocation;
if (ddmsParentLocation != null && ddmsParentLocation.length() != 0) {
- adbLocation = ddmsParentLocation + File.separator + "adb"; //$NON-NLS-1$
+ // check if there's a platform-tools folder
+ File platformTools = new File(new File(ddmsParentLocation).getParent(),
+ "platform-tools"); //$NON-NLS-1$
+ if (platformTools.isDirectory()) {
+ adbLocation = platformTools.getAbsolutePath() + File.separator + "adb"; //$NON-NLS-1$
+ } else {
+ adbLocation = ddmsParentLocation + File.separator + "adb"; //$NON-NLS-1$
+ }
} else {
adbLocation = "adb"; //$NON-NLS-1$
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
index afe04ae..5930635 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
@@ -310,7 +310,7 @@
/** Returns the adb path relative to the sdk folder */
public static String getOsRelativeAdb() {
- return SdkConstants.OS_SDK_TOOLS_FOLDER + SdkConstants.FN_ADB;
+ return SdkConstants.OS_SDK_PLATFORM_TOOLS_FOLDER + SdkConstants.FN_ADB;
}
/** Returns the zipalign path relative to the sdk folder */
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java
index d1a5b8c..b6a1f58 100644
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java
+++ b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java
@@ -47,9 +47,20 @@
@Override
public String getAdbLocation() {
String hvParentLocation = System.getProperty("com.android.hierarchyviewer.bindir"); //$NON-NLS-1$
+
+ // in the new SDK, adb is in the platform-tools, but when run from the command line
+ // in the Android source tree, then adb is next to hierarchyviewer.
if (hvParentLocation != null && hvParentLocation.length() != 0) {
+ // check if there's a platform-tools folder
+ File platformTools = new File(new File(hvParentLocation).getParent(),
+ SdkConstants.FD_PLATFORM_TOOLS);
+ if (platformTools.isDirectory()) {
+ return platformTools.getAbsolutePath() + File.separator + SdkConstants.FN_ADB;
+ }
+
return hvParentLocation + File.separator + SdkConstants.FN_ADB;
}
+
return SdkConstants.FN_ADB;
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
index ebcc0fb..e4a96e5 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
@@ -91,6 +91,13 @@
visited.add(dir);
}
+ dir = new File(osSdkRoot, SdkConstants.FD_PLATFORM_TOOLS);
+ pkg = scanPlatformTools(dir, log);
+ if (pkg != null) {
+ packages.add(pkg);
+ visited.add(dir);
+ }
+
File samplesRoot = new File(osSdkRoot, SdkConstants.FD_SAMPLES);
// for platforms, add-ons and samples, rely on the SdkManager parser
@@ -229,18 +236,17 @@
Properties props = parseProperties(new File(toolFolder, SdkConstants.FN_SOURCE_PROP));
// We're not going to check that all tools are present. At the very least
- // we should expect to find adb, android and an emulator adapted to the current OS.
+ // we should expect to find android and an emulator adapted to the current OS.
Set<String> names = new HashSet<String>();
for (File file : toolFolder.listFiles()) {
names.add(file.getName());
}
- if (!names.contains(SdkConstants.FN_ADB) ||
- !names.contains(SdkConstants.androidCmdName()) ||
+ if (!names.contains(SdkConstants.androidCmdName()) ||
!names.contains(SdkConstants.FN_EMULATOR)) {
return null;
}
- // Create are package. use the properties if we found any.
+ // Create our package. use the properties if we found any.
try {
ToolPackage pkg = new ToolPackage(
null, //source
@@ -262,6 +268,49 @@
}
/**
+ * Try to find a platform-tools package at the given location.
+ * Returns null if not found.
+ */
+ private Package scanPlatformTools(File platformToolsFolder, ISdkLog log) {
+ // Can we find some properties?
+ Properties props = parseProperties(new File(platformToolsFolder,
+ SdkConstants.FN_SOURCE_PROP));
+
+ // We're not going to check that all tools are present. At the very least
+ // we should expect to find adb, aidl, aapt and dx (adapted to the current OS).
+ Set<String> names = new HashSet<String>();
+ for (File file : platformToolsFolder.listFiles()) {
+ names.add(file.getName());
+ }
+ if (!names.contains(SdkConstants.FN_ADB) ||
+ !names.contains(SdkConstants.FN_AAPT) ||
+ !names.contains(SdkConstants.FN_AIDL) ||
+ !names.contains(SdkConstants.FN_DX)) {
+ return null;
+ }
+
+ // Create our package. use the properties if we found any.
+ try {
+ PlatformToolPackage pkg = new PlatformToolPackage(
+ null, //source
+ props, //properties
+ 0, //revision
+ null, //license
+ "Platform Tools", //description
+ null, //descUrl
+ Os.getCurrentOs(), //archiveOs
+ Arch.getCurrentArch(), //archiveArch
+ platformToolsFolder.getPath() //archiveOsPath
+ );
+
+ return pkg;
+ } catch (Exception e) {
+ log.error(e, null);
+ }
+ return null;
+ }
+
+ /**
* Try to find a docs package at the given location.
* Returns null if not found.
*/
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/AdbWrapper.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/AdbWrapper.java
index cb553d1..241f30f 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/AdbWrapper.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/AdbWrapper.java
@@ -50,7 +50,8 @@
if (!osSdkPath.endsWith(File.separator)) {
osSdkPath += File.separator;
}
- mAdbOsLocation = osSdkPath + SdkConstants.OS_SDK_TOOLS_FOLDER + SdkConstants.FN_ADB;
+ mAdbOsLocation = osSdkPath + SdkConstants.OS_SDK_PLATFORM_TOOLS_FOLDER
+ + SdkConstants.FN_ADB;
}
private void display(String format, Object...args) {