Skip to content

Commit eda8083

Browse files
enhance app installation
Instead of copying to /data/local we now install using a pipe, which will not yield any file access issues anymore. Additionally now the app will be upgraded if it exists already, and will only be deactivated if it didn't exist beforehand. This will make it possible to update at any point in time and postpone the restart to a more convenient time.
1 parent 0ac2700 commit eda8083

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

magiskmodule/customize.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ IFS=$'\n'
1212
SEARCH_ROOT="$(magisk --path)/.magisk/mirror"/
1313
[ ! -d "$SEARCH_ROOT" ] && SEARCH_ROOT=/
1414

15-
# Uninstall v4a app if installed
16-
[ -n "$(pm list packages | grep "$VIPERFXPACKAGE")" ] && pm uninstall -k "$VIPERFXPACKAGE" &>/dev/null
17-
1815
# Create the scoped storage directory
1916
mkdir -p "$FOLDER"
2017

@@ -107,15 +104,18 @@ for ORIGINAL_FILE in $AUDIO_EFFECTS_FILES; do
107104
done
108105

109106
ui_print "- Installing the ViPER4AndroidFX user app"
110-
APK_INSTALL_FOLDER="/data/local"
111-
(
112-
cp -f "$MODPATH"/v4afx.apk "$APK_INSTALL_FOLDER"/v4afx.apk || exit 1
113-
pm install "$APK_INSTALL_FOLDER"/v4afx.apk &>/dev/null
114-
RET=$?
115-
rm "$APK_INSTALL_FOLDER"/v4afx.apk
116-
exit $RET
117-
) || abort "Failed to install V4AFX!"
118-
pm disable "$VIPERFXPACKAGE" &>/dev/null
107+
APK=v4afx.apk
108+
[ -n "$(pm list packages | grep "^package:$VIPERFXPACKAGE$")" ] && APK_UPGRADE=true || APK_UPGRADE=false
109+
APK_SIZE=$(stat -c %s "$MODPATH"/"$APK")
110+
installAPK() {
111+
pm install --install-location 1 --pkg "$VIPERFXPACKAGE" -S $APK_SIZE < "$MODPATH"/"$APK" &>/dev/null
112+
}
113+
installAPK || {
114+
$APK_UPGRADE && pm uninstall -k "$VIPERFXPACKAGE" &>/dev/null
115+
APK_UPGRADE=false
116+
installAPK
117+
} || abort "Failed to install V4AFX!"
118+
! $APK_UPGRADE && pm disable "$VIPERFXPACKAGE" &>/dev/null
119119

120120
ui_print "- Configuring ViPER4Android"
121121
VIPERFXPREFS="$(pm dump "$VIPERFXPACKAGE" | grep dataDir | head -n 1 | cut -d'=' -f2)"

0 commit comments

Comments
 (0)