bisect-kit: support bisect android prebuilt with service account

In order to use service account, please set following two environment
variables:
 - ANDROID_CLOUD_SERVICE_ACCOUNT_EMAIL
   This is the email of service account.
 - ANDROID_CLOUD_SERVICE_ACCOUNT_KEY
   This is the private key of above service account, in p12 format.

BUG=b:122874397
TEST=set environment variables and run ./switch_arc_prebuilt.py $DUT $BUILD_ID

Change-Id: Ia61ece6e9606fb81250623dd884dd2567d654448
Reviewed-on: https://chromium-review.googlesource.com/1412201
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Kuang-che Wu <kcwu@chromium.org>
diff --git a/bisect_kit/android_util.py b/bisect_kit/android_util.py
index 48d0f95..0cd8e3d 100644
--- a/bisect_kit/android_util.py
+++ b/bisect_kit/android_util.py
@@ -140,8 +140,21 @@
     filename: artifact name
     dest: local path to store the fetched artifact
   """
+  service_account_args = []
+  # These arguments are for bisector service and not required for users of
+  # bisect-kit using personal account.
+  if os.environ.get('ANDROID_CLOUD_SERVICE_ACCOUNT_EMAIL'):
+    assert os.environ.get('ANDROID_CLOUD_SERVICE_ACCOUNT_KEY')
+    service_account_args += [
+        '--email',
+        os.environ.get('ANDROID_CLOUD_SERVICE_ACCOUNT_EMAIL'),
+        '--apiary_service_account_private_key_path',
+        os.environ.get('ANDROID_CLOUD_SERVICE_ACCOUNT_KEY'),
+    ]
+
   util.check_call('/google/data/ro/projects/android/fetch_artifact', '--target',
-                  flavor, '--bid', build_id, filename, dest)
+                  flavor, '--bid', build_id, filename, dest,
+                  *service_account_args)
 
 
 def fetch_manifest(android_root, flavor, build_id):