Add support for devserver latestbuild RPC for Android build

Add a new request argument os_type to differentiate requests for android builds
and ChromeOS builds. The value needs to be set to `android` for any request
related to Android build. If the value is not set or has other values, default
to ChromeOS builds.

BUG=chromium:512668
TEST=run devserver locally, and
curl http://localhost:8082/stage?target=shamu-userdebug\&build_id=2040953\&artifacts=test_zip\&branch=git_mnc-release\&os_type=android
curl http://localhost:8082/latestbuild?target=shamu-userdebug\&branch=git_mnc-release\&os_type=android

Change-Id: I32dd118c7c03c5899742cebe437d34b9cef984de
Reviewed-on: https://chromium-review.googlesource.com/308755
Commit-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
diff --git a/android_build.py b/android_build.py
index cae3b3b..597d8bb 100644
--- a/android_build.py
+++ b/android_build.py
@@ -118,3 +118,25 @@
       done = None
       while not done:
         _, done = downloader.next_chunk()
+
+  @classmethod
+  def GetLatestBuildID(cls, target, branch):
+    """Get the latest build ID for the given target and branch.
+
+    Args:
+      branch: branch of the desired build.
+      target: Target of the Android build, e.g., shamu-userdebug.
+
+    Returns:
+      Build id of the latest successful Android build for the given target and
+      branch, e.g., 2155602.
+    """
+    service_obj = cls._GetServiceObject()
+    builds = service_obj.build().list(
+        buildType='submitted', branch=branch, target=target, successful=True,
+        maxResults=1).execute()
+    if not builds or not builds['builds']:
+      raise AndroidBuildFetchError(
+          'Failed to locate build with branch %s and target %s.' %
+          (branch, target))
+    return builds['builds'][0]['buildId']