Skip to content

Commit

Permalink
Update Function.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 authored Feb 25, 2024
1 parent 41cf5b5 commit 9a68228
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ if (($Files | Test-Path) -contains $false)
exit
}

if (Get-Process -Name adb -ErrorAction Ignore)
{
Write-Warning -Message "Kill adb.exe manually and try again"
pause
exit
}

Write-Warning -Message "Waiting your phone to be connected and allowed USB debugging"
& $PSScriptRoot\platform-tools\adb.exe wait-for-device
pause

# Check whether adb is functioning
try
{
Expand Down Expand Up @@ -127,18 +138,12 @@ if ($null -ne (& $PSScriptRoot\platform-tools\adb.exe shell pm list packages -d)
$Packages = @()
foreach ($Package in $PackagesList.Package)
{
if ((@((& $PSScriptRoot\platform-tools\adb.exe shell cmd package list packages).replace("package:", "")) | Where-Object -FilterScript {$_ -eq $Package}) -or ($DisabledPackages -contains $Package))
if ((@((& $PSScriptRoot\platform-tools\adb.exe shell cmd package list packages).replace("package:", "")) | Where-Object -FilterScript {$_ -eq $Package}) -and ($DisabledPackages -notcontains $Package))
{
$Packages += $PackagesList | Where-Object {$_.Package -eq $Package}
}
}

Write-Warning -Message "Waiting your phone to be connected and allowed USB debugging"

& $PSScriptRoot\platform-tools\adb.exe wait-for-device

pause

Add-Type -AssemblyName PresentationCore, PresentationFramework

$CheckedPackages = New-Object -TypeName System.Collections.ArrayList($null)
Expand Down

0 comments on commit 9a68228

Please sign in to comment.