-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPull-AndroidPackage.ps1
More file actions
28 lines (23 loc) · 1007 Bytes
/
Pull-AndroidPackage.ps1
File metadata and controls
28 lines (23 loc) · 1007 Bytes
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
param(
[Parameter(Mandatory=$True)][String] $PackageName
)
$PackageManager = adb shell "pm list packages -f | grep $PackageName"
If ($null -eq $PackageManager) {
Write-Error -Message "Could not find package: $PackageName"
Exit
} Else {
[void]($PackageManager -match "package:(.*)=$PackageName")
$PackagePath = $Matches[1]
$DumpSys = adb shell "dumpsys package $PackageName | grep versionName"
[void]($DumpSys -match "versionName=(.*)")
$PackageVersion = $Matches[1]
If ($False -eq (Test-Path $PackageName)) {
Write-Output "Creating directory: $PackageName"
[void](New-Item -ItemType Directory -Name $PackageName)
}
If ($False -eq (Test-Path "$PackageName\$PackageVersion")) {
Write-Output "Creating directory: $PackageName\$PackageVersion"
[void](New-Item -ItemType Directory -Name ("$PackageName\$PackageVersion"))
}
adb pull $PackagePath ("$PackageName\$PackageVersion\$PackageName.apk")
}