Merge change 22526 into donut

* changes:
  CTS: Fix ContextWrapperTest to not reference hardcoded package names.
diff --git a/tools/host/src/com/android/cts/DeviceManager.java b/tools/host/src/com/android/cts/DeviceManager.java
index dac1a86..9dd292a 100644
--- a/tools/host/src/com/android/cts/DeviceManager.java
+++ b/tools/host/src/com/android/cts/DeviceManager.java
@@ -300,11 +300,11 @@
             // TODO: do we need logic to retry this
             executeCommand("adb -s " + deviceSerialNumber + " reboot");
             // wait to make sure the reboot gets through before we tear down the connection
-            
+
             // TODO: this is flaky, no guarantee device has actually rebooted, host should wait till
             // device goes offline
             Thread.sleep(REBOOT_DELAY);
-            
+
             int attempts = 0;
             boolean deviceConnected = false;
             while (!deviceConnected && (attempts < MAX_ADB_RESTART_ATTEMPTS)) {
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index 3982a68..1f1967f 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -195,17 +195,27 @@
     android_packages = GetSubDirectories(self.test_root)
     for package in android_packages:
       app_package_name = 'android.' + package
+      package_root = os.path.join(self.test_root, package)
+
+      makefile_name = os.path.join(package_root, 'Android.mk')
+      if not os.path.exists(makefile_name):
+        print 'Skipping directory "%s" due to missing Android.mk' % package_root
+        continue
+      makefile_vars = GetMakeFileVars(makefile_name)
+
+      manifest_name = os.path.join(package_root, 'AndroidManifest.xml')
+      if not os.path.exists(manifest_name):
+        print 'Skipping directory "%s" due to missing AndroidManifest.xml' % package_root
+        continue
+      manifest = tools.XmlFile(manifest_name)
+
       self.__LogGenerateDescription(app_package_name)
 
       # Run the description generator doclet to get the test package structure
       # TODO: The Doclet does not currently add all required attributes. Instead of rewriting
       # the document below, additional attributes should be passed to the Doclet as arguments.
       temp_desc = os.path.join(self.temp_dir, 'description.xml')
-      self.RunDescriptionGeneratorDoclet(os.path.join(self.test_root, package), temp_desc)
-
-      makefile_name = os.path.join(self.test_root, package, 'Android.mk')
-      makefile_vars = GetMakeFileVars(makefile_name)
-      manifest = tools.XmlFile(os.path.join(self.test_root, package, 'AndroidManifest.xml'))
+      self.RunDescriptionGeneratorDoclet(package_root, temp_desc)
 
       # obtain missing attribute values from the makefile and manifest
       package_name = makefile_vars['LOCAL_PACKAGE_NAME']