-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApkHelper.ps1
40 lines (31 loc) · 1002 Bytes
/
ApkHelper.ps1
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
function Get-ApkInfo {
param (
[Parameter(Mandatory = $true)] [string]$ApkPath
)
if (-not (Test-Path $ApkPath)) {
Write-Error "Apk path '$ApkPath' does not exist"
return
}
$output = & aapt dump badging $ApkPath
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to dump badging for '$ApkPath'"
return
}
$result = [PSCustomObject]@{
PackageName = $null
LaunchActivity = $null
}
foreach ($line in $output) {
if ($line.StartsWith("package:")) {
$match = [Regex]::Match($line, "name='(?<packageName>[^']*)'")
if ($match.Success) {
$result.PackageName = $match.Groups["packageName"].Value
}
}
if ($line -match "launchable-activity: name='(?<launchActivity>[^']*)'") {
$result.LaunchActivity = $matches['launchActivity']
}
}
return $result
}
New-Alias -Name gapki -Value Get-ApkInfo -Force