Skip to content

Commit

Permalink
module: update
Browse files Browse the repository at this point in the history
  • Loading branch information
j-hc committed Feb 4, 2025
1 parent 36bc158 commit 6a988a3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
11 changes: 9 additions & 2 deletions revanced-magisk/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ if type nsenter >/dev/null 2>/dev/null; then
ZPID=$(pidof zygote)
Z64PID=$(pidof zygote64)

mm() {
mz() {
if [ "$ZPID" ]; then nsenter -t "$ZPID" -m -- "$@" || return $?; fi
if [ "$Z64PID" ]; then nsenter -t "$Z64PID" -m -- "$@" || return $?; fi
}
mm() { nsenter -t 1 -m -- "$@"; }
else
mm() { "$@"; }
mz() { "$@"; }

if su -M -c true >/dev/null 2>/dev/null; then
mm() { su -M -c "$@"; }
else
mm() { "$@"; }
fi
fi

pmex() {
Expand Down
26 changes: 17 additions & 9 deletions revanced-magisk/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk

set_perm_recursive "$MODPATH/bin" 0 0 0755 0777

mm grep -F "$PKG_NAME" /proc/mounts | while read -r line; do
mz grep -F "$PKG_NAME" /proc/mounts | while read -r line; do
ui_print "* Un-mount"
mp=${line#* } mp=${mp%% *}
mz umount -l "${mp%%\\*}"
done
mm grep -F "$PKG_NAME" /proc/mounts | while read -r line; do
ui_print "* Un-mount global"
mp=${line#* } mp=${mp%% *}
mm umount -l "${mp%%\\*}"
done
am force-stop "$PKG_NAME"
Expand Down Expand Up @@ -96,7 +101,7 @@ install() {
if [ "$IS_SYS" = true ]; then
mkdir -p /data/adb/rvhc/empty /data/adb/post-fs-data.d
SCNM="/data/adb/post-fs-data.d/$PKG_NAME-uninstall.sh"
echo "mount -o bind /data/adb/rvhc/empty $BASEPATH" >"$SCNM"
echo "mount /data/adb/rvhc/empty $BASEPATH" >"$SCNM"
chmod +x "$SCNM"
ui_print "* Created the uninstall script."
ui_print ""
Expand Down Expand Up @@ -138,20 +143,23 @@ if [ $INS = true ] || [ -z "$(ls -A1 "$BASEPATHLIB")" ]; then
fi

ui_print "* Setting Permissions"
set_perm "$MODPATH/base.apk" 1000 1000 644 u:object_r:apk_data_file:s0

ui_print "* Mounting $PKG_NAME"
mkdir -p "/data/adb/rvhc"
RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk
mv -f "$MODPATH/base.apk" "$RVPATH"
set_perm "$RVPATH" 1000 1000 644 u:object_r:apk_data_file:s0

ui_print "* Optimizing $PKG_NAME"
mm nohup sh -c "
mount $RVPATH $BASEPATH/base.apk
cmd package compile --reset $PKG_NAME
umount -l $BASEPATH/base.apk
" >/dev/null 2>&1 &

if ! op=$(mm mount -o bind "$RVPATH" "$BASEPATH/base.apk" 2>&1); then
ui_print "* Mounting $PKG_NAME"
if ! op=$(mz mount "$RVPATH" "$BASEPATH/base.apk" 2>&1); then
ui_print "ERROR: Mount failed!"
ui_print "$op"
fi
am force-stop "$PKG_NAME"
ui_print "* Optimizing $PKG_NAME"
nohup cmd package compile --reset "$PKG_NAME" >/dev/null 2>&1 &

ui_print "* Cleanup"
rm -rf "${MODPATH:?}/bin" "$MODPATH/$PKG_NAME.apk"
Expand Down
6 changes: 3 additions & 3 deletions revanced-magisk/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ run() {
err "version mismatch (installed:${VERSION}, module:$PKG_VER)"
return
fi
mm grep "$PKG_NAME" /proc/mounts | while read -r line; do
mz grep "$PKG_NAME" /proc/mounts | while read -r line; do
mp=${line#* } mp=${mp%% *}
mm umount -l "${mp%%\\*}"
mz umount -l "${mp%%\\*}"
done
if ! chcon u:object_r:apk_data_file:s0 "$RVPATH"; then
err "apk not found"
return
fi
mm mount -o bind "$RVPATH" "$BASEPATH/base.apk"
mz mount "$RVPATH" "$BASEPATH/base.apk"
am force-stop "$PKG_NAME"
[ -f "$MODDIR/err" ] && mv -f "$MODDIR/err" "$MODDIR/module.prop"
}
Expand Down

0 comments on commit 6a988a3

Please sign in to comment.