Uh oh!
There was an error while loading. Please reload this page.
Fix AdbRunner AVD detection: use getprop first, skip offline emulators - #312
Conversation
754bc93 to
994314fCompareThere was a problem hiding this comment.
Pull request overview
Improves Xamarin.Android.Tools.AndroidSdk’s AdbRunner emulator AVD detection to better handle modern emulator behavior and avoid slow/failed AVD queries while emulators are offline (e.g., during boot polling).
Changes:
- Prefer
adb shell getprop ro.boot.qemu.avd_namefor emulator AVD name detection, with fallback toadb emu avd name. - Skip AVD-name probing for offline emulators in
ListDevicesAsync(and optionally log the skip). - Add/extend unit tests covering the detection order and offline-emulator handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| tests/Xamarin.Android.Tools.AndroidSdk-Tests/AdbRunnerTests.cs | Adds new tests using a fake adb implementation to validate AVD detection and offline handling. |
| src/Xamarin.Android.Tools.AndroidSdk/Runners/AdbRunner.cs | Updates AVD name query order; skips offline emulators; adds optional logger parameter. |
| src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | Updates public API entry for the AdbRunner constructor signature change. |
| src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/net10.0/PublicAPI.Unshipped.txt | Updates public API entry for the AdbRunner constructor signature change. |
You can also share your feedback on Copilot code review. Take the survey.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| var psi = new System.Diagnostics.ProcessStartInfo ("chmod") { | ||
| ArgumentList = { "+x", path }, | ||
| }; | ||
| System.Diagnostics.Process.Start (psi)?.WaitForExit (); |
There was a problem hiding this comment.
I thought we had a [DllImport] for this somewhere? Can the test call a method from ProcessUtils (or whereever that was?)
There was a problem hiding this comment.
Done — replaced Process.Start("chmod") with FileUtil.Chmod(path, 0x1ED) which uses File.SetUnixFileMode on .NET 7+ and the [DllImport("libc")] chmod on older runtimes. Also replaced the null-forgiving ! on Path.GetDirectoryName() with is { Length: > 0 } property pattern per repo conventions.
10ec06c to
1661ac9CompareTwo fixes for AdbRunner emulator detection reliability: 1. Swap AVD name detection order in GetEmulatorAvdNameAsync: use 'adb shell getprop ro.boot.qemu.avd_name' first (reliable on all modern emulators), fall back to 'adb emu avd name' for older versions. The 'emu avd name' command returns empty output on emulator 36.4.10+. 2. Skip AVD name queries for offline emulators in ListDevicesAsync: neither getprop nor 'emu avd name' works on offline devices, causing unnecessary delays during boot polling loops. Context: dotnet/android#10965 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1661ac9 to
cc1e063Compare…erators
- Replace Process.Start("chmod") with FileUtil.Chmod(path, 0x1ED)
which uses managed File.SetUnixFileMode on .NET 7+ and the
chmod DllImport on older runtimes
- Replace null-forgiving operator on Path.GetDirectoryName() with
is { Length: > 0 } property pattern per repo conventions
- Reorder CleanupFakeAdb to delete file only when dir is non-null
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Two fixes for
AdbRunneremulator detection reliability, discovered while investigating dotnet/android#10965.Related PR: dotnet/android#10969
1. Swap AVD name detection order (
GetEmulatorAvdNameAsync)adb -s <serial> emu avd namereturns empty output on modern Android emulators (tested with emulator 36.4.10, adb v36). This causes AVD name matching to fail even when the correct emulator is running.Fix: Use
adb shell getprop ro.boot.qemu.avd_namefirst (reliable on all modern emulators, always set by the emulator kernel), fall back toemu avd namefor older emulator versions.2. Skip AVD name queries for offline emulators (
ListDevicesAsync)ListDevicesAsynccalledGetEmulatorAvdNameAsyncfor ALL emulators including offline ones. Neithergetpropnoremu avd nameworks on offline devices — they fail or timeout. During boot polling loops, this causes unnecessary delays on every iteration as the emulator transitions from offline → online.Fix: Only query AVD names for online emulators (
Status == AdbDeviceStatus.Online).Testing