SHIBA-st-x
/
file-home-chronos-u-f94eb994d2ea76ffe151023322f8e33fe40ee920-MyFiles-Downloads-ECMAScript-C2-AE-2
Public
generated from SHIBA-st-x/writecontract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoftwareReport.Android.psm1
171 lines (155 loc) · 5.67 KB
/
SoftwareReport.Android.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking
function Split-TableRowByColumns {
param(
[string] $Row
)
return $Row.Split("|") | ForEach-Object { $_.trim() }
}
function Get-AndroidSDKRoot {
param(
[string] $ComponentName
)
$path = Join-Path $env:ANDROID_HOME $ComponentName
return "Location $path"
}
function Get-AndroidSDKManagerPath {
return Join-Path $env:ANDROID_HOME "tools\bin\sdkmanager.bat"
}
function Get-AndroidInstalledPackages {
$androidSDKManagerPath = Get-AndroidSDKManagerPath
$androidSDKManagerList = & $androidSDKManagerPath --list --include_obsolete
$androidInstalledPackages = @()
foreach($packageInfo in $androidSDKManagerList) {
if($packageInfo -Match "Available Packages:") {
break
}
$androidInstalledPackages += $packageInfo
}
return $androidInstalledPackages
}
function Build-AndroidTable {
$packageInfo = Get-AndroidInstalledPackages
return @(
@{
"Package" = "Android Command Line Tools"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Command-line Tools"
},
@{
"Package" = "Android Emulator"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Emulator"
},
@{
"Package" = "Android SDK Build-tools"
"Version" = Get-AndroidBuildToolVersions -PackageInfo $packageInfo
},
@{
"Package" = "Android SDK Platforms"
"Version" = Get-AndroidPlatformVersions -PackageInfo $packageInfo
},
@{
"Package" = "Android SDK Platform-Tools"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Platform-Tools"
},
@{
"Package" = "Android SDK Tools"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Tools"
},
@{
"Package" = "Android Support Repository"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Support Repository"
},
@{
"Package" = "CMake"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "cmake"
},
@{
"Package" = "Google APIs"
"Version" = Get-AndroidGoogleAPIsVersions -PackageInfo $packageInfo
},
@{
"Package" = "Google Play services"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Play services"
},
@{
"Package" = "Google Repository"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Repository"
},
@{
"Package" = "NDK"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "ndk;"
},
@{
"Package" = "SDK Patch Applier v4"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "SDK Patch Applier v4"
}
) | Where-Object { $_.Version } | ForEach-Object {
[PSCustomObject] @{
"Package Name" = $_.Package
"Version" = $_.Version
}
}
}
function Get-AndroidPackageVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo,
[Parameter(Mandatory)]
[object] $MatchedString
)
$versions = $packageInfo | Where-Object { $_ -Match $MatchedString } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
return $packageInfoParts[1]
}
return ($versions -Join "<br>")
}
function Get-AndroidPlatformVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo
)
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Platform " } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
$revision = $packageInfoParts[1]
$version = $packageInfoParts[0].split(";")[1]
return "$version (rev $revision)"
}
[array]::Reverse($versions)
return ($versions -Join "<br>")
}
function Get-AndroidBuildToolVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo
)
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Build-Tools" } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
return $packageInfoParts[1]
}
$groupVersions = @()
$versions | ForEach-Object {
$majorVersion = $_.Split(".")[0]
$groupVersions += $versions | Where-Object { $_.StartsWith($majorVersion) } | Join-String -Separator " "
}
return ($groupVersions | Sort-Object -Descending -Unique | Join-String -Separator "<br>")
}
function Get-AndroidGoogleAPIsVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo
)
$versions = $packageInfo | Where-Object { $_ -Match "Google APIs" } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
return $packageInfoParts[0].split(";")[1]
}
return ($versions -Join "<br>")
}
function Build-AndroidEnvironmentTable {
$androidVersions = Get-Item env:ANDROID_*
$shoulddResolveLink = 'ANDROID_NDK_PATH', 'ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'ANDROID_NDK_LATEST_HOME'
return $androidVersions | Sort-Object -Property Name | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = if ($shoulddResolveLink.Contains($_.Name )) { Get-PathWithLink($_.Value) } else {$_.Value}
}
}
}