Commit 4bcba62a by Jonah Ryan-Davis Committed by Commit Bot

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: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 9b050f84
...@@ -64,11 +64,13 @@ struct SystemInfo ...@@ -64,11 +64,13 @@ struct SystemInfo
bool isOptimus = false; bool isOptimus = false;
bool isAMDSwitchable = false; bool isAMDSwitchable = false;
// Only available on Android, when added by the feature support utility // Only available on Android
std::string machineManufacturer; std::string machineManufacturer;
// Only available on macOS // Only available on macOS and Android
std::string machineModelName; std::string machineModelName;
// Only available on macOS
std::string machineModelVersion; std::string machineModelVersion;
// Only available on Windows, set even on failure. // Only available on Windows, set even on failure.
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "gpu_info_util/SystemInfo_internal.h" #include "gpu_info_util/SystemInfo_internal.h"
#include <sys/system_properties.h>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
...@@ -110,8 +111,29 @@ std::string FormatString(const char *fmt, ...) ...@@ -110,8 +111,29 @@ std::string FormatString(const char *fmt, ...)
return std::string(&buffer[0], len); 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 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 // 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. // 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 // Therefore, we need to use dlopen()/dlsym() in order to see if Vulkan is installed on the
...@@ -228,7 +250,7 @@ bool GetSystemInfo(SystemInfo *info) ...@@ -228,7 +250,7 @@ bool GetSystemInfo(SystemInfo *info)
gpu.driverDate = ""; gpu.driverDate = "";
} }
return true; return isFullyPopulated;
} }
} // namespace angle } // namespace angle
...@@ -131,6 +131,35 @@ bool IsFuchsia() ...@@ -131,6 +131,35 @@ bool IsFuchsia()
#endif #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) bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters &param)
{ {
VendorID vendorID = systemInfo.gpus[systemInfo.primaryGPUIndex].vendorId; VendorID vendorID = systemInfo.gpus[systemInfo.primaryGPUIndex].vendorId;
......
...@@ -25,6 +25,11 @@ bool IsOzone(); ...@@ -25,6 +25,11 @@ bool IsOzone();
bool IsWindows(); bool IsWindows();
bool IsFuchsia(); bool IsFuchsia();
// Android devices
bool IsNexus5X();
bool IsPixelXL();
bool IsPixel2();
bool IsPlatformAvailable(const PlatformParameters &param); bool IsPlatformAvailable(const PlatformParameters &param);
// This functions is used to filter which tests should be registered, // This functions is used to filter which tests should be registered,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment