Skip to content

Commit

Permalink
Cache Android SDK packages list (#7709)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpolikarpov-akvelon authored Jun 16, 2023
1 parent f83e411 commit d0d97cd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
17 changes: 14 additions & 3 deletions images/linux/scripts/helpers/Common.Helpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,20 @@ function Get-ToolsetValue {
}

function Get-AndroidPackages {
$androidSDKManagerPath = "/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager"
$androidPackages = & $androidSDKManagerPath --list --verbose 2>&1
return $androidPackages
$packagesListFile = "/usr/local/lib/android/sdk/packages-list.txt"

if (-Not (Test-Path -Path $packagesListFile -PathType Leaf)) {
(/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --list --verbose 2>&1) |
Where-Object { $_ -Match "^[^\s]" } |
Where-Object { $_ -NotMatch "^(Loading |Info: Parsing |---|\[=+|Installed |Available )" } |
Where-Object { $_ -NotMatch "^[^;]*$" } |
Out-File -FilePath $packagesListFile

Write-Host Android packages list:
Get-Content $packagesListFile
}

return Get-Content $packagesListFile
}

function Get-EnvironmentVariable($variable) {
Expand Down
18 changes: 16 additions & 2 deletions images/macos/software-report/SoftwareReport.Android.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,23 @@ function Get-AndroidInstalledPackages {
}

function Get-AndroidPackages {
$androidSDKDir = Get-AndroidSDKRoot
$androidSDKManagerPath = Get-AndroidSDKManagerPath
$androidPackages = & $androidSDKManagerPath --list --verbose
return $androidPackages

$packagesListFile = Join-Path $androidSDKDir "packages-list.txt"

if (-Not (Test-Path -Path $packagesListFile -PathType Leaf)) {
(& $androidSDKManagerPath --list --verbose) |
Where-Object { $_ -Match "^[^\s]" } |
Where-Object { $_ -NotMatch "^(Loading |Info: Parsing |---|\[=+|Installed |Available )" } |
Where-Object { $_ -NotMatch "^[^;]*$" } |
Out-File -FilePath $packagesListFile

Write-Host Android packages list:
Get-Content $packagesListFile
}

return Get-Content $packagesListFile
}

function Build-AndroidTable {
Expand Down
12 changes: 11 additions & 1 deletion images/win/scripts/ImageHelpers/InstallHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,17 @@ function Get-AndroidPackages {
[string]$AndroidSDKManagerPath
)

return (cmd /c "$AndroidSDKManagerPath --list --verbose 2>&1").Trim() | Foreach-Object { $_.Split()[0] } | Where-Object {$_}
$packagesListFile = "C:\Android\android-sdk\packages-list.txt"

if (-Not (Test-Path -Path $packagesListFile -PathType Leaf)) {
(cmd /c "$AndroidSDKManagerPath --list --verbose 2>&1") |
Where-Object { $_ -Match "^[^\s]" } |
Where-Object { $_ -NotMatch "^(Loading |Info: Parsing |---|\[=+|Installed |Available )" } |
Where-Object { $_ -NotMatch "^[^;]*$" } |
Out-File -FilePath $packagesListFile
}

return Get-Content $packagesListFile
}

function Get-AndroidPackagesByName {
Expand Down

0 comments on commit d0d97cd

Please sign in to comment.