Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/Xamarin.Android.Tools.AndroidSdk/EnvironmentVariableNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Xamarin.Android.Tools
{
/// <summary>
/// Constants for environment variable names used by Android SDK tooling.
/// </summary>
public static class EnvironmentVariableNames
{
/// <summary>
/// The ANDROID_HOME environment variable specifying the Android SDK root directory.
/// This is the preferred variable for modern Android tooling.
/// </summary>
public const string AndroidHome = "ANDROID_HOME";

/// <summary>
/// The ANDROID_SDK_ROOT environment variable specifying the Android SDK root directory.
/// This is an older variable name, but still supported by many tools.
/// </summary>
public const string AndroidSdkRoot = "ANDROID_SDK_ROOT";

/// <summary>
/// The JAVA_HOME environment variable specifying the JDK installation directory.
/// </summary>
public const string JavaHome = "JAVA_HOME";

/// <summary>
/// The JI_JAVA_HOME environment variable for internal/override JDK path.
/// Takes precedence over JAVA_HOME when set.
/// </summary>
public const string JiJavaHome = "JI_JAVA_HOME";

/// <summary>
/// The PATH environment variable for executable search paths.
/// </summary>
public const string Path = "PATH";

/// <summary>
/// The PATHEXT environment variable for executable file extensions (Windows).
/// </summary>
public const string PathExt = "PATHEXT";
}
}
4 changes: 2 additions & 2 deletions src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public static IEnumerable<JdkInfo> GetKnownSystemJdkInfos (Action<TraceLevel, st
{
logger = logger ?? AndroidSdkInfo.DefaultConsoleLogger;

return GetEnvironmentVariableJdks ("JI_JAVA_HOME", logger)
return GetEnvironmentVariableJdks (EnvironmentVariableNames.JiJavaHome, logger)
.Concat (JdkLocations.GetPreferredJdks (logger))
.Concat (XAPrepareJdkLocations.GetXAPrepareJdks (logger))
.Concat (MicrosoftOpenJdkLocations.GetMicrosoftOpenJdks (logger))
Expand All @@ -337,7 +337,7 @@ public static IEnumerable<JdkInfo> GetKnownSystemJdkInfos (Action<TraceLevel, st
.Concat (OracleJdkLocations.GetOracleJdks (logger))
.Concat (VSAndroidJdkLocations.GetVSAndroidJdks (logger))
.Concat (MicrosoftDistJdkLocations.GetMicrosoftDistJdks (logger))
.Concat (GetEnvironmentVariableJdks ("JAVA_HOME", logger))
.Concat (GetEnvironmentVariableJdks (EnvironmentVariableNames.JavaHome, logger))
.Concat (GetPathEnvironmentJdks (logger))
.Concat (GetLibexecJdks (logger))
.Concat (GetJavaAlternativesJdks (logger))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Xamarin.Android.Tools
{
/// <summary>
/// Phases of the SDK bootstrap operation.
/// </summary>
public enum SdkBootstrapPhase
{
/// <summary>Reading the manifest feed.</summary>
ReadingManifest,
/// <summary>Downloading the command-line tools archive.</summary>
Downloading,
/// <summary>Verifying the downloaded archive checksum.</summary>
Verifying,
/// <summary>Extracting the archive.</summary>
Extracting,
/// <summary>Bootstrap completed successfully.</summary>
Complete
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Xamarin.Android.Tools
{
/// <summary>
/// Progress information for SDK bootstrap operations.
/// </summary>
public class SdkBootstrapProgress
{
/// <summary>Current phase of the bootstrap operation.</summary>
public SdkBootstrapPhase Phase { get; set; }

/// <summary>Download progress percentage (0-100), or -1 if unknown.</summary>
public int PercentComplete { get; set; } = -1;

/// <summary>Human-readable status message.</summary>
public string Message { get; set; } = "";
}
}

21 changes: 21 additions & 0 deletions src/Xamarin.Android.Tools.AndroidSdk/Models/Sdk/SdkLicense.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Xamarin.Android.Tools
{
/// <summary>
/// Represents an Android SDK license that may need to be accepted.
/// </summary>
public class SdkLicense
{
/// <summary>
/// Gets or sets the license identifier (e.g., "android-sdk-license", "android-sdk-preview-license").
/// </summary>
public string Id { get; set; } = "";

/// <summary>
/// Gets or sets the full license text that should be presented to the user.
/// </summary>
public string Text { get; set; } = "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Xamarin.Android.Tools
{
/// <summary>
/// Information about a component available in the SDK manifest feed.
/// Named SdkManifestComponent to avoid confusion with AndroidManifest.xml.
/// </summary>
public class SdkManifestComponent
{
/// <summary>Element name in the manifest (e.g. "cmdline-tools", "platform-tools").</summary>
public string ElementName { get; set; } = "";

/// <summary>Component version/revision.</summary>
public string Revision { get; set; } = "";

/// <summary>SDK-style path (e.g. "cmdline-tools;19.0").</summary>
public string? Path { get; set; }

/// <summary>Filesystem destination path (e.g. "cmdline-tools/latest").</summary>
public string? FilesystemPath { get; set; }

/// <summary>Human-readable description.</summary>
public string? Description { get; set; }

/// <summary>Download URL for the current platform.</summary>
public string? DownloadUrl { get; set; }

/// <summary>Expected file size in bytes.</summary>
public long Size { get; set; }

/// <summary>Checksum value (typically SHA-1).</summary>
public string? Checksum { get; set; }

/// <summary>Checksum algorithm (e.g. "sha1").</summary>
public string? ChecksumType { get; set; }

/// <summary>Whether this component is marked obsolete.</summary>
public bool IsObsolete { get; set; }
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Xamarin.Android.Tools
{
/// <summary>
/// Specifies the manifest feed source for SDK component discovery.
/// </summary>
public enum SdkManifestSource
{
/// <summary>Use Xamarin/Microsoft manifest feed (default).</summary>
Xamarin,
/// <summary>Use Google's official Android SDK repository manifest.</summary>
Google
}
}

24 changes: 24 additions & 0 deletions src/Xamarin.Android.Tools.AndroidSdk/Models/Sdk/SdkPackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Xamarin.Android.Tools
{
/// <summary>
/// Information about an SDK package as reported by the <c>sdkmanager</c> CLI.
/// </summary>
public class SdkPackage
{
/// <summary>Package path (e.g. "platform-tools", "platforms;android-35").</summary>
public string Path { get; set; } = "";

/// <summary>Installed or available version.</summary>
public string? Version { get; set; }

/// <summary>Human-readable description.</summary>
public string? Description { get; set; }

/// <summary>Whether this package is currently installed.</summary>
public bool IsInstalled { get; set; }
}
}

4 changes: 2 additions & 2 deletions src/Xamarin.Android.Tools.AndroidSdk/ProcessUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class ProcessUtils

static ProcessUtils ()
{
var pathExt = Environment.GetEnvironmentVariable ("PATHEXT");
var pathExt = Environment.GetEnvironmentVariable (EnvironmentVariableNames.PathExt);
var pathExts = pathExt?.Split (new char [] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries) ?? new string [0];

ExecutableFileExtensions = pathExts;
Expand Down Expand Up @@ -161,7 +161,7 @@ internal static void Exec (ProcessStartInfo processStartInfo, DataReceivedEventH

internal static IEnumerable<string> FindExecutablesInPath (string executable)
{
var path = Environment.GetEnvironmentVariable ("PATH") ?? "";
var path = Environment.GetEnvironmentVariable (EnvironmentVariableNames.Path) ?? "";
var pathDirs = path.Split (new char[] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries);

foreach (var dir in pathDirs) {
Expand Down
Loading