Make update_prebilts.py fail gracefully on bad sdk zip

Print some useful errors if there are unexpectededly missing,
or double entries in the fetched zip file.

New output when the sdk zip is missing an entry:

Running: /google/data/ro/projects/android/fetch_artifact --bid [..]
Expected 1 file named 'android.jar' in zip sdk-repo-linux-platforms-6302112.zip, found 0
Failed to update platform SDK, aborting

Bug: 151953032
Test: ./update_prebuilts.py -p 6302112
Test: ./update_prebuilts.py -p 6330106
Change-Id: I91d6c3d6a64cfbb993295cc07ab48c9aef5d71e0
diff --git a/update_prebuilts/update_prebuilts.py b/update_prebuilts/update_prebuilts.py
index c99c0c1..a19f790 100755
--- a/update_prebuilts/update_prebuilts.py
+++ b/update_prebuilts/update_prebuilts.py
@@ -664,12 +664,6 @@
                                  os.path.join(extras_dir, 'material-design-x'), extract_res=False)
 
 
-def extract_to(zip_file, filename, parent_path):
-    zip_path = next(filter(lambda path: filename in path, zip_file.namelist()))
-    src_path = zip_file.extract(zip_path)
-    dst_path = path(parent_path, filename)
-    mv(src_path, dst_path)
-
 def update_framework(build_id, sdk_dir):
     api_scope_list = ['public', 'system', 'test']
     if sdk_dir == 'current':
@@ -694,7 +688,15 @@
 
             with zipfile.ZipFile(artifact_path) as zipFile:
                 for filename in ['android.jar', 'framework.aidl', 'uiautomator.jar']:
-                    extract_to(zipFile, filename, target_dir)
+                    matches = list(filter(lambda path: filename in path, zipFile.namelist()))
+                    if len(matches) != 1:
+                        print_e('Expected 1 file named \'%s\' in zip %s, found %d' %
+                                (filename, zipFile.filename, len(matches)))
+                        return False
+                    zip_path = matches[0]
+                    src_path = zipFile.extract(zip_path)
+                    dst_path = path(target_dir, filename)
+                    mv(src_path, dst_path)
 
     return True