-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Made emulator check more thorough #174731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request enhances the emulator detection logic by making the check in IsDeviceEmulator
more comprehensive. The updated function now inspects the ro.hardware
system property for common emulator values and checks for the existence of /dev/qemu_pipe
, in addition to the existing check for "gphone" in ro.product.model
. The function's signature has been simplified, and call sites have been updated. My review includes a suggestion to use the non-throwing version of std::filesystem::exists
to prevent potential application crashes, as exceptions are disabled in the Flutter engine.
engine/src/flutter/shell/platform/android/android_context_dynamic_impeller.cc
Outdated
Show resolved
Hide resolved
…mic_impeller.cc Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
} | ||
|
||
std::error_code ec; | ||
if (fs::exists("/dev/qemu_pipe", ec)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets stick to fml::IsFile
instead? Handles stuff like directories and you won't have to pull in to boot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exists
seems more apropos to me. It is a weird file and I didn't want to try to figure out if has weird stat
results. I could see it being a symbolic link in some cases 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess thats precisely why I'd rather use our utilities. I don't know how std::filesystem::exists
is implemented. Does it check for sockets, block devices, links? Or should we instead use ::faccessat
and friends. I can look that up in FML. Reading the docs on std::filesystem and they are more handwavy.
Honestly, if you want to just make sure to check for access bool exists = ::access(path, F_OK) == 0;
should help you cast the widest net. This bit in the docs make me worry that it won't consider sockets or block devices and you'll miss something: path corresponds to an existing file or directory
A secondary concern is just different places using different utilities to do the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, I don't want you to spend time figuring out what type of a file/block-device/fifo, etc. it is and I don't trust std::filesystem and its docs to tell me exactly what it checks for. ::access
seems like a good 🤷🏽 approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, sounds good. Moved to access
with F_OK. I ssh'd into the emulator and fwiw that file was a symbolic link on my emulator. I would expect std::filesystem::exists
to return true for a symbolic link, but happy to just do it this way.
fixes #169931
Pre-launch Checklist
//github.com/
).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. 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.