Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions magiskmodule/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ presetCompatible() {
}

mkdir -p "$FOLDER"/Preset
CUSTOM_PRESET_FILES=$(find "$SDCARD" -name '*.xml' -not -path "$SDCARD/Android/*")
CUSTOM_PRESET_FILES=$(find "$SDCARD" -path "$SDCARD/Android" -prune -o -type f -name '*.xml' -size -1048576c -print)
if [ -n "$CUSTOM_PRESET_FILES" ]; then
ui_print "- Copying custom preset files"
for file in $CUSTOM_PRESET_FILES; do
Expand All @@ -106,7 +106,7 @@ osp_detect() {
local osp=music
case $file in
*.conf)
spaces=$(sed -n "/^output_session_processing {/,/^}/ {/^ *$osp {/p}" "$fil"e | sed -r "s/( *).*/\1/")
spaces=$(sed -n "/^output_session_processing {/,/^}/ {/^ *$osp {/p}" "$file" | sed -r "s/( *).*/\1/")
effects=$(sed -n "/^output_session_processing {/,/^}/ {/^$spaces\$osp {/,/^$spaces}/p}" "$file" | grep -E "^$spaces +[A-Za-z]+" | sed -r "s/( *.*) .*/\1/g")
for effect in ${effects}; do
spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effect {/p}" "$file" | sed -r "s/( *).*/\1/")
Expand Down Expand Up @@ -174,13 +174,9 @@ installAPK || {
! $APK_UPGRADE && pm disable "$VIPERFXPACKAGE" >&2

ui_print "- Configuring ViPER4Android"
VIPERFXPREFS="$(pm dump "$VIPERFXPACKAGE" | grep dataDir | head -n 1 | cut -d'=' -f2)"
VIPERFXPREFSOWNER="$(stat -c '%U' "$VIPERFXPREFS")"
VIPERFXSHAREDPREFS="$VIPERFXPREFS"/shared_prefs
[ ! -d "$VIPERFXSHAREDPREFS" ] && mkdir "$VIPERFXSHAREDPREFS"
cp -f "$MODPATH"/viperfx_preferences.xml "$VIPERFXSHAREDPREFS"/"${VIPERFXPACKAGE}_preferences.xml"
chown -R "$VIPERFXPREFSOWNER":"$VIPERFXPREFSOWNER" "$VIPERFXPREFS"
set_perm_recursive "$FOLDER" "$VIPERFXPREFSOWNER" sdcard_rw 771 660 u:object_r:sdcardfs:s0
VIPERFXSTORAGEOWNER="$(stat -c '%u' "$FOLDER")"
[ -n "$VIPERFXSTORAGEOWNER" ] || abort "Could not determine ViPER4Android shared-storage owner"
set_perm_recursive "$FOLDER" "$VIPERFXSTORAGEOWNER" sdcard_rw 771 660 u:object_r:sdcardfs:s0
# this permanently hides the notifications without the possiblity of reenabling them
[ "$API" -ge 31 ] && pm set-distracting-restriction --flag hide-notifications "$VIPERFXPACKAGE"
[ "$API" -ge 33 ] && {
Expand Down
22 changes: 22 additions & 0 deletions magiskmodule/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ waitUntilBootCompleted() {
waitUntilBootCompleted
sleep 10
pm list packages -d | grep -q "$VIPERFXPACKAGE" && pm enable "$VIPERFXPACKAGE"

# PackageManager may not expose the app's private data during module install.
# Install default preferences once the normal boot namespace can see it.
APPDATA="$(pm dump "$VIPERFXPACKAGE" | grep dataDir | head -n 1 | cut -d'=' -f2)"
attempts=0
while [ ! -d "$APPDATA" ] && [ "$attempts" -lt 12 ]; do
sleep 5
attempts=$((attempts + 1))
done
if [ -d "$APPDATA" ]; then
PREFDIR="$APPDATA/shared_prefs"
PREF="$PREFDIR/${VIPERFXPACKAGE}_preferences.xml"
if [ ! -e "$PREF" ]; then
mkdir -p "$PREFDIR" && cp ./viperfx_preferences.xml "$PREF" && {
chown "$(stat -c '%u:%g' "$APPDATA")" "$PREFDIR" "$PREF"
chmod 700 "$PREFDIR"
chmod 600 "$PREF"
APP_CONTEXT="$(stat -c '%C' "$APPDATA")"
[ -n "$APP_CONTEXT" ] && chcon "$APP_CONTEXT" "$PREFDIR" "$PREF"
}
fi
fi
) &

(
Expand Down