Add update_prebuilts.py support for BeyondCorp. am: abe16dffa5

Original change: https://googleplex-android-review.googlesource.com/c/platform/prebuilts/sdk/+/14715728

Change-Id: I364891975aa3ec38ae10e348de0f164906c0fe4e
diff --git a/update_prebuilts/update_prebuilts.py b/update_prebuilts/update_prebuilts.py
index e17f1fa..da1821f 100755
--- a/update_prebuilts/update_prebuilts.py
+++ b/update_prebuilts/update_prebuilts.py
@@ -24,6 +24,7 @@
 
 # See go/fetch_artifact for details on this script.
 FETCH_ARTIFACT = '/google/data/ro/projects/android/fetch_artifact'
+FETCH_ARTIFACT_BEYOND_CORP = '/usr/bin/fetch_artifact'
 
 maven_to_make = {
     # AndroidX
@@ -412,12 +413,17 @@
 
 
 def fetch_artifact(target, build_id, artifact_path):
+    global args
     download_to = os.path.join('.', os.path.dirname(artifact_path))
     print('Fetching %s from %s ...' % (artifact_path, target))
     if not os.path.exists(download_to):
         os.makedirs(download_to)
-    fetch_cmd = [FETCH_ARTIFACT, '--bid', str(build_id), '--target', target, artifact_path,
-                 download_to]
+    if args.beyond_corp:
+        fetch_cmd = [FETCH_ARTIFACT_BEYOND_CORP, '--use_oauth2',
+                     '--bid', str(build_id), '--target', target, artifact_path, download_to]
+    else:
+        fetch_cmd = [FETCH_ARTIFACT,
+                     '--bid', str(build_id), '--target', target, artifact_path, download_to]
     print("Running: " + ' '.join(fetch_cmd))
     try:
         subprocess.check_output(fetch_cmd, stderr=subprocess.STDOUT)
@@ -714,6 +720,9 @@
 parser.add_argument(
     '--commit-first', action="store_true",
     help='If specified, then if uncommited changes exist, commit before continuing')
+parser.add_argument(
+    '--beyond-corp', action="store_true",
+    help='If specified, then fetch artifacts with tooling that works on BeyondCorp devices')
 args = parser.parse_args()
 args.file = True
 if not args.source: