Merge "Remove the emulator special case from the "adb root" code."
diff --git a/adb/Android.mk b/adb/Android.mk
index fb7a3f3..327591f 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -28,7 +28,7 @@
     -D_XOPEN_SOURCE -D_GNU_SOURCE \
     -fvisibility=hidden \
 
-LIBADB_darwin_SRC_FILES := get_my_path_darwin.c usb_osx.c
+LIBADB_darwin_SRC_FILES := fdevent.cpp get_my_path_darwin.c usb_osx.c
 LIBADB_linux_SRC_FILES := fdevent.cpp get_my_path_linux.c usb_linux.c
 LIBADB_windows_SRC_FILES := get_my_path_windows.c sysdeps_win32.c usb_windows.c
 
@@ -57,6 +57,10 @@
 # this to take effect), this adds the SSL includes to our path.
 LOCAL_STATIC_LIBRARIES := libcrypto_static
 
+ifeq ($(HOST_OS),windows)
+    LOCAL_C_INCLUDES += development/host/windows/usb/api/
+endif
+
 include $(BUILD_HOST_STATIC_LIBRARY)
 
 # adb host tool
@@ -80,7 +84,6 @@
     LOCAL_LDLIBS += -lws2_32 -lgdi32
     USE_SYSDEPS_WIN32 := 1
   endif
-  LOCAL_C_INCLUDES += development/host/windows/usb/api/
 endif
 
 LOCAL_SRC_FILES := \
diff --git a/adb/tests/test_adb.py b/adb/tests/test_adb.py
index 4b3baf3..49ead73 100755
--- a/adb/tests/test_adb.py
+++ b/adb/tests/test_adb.py
@@ -215,15 +215,13 @@
 
 
 class AdbBasic(unittest.TestCase):
-    def test_devices(self):
-        """Get uptime for each device plugged in from /proc/uptime."""
-        dev_list = get_device_list()
-        for device in dev_list:
-            out = call_checked(
-                "adb -s {} shell cat /proc/uptime".format(device))
-            self.assertEqual(len(out.split()), 2)
-            self.assertGreater(float(out.split()[0]), 0.0)
-            self.assertGreater(float(out.split()[1]), 0.0)
+    def test_shell(self):
+        """Check that we can at least cat a file."""
+        adb = AdbWrapper()
+        out = adb.shell("cat /proc/uptime")
+        self.assertEqual(len(out.split()), 2)
+        self.assertGreater(float(out.split()[0]), 0.0)
+        self.assertGreater(float(out.split()[1]), 0.0)
 
     def test_help(self):
         """Make sure we get _something_ out of help."""
@@ -241,14 +239,13 @@
 
     def test_root_unroot(self):
         """Make sure that adb root and adb unroot work, using id(1)."""
-        for device in get_device_list():
-            adb = AdbWrapper(device)
-            adb.root()
-            adb.wait()
-            self.assertEqual("root", adb.shell("id -un").strip())
-            adb.unroot()
-            adb.wait()
-            self.assertEqual("shell", adb.shell("id -un").strip())
+        adb = AdbWrapper()
+        adb.root()
+        adb.wait()
+        self.assertEqual("root", adb.shell("id -un").strip())
+        adb.unroot()
+        adb.wait()
+        self.assertEqual("shell", adb.shell("id -un").strip())
 
 
 class AdbFile(unittest.TestCase):
@@ -257,15 +254,9 @@
     DEVICE_TEMP_DIR = SCRATCH_DIR + "/adb_test_dir"
 
     def test_push(self):
-        """Push a file to all attached devices."""
-        dev_list = get_device_list()
-        for device in dev_list:
-            self.push_with_device(device)
-
-    def push_with_device(self, device):
         """Push a randomly generated file to specified device."""
         kbytes = 512
-        adb = AdbWrapper(device)
+        adb = AdbWrapper()
         with tempfile.NamedTemporaryFile(mode="w") as tmp:
             rand_str = os.urandom(1024 * kbytes)
             tmp.write(rand_str)
