Skip to content

Commit

Permalink
Update Function.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 authored Oct 17, 2023
1 parent fab103a commit 67ed6db
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ $File = Show-Menu -Menu @("Samsung", "Xiaomi", "Google") -Default 1

Write-Verbose -Message "Please wait..." -Verbose

$Packages = @()
$PackagesList = Get-Content -Path "$PSScriptRoot\JSON\$File.json" | ConvertFrom-Json
# Check if disabled packages exist, unless we cannot check if replace() method exists for them
if ($null -ne (& $PSScriptRoot\platform-tools\adb.exe shell pm list packages -d))
{
$DisabledPackages = @((& $PSScriptRoot\platform-tools\adb.exe shell pm list packages -d).replace("package:", ""))
}

$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 (@((& $PSScriptRoot\platform-tools\adb.exe shell pm list packages -d).replace("package:", "")) -contains $Package))
if ((@((& $PSScriptRoot\platform-tools\adb.exe shell cmd package list packages).replace("package:", "")) | Where-Object -FilterScript {$_ -eq $Package}) -or ($DisabledPackages -contains $Package))
{
$Packages += $PackagesList | Where-Object {$_.Package -eq $Package}
}
Expand Down

0 comments on commit 67ed6db

Please sign in to comment.