Update AOSP tools

* Share common code
* Make the --aosp-root default to build/aosp in the R8 checkout

Change-Id: Ia76aad590f079b852bfa8f581f73082da571de68
diff --git a/tools/emulator_aosp.py b/tools/emulator_aosp.py
index 90a6000..f63c673 100755
--- a/tools/emulator_aosp.py
+++ b/tools/emulator_aosp.py
@@ -3,34 +3,23 @@
 # for details. All rights reserved. Use of this source code is governed by a
 # BSD-style license that can be found in the LICENSE file.
 
-from os.path import join
-from subprocess import check_call
 import argparse
-import os
 import sys
 
 import utils
-
-AOSP_HELPER_SH = join(utils.REPO_ROOT, 'scripts', 'aosp_helper.sh')
-
-DEFAULT_LUNCH = 'aosp_x86-eng'
+import utils_aosp
 
 def parse_arguments():
   parser = argparse.ArgumentParser(
       description = 'Checkout the AOSP source tree.')
-  parser.add_argument('--aosp-root',
-                      help='Root of the AOSP checkout. ' +
-                           'Defaults to current working directory.',
-                      default=os.getcwd())
-  parser.add_argument('--lunch',
-                      help='Build menu. ' +
-                           'Defaults to ' + DEFAULT_LUNCH + '.',
-                      default=DEFAULT_LUNCH)
+  utils_aosp.add_common_arguments(parser)
   return parser.parse_args()
 
 def emulator_aosp(aosp_root, lunch):
-  check_call([AOSP_HELPER_SH, lunch,
-      'emulator_fg', '-partition-size', '4096', '-wipe-data'], cwd = aosp_root)
+  print "Running AOSP emulator in " + aosp_root
+
+  utils_aosp.run_through_aosp_helper(lunch, ['emulator_fg',
+      '-partition-size', '4096', '-wipe-data'], cwd = aosp_root)
 
 def Main():
   args = parse_arguments()