Skip to content

Commit 0799b9b

Browse files
unify constants
unify constants into one file used for compilation and installation for more streamlined configuration changes later on
1 parent 2223c9b commit 0799b9b

File tree

5 files changed

+40
-19
lines changed

5 files changed

+40
-19
lines changed

compile.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e -u
44
IFS=$'\n'
55
renice -n 19 $$ &>/dev/null
66

7+
source magiskmodule/constants.sh
8+
79
GZIP=(gzip --best)
810
[ -n "$(command -v pigz)" ] && {
911
GZIP=(pigz --best)
@@ -36,10 +38,10 @@ compressFiles() {
3638
}
3739

3840
echo "Compressing Viper IRS files..."
39-
compressFiles ViperIRS/"*.irs" magiskmodule/ViperIRS.tar.gz &
41+
compressFiles ViperIRS/"*.irs" magiskmodule/"$VIPERIRSFILE" &
4042

4143
echo "Compressing Original VDC files..."
42-
compressFiles OriginalVDCs/"*.vdc" magiskmodule/ViperVDC.tar.gz &
44+
compressFiles OriginalVDCs/"*.vdc" magiskmodule/"$VIPERVDCFILE" &
4345

4446
wait
4547

magiskmodule/constants.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# minimum required SDK level
4+
MINAPI=28
5+
6+
# the ViPER4Android user app package
7+
VIPERFXPACKAGE="com.pittvandewitt.viperfx"
8+
9+
# location of the user folder (commonly referred to as /sdcard)
10+
SDCARD="/storage/emulated/0"
11+
12+
# location of the ViPER4Android app data folder
13+
FOLDER="$SDCARD/Android/data/$VIPERFXPACKAGE/files"
14+
15+
# names of the included archives
16+
VIPERVDCFILE="ViperVDC.tar.gz"
17+
VIPERIRSFILE="ViperIRS.tar.gz"
18+
19+
# constants for patching system audio config files
20+
LIBRARY_NAME="v4a_standard_fx"
21+
EFFECT_NAME="v4a_fx"
22+
EFFECT_UUID="41d3c987-e6cf-11e3-a88a-11aba5d5c51b"
23+
LIBRARY_FILE="lib$EFFECT_NAME.so"
24+
LIBRARY_FILE_PATH="/system/vendor/lib/soundfx/$LIBRARY_FILE"

magiskmodule/customize.sh

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#!/bin/bash
22

3-
[ $API -lt 28 ] && abort "Android SDK $API is not supported!"
3+
[ ! -f "$MODPATH"/constants.sh ] && abort "Missing constants.sh"
4+
source "$MODPATH"/constants.sh
45

5-
VIPERFXPACKAGE="com.pittvandewitt.viperfx"
6-
SDCARD="/storage/emulated/0"
7-
FOLDER="$SDCARD/Android/data/$VIPERFXPACKAGE/files"
8-
VIPERVDCFILE="ViperVDC.tar.gz"
9-
VIPERIRSFILE="ViperIRS.tar.gz"
6+
[ $API -lt $MINAPI ] && abort "Android SDK $API is not supported!"
107

118
IFS=$'\n'
129
SEARCH_ROOT="$(magisk --path)/.magisk/mirror"/
@@ -23,13 +20,13 @@ mkdir -p "$FOLDER"
2320
mkdir -p "$FOLDER"/DDC
2421
CUSTOM_VDC_FILES=$(find $SDCARD -name '*.vdc' -not -path "$SDCARD/Android/*")
2522
[ -n "$CUSTOM_VDC_FILES" ] && CUSTOM_VDC_FOUND=true || CUSTOM_VDC_FOUND=false
26-
[ -f "$MODPATH"/"$VIPERVDCFILE" ] && ORIGINAL_VDC_ARCHIVE_FOUND=true || ORIGINAL_VDC_ARCHIVE_FOUND=false
23+
[ -f "$MODPATH"/"$VIPERVDCFILE" ] && VDC_ARCHIVE_FOUND=true || VDC_ARCHIVE_FOUND=false
2724
for file in $(tar -tzf "$MODPATH"/"$VIPERVDCFILE") $CUSTOM_VDC_FILES; do
2825
file="$FOLDER"/DDC/"$file"
2926
rmi "$file"
3027
done
3128
[ -z "$(ls -A "$FOLDER"/DDC 2>/dev/null)" ] && VDC_FOLDER_EMPTY=true || VDC_FOLDER_EMPTY=false
32-
if $VDC_FOLDER_EMPTY && ! $CUSTOM_VDC_FOUND && $ORIGINAL_VDC_ARCHIVE_FOUND; then
29+
if $VDC_FOLDER_EMPTY && ! $CUSTOM_VDC_FOUND && $VDC_ARCHIVE_FOUND; then
3330
ui_print "- Copying original ViPER4Android VDCs"
3431
ui_print " Note that some of these aren't that great"
3532
ui_print " Check out https://t.me/vdcservice for better ones"
@@ -39,7 +36,7 @@ else
3936
ui_print "- Skipping Viper original VDC copy"
4037
! $VDC_FOLDER_EMPTY && ui_print " the folder is not empty"
4138
$CUSTOM_VDC_FOUND && ui_print " custom VDCs have been found"
42-
! $ORIGINAL_VDC_ARCHIVE_FOUND && ui_print " the required data couldn't be located"
39+
! $VDC_ARCHIVE_FOUND && ui_print " the required data couldn't be located"
4340
fi
4441
rmi "$MODPATH"/"$VIPERVDCFILE"
4542
if $CUSTOM_VDC_FOUND; then
@@ -79,11 +76,6 @@ if $CUSTOM_IRS_FOUND; then
7976
fi
8077

8178
ui_print "- Patching system audio files"
82-
LIBRARY_NAME="v4a_standard_fx"
83-
EFFECT_NAME="v4a_fx"
84-
EFFECT_UUID="41d3c987-e6cf-11e3-a88a-11aba5d5c51b"
85-
LIBRARY_FILE="lib$EFFECT_NAME.so"
86-
LIBRARY_FILE_PATH="/system/vendor/lib/soundfx/$LIBRARY_FILE"
8779
AUDIO_EFFECTS_FILES="$( \
8880
find -H \
8981
$SEARCH_ROOT/system $SEARCH_ROOT/vendor $SEARCH_ROOT/odm \

magiskmodule/service.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/bin/bash
22

3+
cd "$(dirname "$0")"
4+
source ./constants.sh
5+
36
waitUntilBootCompleted() {
47
while [ $(getprop sys.boot_completed) -ne 1 ] || [ "$(getprop init.svc.bootanim | tr '[:upper:]' '[:lower:]')" != "stopped" ]; do
58
sleep 10
69
done
710
}
811

9-
VIPERFXPACKAGE="com.pittvandewitt.viperfx"
10-
1112
(
1213
waitUntilBootCompleted
1314
sleep 10

magiskmodule/uninstall.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11

2+
cd "$(dirname "$0")"
3+
source ./constants.sh
4+
25
(
36
while [ $(getprop sys.boot_completed) -ne 1 ] || [ "$(getprop init.svc.bootanim | tr '[:upper:]' '[:lower:]')" != "stopped" ]; do
47
sleep 1
58
done
69
sleep 10
7-
VIPERFXPACKAGE="com.pittvandewitt.viperfx"
810
pm uninstall -k "$VIPERFXPACKAGE"
911
) &

0 commit comments

Comments
 (0)