Skip to content

Commit 9f2ee69

Browse files
gaaclarkegemini-code-assist[bot]
authored andcommitted
Made emulator check more thorough (flutter#174731)
fixes flutter#169931 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent e4435ba commit 9f2ee69

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

engine/src/flutter/shell/platform/android/android_context_dynamic_impeller.cc

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "flutter/impeller/base/validation.h"
1212
#include "shell/platform/android/android_rendering_selector.h"
1313

14+
namespace fs = std::filesystem;
15+
1416
namespace flutter {
1517

1618
namespace {
@@ -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

4566
static 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

Comments
 (0)