Add Android device name, version, manufacturer to gpu_info_util

The model name, model version, and model manufacturer are easy to expose for
Android via <sys/system_properties.h>. This should be exposed and added to the
angle test framework for easy management of test expectations on different
devices.

Bug: angleproject:3274
Change-Id: I8ee6b8fa66ff7f4d6ee4688b335f2e6ef03baed6
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1529207
Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/gpu_info_util/SystemInfo.h b/src/gpu_info_util/SystemInfo.h
index ac4e50f..c08cc4c 100644
--- a/src/gpu_info_util/SystemInfo.h
+++ b/src/gpu_info_util/SystemInfo.h
@@ -64,11 +64,13 @@
     bool isOptimus       = false;
     bool isAMDSwitchable = false;
 
-    // Only available on Android, when added by the feature support utility
+    // Only available on Android
     std::string machineManufacturer;
 
-    // Only available on macOS
+    // Only available on macOS and Android
     std::string machineModelName;
+
+    // Only available on macOS
     std::string machineModelVersion;
 
     // Only available on Windows, set even on failure.
diff --git a/src/gpu_info_util/SystemInfo_android.cpp b/src/gpu_info_util/SystemInfo_android.cpp
index 552ca40..5a0c545 100644
--- a/src/gpu_info_util/SystemInfo_android.cpp
+++ b/src/gpu_info_util/SystemInfo_android.cpp
@@ -10,6 +10,7 @@
 #include <vulkan/vulkan.h>
 #include "gpu_info_util/SystemInfo_internal.h"
 
+#include <sys/system_properties.h>
 #include <cstring>
 #include <fstream>
 
@@ -110,8 +111,29 @@
     return std::string(&buffer[0], len);
 }
 
+bool GetAndroidSystemProperty(const std::string &propertyName, std::string *value)
+{
+    // PROP_VALUE_MAX from <sys/system_properties.h>
+    std::vector<char> propertyBuf(PROP_VALUE_MAX);
+    int len = __system_property_get(propertyName.c_str(), propertyBuf.data());
+    if (len <= 0)
+    {
+        return false;
+    }
+    *value = std::string(propertyBuf.data());
+    return true;
+}
+
 bool GetSystemInfo(SystemInfo *info)
 {
+    bool isFullyPopulated = true;
+
+    isFullyPopulated =
+        GetAndroidSystemProperty("ro.product.manufacturer", &info->machineManufacturer) &&
+        isFullyPopulated;
+    isFullyPopulated =
+        GetAndroidSystemProperty("ro.product.model", &info->machineModelName) && isFullyPopulated;
+
     // This implementation builds on top of the Vulkan API, but cannot assume the existence of the
     // Vulkan library.  ANGLE can be installed on versions of Android as old as Ice Cream Sandwich.
     // Therefore, we need to use dlopen()/dlsym() in order to see if Vulkan is installed on the
@@ -228,7 +250,7 @@
         gpu.driverDate = "";
     }
 
-    return true;
+    return isFullyPopulated;
 }
 
 }  // namespace angle
diff --git a/src/tests/test_utils/angle_test_instantiate.cpp b/src/tests/test_utils/angle_test_instantiate.cpp
index 1b25efb..c11212a 100644
--- a/src/tests/test_utils/angle_test_instantiate.cpp
+++ b/src/tests/test_utils/angle_test_instantiate.cpp
@@ -131,6 +131,35 @@
 #endif
 }
 
+bool IsAndroidDevice(const std::string &deviceName)
+{
+    if (!IsAndroid())
+    {
+        return false;
+    }
+    SystemInfo *systemInfo = GetTestSystemInfo();
+    if (systemInfo->machineModelName == deviceName)
+    {
+        return true;
+    }
+    return false;
+}
+
+bool IsNexus5X()
+{
+    return IsAndroidDevice("Nexus 5X");
+}
+
+bool IsPixelXL()
+{
+    return IsAndroidDevice("Pixel XL");
+}
+
+bool IsPixel2()
+{
+    return IsAndroidDevice("Pixel 2");
+}
+
 bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters &param)
 {
     VendorID vendorID = systemInfo.gpus[systemInfo.primaryGPUIndex].vendorId;
diff --git a/src/tests/test_utils/angle_test_instantiate.h b/src/tests/test_utils/angle_test_instantiate.h
index fc4c582..c2f6c0a 100644
--- a/src/tests/test_utils/angle_test_instantiate.h
+++ b/src/tests/test_utils/angle_test_instantiate.h
@@ -25,6 +25,11 @@
 bool IsWindows();
 bool IsFuchsia();
 
+// Android devices
+bool IsNexus5X();
+bool IsPixelXL();
+bool IsPixel2();
+
 bool IsPlatformAvailable(const PlatformParameters &param);
 
 // This functions is used to filter which tests should be registered,