1111#include " flutter/impeller/base/validation.h"
1212#include " shell/platform/android/android_rendering_selector.h"
1313
14+ namespace fs = std::filesystem;
15+
1416namespace flutter {
1517
1618namespace {
@@ -38,8 +40,27 @@ static constexpr const char* kBadSocs[] = {
3840 " exynos9825" //
3941};
4042
41- static bool IsDeviceEmulator (std::string_view product_model) {
42- return std::string (product_model).find (" gphone" ) != std::string::npos;
43+ static bool IsDeviceEmulator () {
44+ char property[PROP_VALUE_MAX];
45+
46+ __system_property_get (" ro.hardware" , property);
47+ std::string_view hardware_prop (property);
48+ if (hardware_prop == " goldfish" || hardware_prop == " ranchu" ||
49+ hardware_prop == " qemu" ) {
50+ return true ;
51+ }
52+
53+ __system_property_get (" ro.product.model" , property);
54+ std::string_view model_prop (property);
55+ if (model_prop.find (" gphone" ) != std::string::npos) {
56+ return true ;
57+ }
58+
59+ if (::access (" /dev/qemu_pipe" , F_OK) == 0 ) {
60+ return true ;
61+ }
62+
63+ return false ;
4364}
4465
4566static bool IsKnownBadSOC (std::string_view hardware) {
@@ -64,15 +85,14 @@ GetActualRenderingAPIForImpeller(
6485 // Even if this check returns true, Impeller may determine it cannot use
6586 // Vulkan for some other reason, such as a missing required extension or
6687 // feature. In these cases it will use OpenGLES.
67- char product_model[PROP_VALUE_MAX];
68- __system_property_get (" ro.product.model" , product_model);
69- if (IsDeviceEmulator (product_model)) {
88+ if (IsDeviceEmulator ()) {
7089 // Avoid using Vulkan on known emulators.
7190 return nullptr ;
7291 }
7392
74- __system_property_get (" ro.com.google.clientidbase" , product_model);
75- if (strcmp (product_model, kAndroidHuawei ) == 0 ) {
93+ char property[PROP_VALUE_MAX];
94+ __system_property_get (" ro.com.google.clientidbase" , property);
95+ if (strcmp (property, kAndroidHuawei ) == 0 ) {
7696 // Avoid using Vulkan on Huawei as AHB imports do not
7797 // consistently work.
7898 return nullptr ;
@@ -85,8 +105,8 @@ GetActualRenderingAPIForImpeller(
85105 return nullptr ;
86106 }
87107
88- __system_property_get (" ro.product.board" , product_model );
89- if (IsKnownBadSOC (product_model )) {
108+ __system_property_get (" ro.product.board" , property );
109+ if (IsKnownBadSOC (property )) {
90110 FML_LOG (INFO)
91111 << " Known bad Vulkan driver encountered, falling back to OpenGLES." ;
92112 return nullptr ;
0 commit comments