[vm] OperatingSystemVersion return Android OS version

OperatingSystemVersion on Android does not return OS version of Android.

Bug: https://github.com/dart-lang/sdk/issues/36625
Change-Id: Ia26bd5443b7eaf541f2c27c4e93d3c07a8613747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100567
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
diff --git a/runtime/bin/platform_android.cc b/runtime/bin/platform_android.cc
index cbe05fd..db61adf 100644
--- a/runtime/bin/platform_android.cc
+++ b/runtime/bin/platform_android.cc
@@ -11,6 +11,7 @@
 #include <signal.h>       // NOLINT
 #include <string.h>       // NOLINT
 #include <sys/resource.h>
+#include <sys/system_properties.h>
 #include <sys/utsname.h>  // NOLINT
 #include <unistd.h>       // NOLINT
 
@@ -96,24 +97,16 @@
 }
 
 const char* Platform::OperatingSystemVersion() {
-  struct utsname info;
-  int ret = uname(&info);
-  if (ret != 0) {
+  char os_version[PROP_VALUE_MAX + 1];
+  int os_version_length =
+      __system_property_get("ro.build.display.id", os_version);
+  if (os_version_length == 0) {
     return NULL;
   }
-  const char* kFormat = "%s %s %s";
-  int len =
-      snprintf(NULL, 0, kFormat, info.sysname, info.release, info.version);
-  if (len <= 0) {
-    return NULL;
-  }
-  char* result = DartUtils::ScopedCString(len + 1);
-  ASSERT(result != NULL);
-  len = snprintf(result, len + 1, kFormat, info.sysname, info.release,
-                 info.version);
-  if (len <= 0) {
-    return NULL;
-  }
+  ASSERT(os_version_length <= PROP_VALUE_MAX);
+  char* result = reinterpret_cast<char*>(
+      Dart_ScopeAllocate((os_version_length + 1) * sizeof(result)));
+  strncpy(result, os_version, (os_version_length + 1));
   return result;
 }