From 5ecb50f6a5c39a020f10c9bcc9afc5f88b488835 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Tue, 19 Jul 2022 18:01:45 +0200 Subject: [PATCH 1/3] Remove splitarray --- revanced.ps1 | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/revanced.ps1 b/revanced.ps1 index b32f276..d860e98 100644 --- a/revanced.ps1 +++ b/revanced.ps1 @@ -71,21 +71,6 @@ function renderForm([String[]]$items, [String]$label, [String]$title, [System.Wi return $false } -function splitArray([String[]]$array, $splitter = $null, [int]$row = 0) { - $returnVal = New-Object System.Collections.ArrayList - if ($null -eq $splitter) { - foreach ($i in $array) { - $returnVal.Add(@($i.Split()[$row])) | Out-Null - } - } - else { - foreach ($i in $array) { - $returnVal.Add(@($i.Split($splitter)[$row])) | Out-Null - } - } - return $returnVal -} - class config { [String]$patches = "none" [String]$integrations = "none" @@ -229,9 +214,11 @@ function main { [String]$selectedDevice = '' if ($devices.Length -eq 0) {throw "No devices found"} - elseif ($devices.Length -eq 1) {$selectedDevice = (splitArray -array $devices)[0]} + elseif ($devices.Length -eq 1) { + $selectedDevice = ($devices | ForEach-Object {$_.split()[0]})[0] + } else { - $selectedDevice = (renderForm -items (splitArray -array $devices) -label "Select deployment target" -title "Installer for ReVanced - target" -mode One) + $selectedDevice = (renderForm -items ($devices | ForEach-Object {$_.split()[0]}) -label "Select deployment target" -title "Installer for ReVanced - target" -mode One) } # install to device From 7f8d16066177a1c9067ee4a265428b4c1842af57 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Tue, 19 Jul 2022 18:04:03 +0200 Subject: [PATCH 2/3] fix and add throw if nothing from the list selected --- revanced.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/revanced.ps1 b/revanced.ps1 index d860e98..ad2f51f 100644 --- a/revanced.ps1 +++ b/revanced.ps1 @@ -159,9 +159,10 @@ function main { elseif ($apks.getType().Name -eq 'String') {$selectedApk = $apks} else { $selectedApk = (renderForm -items $apks -label "Select apk file to patch" -title "Installer for ReVanced - apk selector" -mode One) - if (-not $selectedApk) {throw "No apk selected!"} } + if (-not $selectedApk) {throw "No apk selected!"} + # Get available integrations $integrationsList = New-Object System.Collections.ArrayList @@ -221,6 +222,8 @@ function main { $selectedDevice = (renderForm -items ($devices | ForEach-Object {$_.split()[0]}) -label "Select deployment target" -title "Installer for ReVanced - target" -mode One) } + if (-not $selectedDevice) {throw "No device selected"} + # install to device $patcherArgs = "-jar", ".\app\revanced-cli.jar", "-a", ".\$selectedApk", "-c", "-d", "$selectedDevice", "-o", "$env:tmp\revanced.apk", "-m", ".\app\app-release-unsigned.apk", "-b", ".\app\revanced-patches.jar" From 96c6ba3d3ccae69704c1895543fe63a9e9d6e05c Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Tue, 19 Jul 2022 18:33:03 +0200 Subject: [PATCH 3/3] document execJava --- revanced.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/revanced.ps1 b/revanced.ps1 index ad2f51f..990819b 100644 --- a/revanced.ps1 +++ b/revanced.ps1 @@ -8,7 +8,15 @@ Add-type -AssemblyName System.Drawing $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = 'Stop' + function execJava { +<# +.Description +execJava was created to additionally allow providing an array of strings to java arguments +if the first argument is a string array, it will launch with arguments in that array +otherwise it will launch with all provided arguments +#> + $SavedErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = 'Continue' if ($args[0].getType().Name -ne "String") { & $Java $args[0] 2>&1 | ForEach-Object{ "$_" } @@ -16,7 +24,7 @@ function execJava { else { & $Java $args 2>&1 | ForEach-Object{ "$_" } } - $ErrorActionPreference = 'Stop' + $ErrorActionPreference = $SavedErrorActionPreference } function renderForm([String[]]$items, [String]$label, [String]$title, [System.Windows.Forms.SelectionMode]$mode, [System.Collections.ArrayList]$selected) { @@ -121,6 +129,8 @@ function main { New-Item -type Directory -Path ".\app" -ErrorAction SilentlyContinue | Out-Null + # TODO: use where-object to search for filename + if ($install[0]) { Write-Output "Downloading Patches ($($config.patches) -> $($patchesRelease.tag_name))" Write-Output "changelog: https://github.com/revanced/revanced-patches/compare/$($config.patches)...$($patchesRelease.tag_name)"