@@ -284,15 +275,9 @@
     # TODO: write push directory test.
 
     def test_pull(self):
-        """Pull a file from all attached devices."""
-        dev_list = get_device_list()
-        for device in dev_list:
-            self.pull_with_device(device)
-
-    def pull_with_device(self, device):
         """Pull a randomly generated file from specified device."""
         kbytes = 512
-        adb = AdbWrapper(device)
+        adb = AdbWrapper()
         adb.shell_nocheck("rm -r {}".format(AdbFile.DEVICE_TEMP_FILE))
         try:
             adb.shell("dd if=/dev/urandom of={} bs=1024 count={}".format(
@@ -310,14 +295,8 @@
             adb.shell_nocheck("rm {}".format(AdbFile.DEVICE_TEMP_FILE))
 
     def test_pull_dir(self):
-        """Pull a directory from all attached devices."""
-        dev_list = get_device_list()
-        for device in dev_list:
-            self.pull_dir_with_device(device)
-
-    def pull_dir_with_device(self, device):
         """Pull a randomly generated directory of files from the device."""
-        adb = AdbWrapper(device)
+        adb = AdbWrapper()
         temp_files = {}
         host_dir = None
         try:
@@ -350,15 +329,9 @@
                 os.removedirs(host_dir)
 
     def test_sync(self):
-        """Sync a directory with all attached devices."""
-        dev_list = get_device_list()
-        for device in dev_list:
-            self.sync_dir_with_device(device)
-
-    def sync_dir_with_device(self, device):
         """Sync a randomly generated directory of files to specified device."""
         try:
-            adb = AdbWrapper(device)
+            adb = AdbWrapper()
             temp_files = {}
 
             # create temporary host directory
@@ -373,7 +346,7 @@
                                                 num_files=32)
 
             # clean up any trash on the device
-            adb = AdbWrapper(device, out_dir=base_dir)
+            adb = AdbWrapper(out_dir=base_dir)
             adb.shell_nocheck("rm -r {}".format(AdbFile.DEVICE_TEMP_DIR))
 
             # issue the sync
diff --git a/init/grab-bootchart.sh b/init/grab-bootchart.sh
index 7fe8904..5715862 100755
--- a/init/grab-bootchart.sh
+++ b/init/grab-bootchart.sh
@@ -3,6 +3,8 @@
 # this script is used to retrieve the bootchart log generated
 # by init when compiled with INIT_BOOTCHART=true.
 #
+# All options are passed to adb, for better or for worse.
+#
 # for all details, see //device/system/init/README.BOOTCHART
 #
 TMPDIR=/tmp/android-bootchart
@@ -15,8 +17,9 @@
 FILES="header proc_stat.log proc_ps.log proc_diskstats.log kernel_pacct"
 
 for f in $FILES; do
-    adb pull $LOGROOT/$f $TMPDIR/$f 2>&1 > /dev/null
+    adb "${@}" pull $LOGROOT/$f $TMPDIR/$f 2>&1 > /dev/null
 done
 (cd $TMPDIR && tar -czf $TARBALL $FILES)
-cp -f $TMPDIR/$TARBALL ./$TARBALL
-echo "look at $TARBALL"
+bootchart ${TMPDIR}/${TARBALL}
+gnome-open ${TARBALL%.tgz}.png
+echo "Clean up ${TMPDIR}/ & ./${TARBALL%.tgz}.png when done"
diff --git a/init/readme.txt b/init/readme.txt
index 32eb4ab..9c24220 100644
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -313,9 +313,8 @@
 bootchart command-line utility:
 
   sudo apt-get install pybootchartgui
+  ANDROID_SERIAL=<device serial number>
   $ANDROID_BUILD_TOP/system/core/init/grab-bootchart.sh
-  bootchart ./bootchart.tgz
-  gnome-open bootchart.png
 
 
 Debugging init