-
Notifications
You must be signed in to change notification settings - Fork 33
EmulatorRunner.LaunchEmulator: return EmulatorLaunchResult with serial, ports, and log path #340
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: main
Are you sure you want to change the base?
Changes from all commits
4a746aa
5ba4132
819fa9d
3ec585d
4cd42fc
6a3241d
131dbe1
d3270e2
2ed3fc3
f8894ba
584456a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Xamarin.Android.Tools; | ||
|
|
||
| /// <summary> | ||
| /// Returned by <see cref="EmulatorRunner.LaunchEmulator"/> with enriched launch information. | ||
| /// </summary> | ||
| public sealed class EmulatorLaunchResult | ||
| { | ||
| public EmulatorLaunchResult (Process process, string logPath) | ||
| { | ||
| if (process is null) | ||
| throw new System.ArgumentNullException (nameof (process)); | ||
| if (logPath is null) | ||
| throw new System.ArgumentNullException (nameof (logPath)); | ||
| Process = process; | ||
| LogPath = logPath; | ||
| } | ||
|
rmarinho marked this conversation as resolved.
|
||
|
|
||
| /// <summary>The running emulator process.</summary> | ||
| public Process Process { get; } | ||
|
|
||
| /// <summary>The OS process ID of the emulator process.</summary> | ||
| public int Pid => Process.Id; | ||
|
|
||
| /// <summary> | ||
| /// The emulator console port (e.g., 5554). Populated either from the pre-assigned | ||
| /// <c>-ports</c> argument or once <see cref="PortsResolvedAsync"/> completes. | ||
| /// </summary> | ||
| public int? ConsolePort { get; internal set; } | ||
|
|
||
| /// <summary> | ||
| /// The emulator ADB port (e.g., 5555). Populated either from the pre-assigned | ||
| /// <c>-ports</c> argument or once <see cref="PortsResolvedAsync"/> completes. | ||
| /// </summary> | ||
| public int? AdbPort { get; internal set; } | ||
|
Comment on lines
+34
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 💡 Code organization — Per repo convention, consider adding a /// <remarks>
/// <see cref="ConsolePort"/> and <see cref="AdbPort"/> are written by process
/// output callbacks and should only be read after <see cref="PortsResolvedAsync"/> completes.
/// </remarks>This makes the ordering contract explicit for future callers. Rule: Document thread-safety invariants |
||
|
|
||
| /// <summary> | ||
| /// The ADB serial for this emulator (e.g., <c>emulator-5554</c>), derived from <see cref="ConsolePort"/>. | ||
| /// Returns <c>null</c> until <see cref="ConsolePort"/> is populated. | ||
| /// </summary> | ||
| public string? Serial => ConsolePort is int p ? $"emulator-{p}" : null; | ||
|
|
||
| /// <summary> | ||
| /// The path to the emulator log file. Resolved at launch time from the <c>-logfile</c> | ||
| /// argument (if specified) or from the <c>ANDROID_AVD_HOME</c> / <c>ANDROID_USER_HOME</c> | ||
| /// environment variables, falling back to the AOSP default | ||
| /// (<c>~/.android/avd/<name>.avd/emulator.log</c>). | ||
| /// </summary> | ||
| public string LogPath { get; } | ||
|
|
||
| /// <summary> | ||
| /// A <see cref="Task"/> that completes when the emulator has reported its console and ADB | ||
| /// port assignments via stdout/stderr. If ports were pre-assigned via <c>-ports</c>, this | ||
| /// task is already completed. | ||
| /// </summary> | ||
| internal Task PortsResolvedAsync { get; set; } = Task.CompletedTask; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.