1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-03 13:23:30 +01:00
bitwarden-mobile/install-android26.ps1

31 lines
1.1 KiB
PowerShell
Raw Normal View History

2017-11-20 22:17:28 +01:00
$AndroidToolPath = "${env:ProgramFiles(x86)}\Android\android-sdk\tools\android"
Function Get-AndroidSDKs() {
$output = & $AndroidToolPath list sdk --all
$sdks = $output |% {
if ($_ -match '(?<index>\d+)- (?<sdk>.+), revision (?<revision>[\d\.]+)') {
$sdk = New-Object PSObject
Add-Member -InputObject $sdk -MemberType NoteProperty -Name Index -Value $Matches.index
Add-Member -InputObject $sdk -MemberType NoteProperty -Name Name -Value $Matches.sdk
Add-Member -InputObject $sdk -MemberType NoteProperty -Name Revision -Value $Matches.revision
$sdk
}
}
$sdks
}
Function Install-AndroidSDK() {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, Position=0)]
[PSObject[]]$sdks
)
$sdkIndexes = $sdks |% { $_.Index }
$sdkIndexArgument = [string]::Join(',', $sdkIndexes)
Echo 'y' | & $AndroidToolPath update sdk -u -a -t $sdkIndexArgument
}
# install android 26
$sdks = Get-AndroidSDKs |? { $_.name -like 'sdk platform*API 26*' }
Install-AndroidSDK -sdks $sdks