Compare commits

..
1 Commits
Author SHA1 Message Date
nezumi 7d5e85fc3e sync the author code 2026-07-21 11:01:29 +07:00
18 changed files with 186 additions and 521 deletions
+2 -2
View File
@@ -81,7 +81,7 @@ for table_name in $(toml_get_table_names); do
epr "Could not get prebuilts" epr "Could not get prebuilts"
continue continue
fi fi
read -r cli_jar patches_jar <<<"$PREBUILTS" read -r patches_jar cli_jar <<<"$PREBUILTS"
app_args[cli]=$cli_jar app_args[cli]=$cli_jar
app_args[ptjar]=$patches_jar app_args[ptjar]=$patches_jar
app_args[rv_brand]=$(toml_get "$t" rv-brand) || app_args[rv_brand]=$DEF_RV_BRAND app_args[rv_brand]=$(toml_get "$t" rv-brand) || app_args[rv_brand]=$DEF_RV_BRAND
@@ -155,7 +155,7 @@ for table_name in $(toml_get_table_names); do
fi fi
done done
wait wait
rm -rf temp/tmp.* _clean_tmp
if [ -z "$(ls -A1 "${BUILD_DIR}")" ]; then abort "All builds failed."; fi if [ -z "$(ls -A1 "${BUILD_DIR}")" ]; then abort "All builds failed."; fi
log "\nInstall [Microg](https://github.com/ReVanced/GmsCore/releases) for non-root YouTube and YT Music APKs" log "\nInstall [Microg](https://github.com/ReVanced/GmsCore/releases) for non-root YouTube and YT Music APKs"
+7 -13
View File
@@ -8,6 +8,7 @@ parallel-jobs = 1
[YouTube] [YouTube]
build-mode = "both" build-mode = "both"
excluded-patches = "'Custom branding'"
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube"
uptodown-dlurl = "https://youtube.en.uptodown.com/android" uptodown-dlurl = "https://youtube.en.uptodown.com/android"
archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube"
@@ -18,6 +19,7 @@ patches-source = "MorpheApp/morphe-patches"
cli-source = "MorpheApp/morphe-cli" cli-source = "MorpheApp/morphe-cli"
rv-brand = "Morphe" rv-brand = "Morphe"
build-mode = "both" build-mode = "both"
excluded-patches = "'Custom branding'"
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube"
uptodown-dlurl = "https://youtube.en.uptodown.com/android" uptodown-dlurl = "https://youtube.en.uptodown.com/android"
archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube"
@@ -25,6 +27,7 @@ archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.y
[Music] [Music]
build-mode = "both" build-mode = "both"
arch = "both" arch = "both"
excluded-patches = "'Custom branding'"
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music"
uptodown-dlurl = "https://youtube-music.en.uptodown.com/android" uptodown-dlurl = "https://youtube-music.en.uptodown.com/android"
archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music"
@@ -36,6 +39,7 @@ cli-source = "MorpheApp/morphe-cli"
rv-brand = "Morphe" rv-brand = "Morphe"
build-mode = "both" build-mode = "both"
arch = "both" arch = "both"
excluded-patches = "'Custom branding'"
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music"
uptodown-dlurl = "https://youtube-music.en.uptodown.com/android" uptodown-dlurl = "https://youtube-music.en.uptodown.com/android"
archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music"
@@ -43,15 +47,17 @@ archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.a
[Reddit-Morphe] [Reddit-Morphe]
app-name = "Reddit" app-name = "Reddit"
rv-brand = "Morphe" rv-brand = "Morphe"
build-mode = "both" build-mode = "apk"
patches-source = "MorpheApp/morphe-patches" patches-source = "MorpheApp/morphe-patches"
cli-source = "MorpheApp/morphe-cli" cli-source = "MorpheApp/morphe-cli"
apkmirror-dlurl = "https://www.apkmirror.com/apk/redditinc/reddit/" apkmirror-dlurl = "https://www.apkmirror.com/apk/redditinc/reddit/"
archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.reddit.frontpage" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.reddit.frontpage"
uptodown-dlurl = "https://reddit-official-app.en.uptodown.com/android" uptodown-dlurl = "https://reddit-official-app.en.uptodown.com/android"
excluded-patches = "'Custom branding name for Reddit'"
dpi = "120-640dpi" dpi = "120-640dpi"
[Twitter] [Twitter]
enabled = false
patches-source = "crimera/piko" patches-source = "crimera/piko"
cli-source = "MorpheApp/morphe-cli" cli-source = "MorpheApp/morphe-cli"
rv-brand = "Piko" rv-brand = "Piko"
@@ -62,24 +68,12 @@ version = "11.81.0-release.0"
include-stock = "split" include-stock = "split"
[GooglePhotos] [GooglePhotos]
patches-source = "RookieEnough/De-Vanced"
cli-source = "MorpheApp/morphe-cli"
rv-brand = "De-Vanced"
build-mode = "both" build-mode = "both"
arch = "both" arch = "both"
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/photos/" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/photos/"
uptodown-dlurl = "https://google-photos.en.uptodown.com/android" uptodown-dlurl = "https://google-photos.en.uptodown.com/android"
archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.photos" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.photos"
[Instagram]
patches-source = "RookieEnough/De-Vanced"
cli-source = "MorpheApp/morphe-cli"
rv-brand = "De-Vanced"
build-mode = "both"
arch = "both"
apkmirror-dlurl = "https://www.apkmirror.com/apk/instagram/instagram-instagram/"
uptodown-dlurl = "https://instagram.en.uptodown.com/android"
[Twitch] [Twitch]
enabled = false enabled = false
apkmirror-dlurl = "https://www.apkmirror.com/apk/twitch-interactive-inc/twitch/" apkmirror-dlurl = "https://www.apkmirror.com/apk/twitch-interactive-inc/twitch/"
-3
View File
@@ -1,3 +0,0 @@
libs
obj
*.mk
-128
View File
@@ -1,128 +0,0 @@
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
#include <unistd.h>
#define KSU_INSTALL_MAGIC1 0xDEADBEEF
#define KSU_INSTALL_MAGIC2 0xCAFEBABE
#define KSU_APP_PROFILE_VER 2
#define KSU_MAX_PACKAGE_NAME 256
#define KSU_MAX_GROUPS 32
#define KSU_SELINUX_DOMAIN 64
#define KSU_IOCTL_MAGIC 'K'
#define KSU_IOCTL_UID_SHOULD_UMOUNT _IOC(_IOC_READ | _IOC_WRITE, KSU_IOCTL_MAGIC, 9, 0)
#define KSU_IOCTL_GET_MANAGER_APPID _IOC(_IOC_READ, KSU_IOCTL_MAGIC, 10, 0)
#define KSU_IOCTL_GET_APP_PROFILE _IOC(_IOC_READ | _IOC_WRITE, KSU_IOCTL_MAGIC, 11, 0)
#define KSU_IOCTL_SET_APP_PROFILE _IOC(_IOC_WRITE, KSU_IOCTL_MAGIC, 12, 0)
struct root_profile {
int32_t uid;
int32_t gid;
int32_t groups_count;
int32_t groups[KSU_MAX_GROUPS];
struct {
uint64_t effective;
uint64_t permitted;
uint64_t inheritable;
} capabilities;
char selinux_domain[KSU_SELINUX_DOMAIN];
int32_t namespaces;
};
struct non_root_profile {
bool umount_modules;
};
struct app_profile {
uint32_t version;
char key[KSU_MAX_PACKAGE_NAME];
int32_t current_uid;
bool allow_su;
union {
struct {
bool use_default;
char template_name[KSU_MAX_PACKAGE_NAME];
struct root_profile profile;
} rp_config;
struct {
bool use_default;
struct non_root_profile profile;
} nrp_config;
};
};
struct ksu_uid_should_umount_cmd {
uint32_t uid;
uint8_t should_umount;
};
struct ksu_get_manager_appid_cmd {
uint32_t appid;
};
static int _fd = -1;
#define ksuctl(op, ...) (ioctl(_fd, op, __VA_ARGS__) >= 0)
#define REPORT_ERR() fprintf(stderr, "%s:%d ERROR: %s\n", __FILE__, __LINE__, strerror(errno));
int main(int argc, char* argv[]) {
if (argc <= 2) {
fprintf(stderr,
"ksu_profile (github.com/j-hc)\n"
"Disables \"Unmount modules\" for given package\n"
" Usage: %s <pkg uid> <pkg name>\n",
argv[0]);
return 1;
}
syscall(SYS_reboot, KSU_INSTALL_MAGIC1, KSU_INSTALL_MAGIC2, 0, &_fd);
if (_fd == -1) {
REPORT_ERR();
return 1;
}
long uid = atol(argv[1]);
struct ksu_uid_should_umount_cmd umount_cmd = {0};
if (!ksuctl(KSU_IOCTL_UID_SHOULD_UMOUNT, &umount_cmd)) {
REPORT_ERR();
return 1;
}
if (!umount_cmd.should_umount) return 0;
struct ksu_get_manager_appid_cmd appid_cmd = {0};
if (!ksuctl(KSU_IOCTL_GET_MANAGER_APPID, &appid_cmd)) {
REPORT_ERR();
return 1;
}
if (setuid(appid_cmd.appid) != 0) {
REPORT_ERR();
return 1;
}
struct app_profile profile = {0};
profile.current_uid = uid;
if (!ksuctl(KSU_IOCTL_GET_APP_PROFILE, &profile)) {
printf("Create profile for %s\n", argv[2]);
profile.version = KSU_APP_PROFILE_VER;
strncpy(profile.key, argv[2], sizeof(profile.key) / sizeof(profile.key[0]));
}
profile.nrp_config.use_default = false;
profile.nrp_config.profile.umount_modules = false;
if (!ksuctl(KSU_IOCTL_SET_APP_PROFILE, &profile)) {
REPORT_ERR();
return 1;
}
return 0;
}
+23
View File
@@ -0,0 +1,23 @@
#!/system/bin/sh
MODDIR=${0%/*}
. "$MODDIR/utils.sh"
DFILE="$MODDIR/disabled_by_action"
if [ -z "$(get_mounts)" ]; then
rm -f "$DFILE"
if mount_nosleep; then
echo "* Enabled successfully"
cp -f "$MODDIR/module.prop.orig" "$MODDIR/module.prop"
else
echo "* Failed"
fi
echo ""
get_mounts
else
touch "$DFILE"
umount_all
echo "* Disabled"
ch_desc "⛔ Disabled by action"
fi
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+23 -36
View File
@@ -1,4 +1,6 @@
. "$MODPATH/config" #!/system/bin/sh
MODDIR=$MODPATH
. "$MODPATH/utils.sh"
ui_print "" ui_print ""
if [ -n "$MODULE_ARCH" ] && [ "$MODULE_ARCH" != "$ARCH" ]; then if [ -n "$MODULE_ARCH" ] && [ "$MODULE_ARCH" != "$ARCH" ]; then
@@ -15,27 +17,10 @@ elif [ "$ARCH" = "x86" ]; then
elif [ "$ARCH" = "x64" ]; then elif [ "$ARCH" = "x64" ]; then
ARCH_LIB=x86_64 ARCH_LIB=x86_64
else abort "ERROR: unreachable: ${ARCH}"; fi else abort "ERROR: unreachable: ${ARCH}"; fi
RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk
set_perm_recursive "$MODPATH/bin" 0 0 0755 0777 set_perm_recursive "$MODPATH/bin" 0 0 0755 0777
if su -M -c true >/dev/null 2>/dev/null; then umount_all
alias mm='su -M -c'
else alias mm='nsenter -t1 -m'; fi
mm grep -F "$PKG_NAME" /proc/mounts | while read -r line; do
ui_print "* Un-mount"
mp=${line#* } mp=${mp%% *}
mm umount -l "${mp%%\\*}"
done
am force-stop "$PKG_NAME"
pmex() {
OP=$(pm "$@" 2>&1 </dev/null)
RET=$?
echo "$OP"
return $RET
}
if OP=$(dumpsys package "$PKG_NAME") && [ "$OP" ]; then if OP=$(dumpsys package "$PKG_NAME") && [ "$OP" ]; then
if echo "$OP" | grep -m1 pkgFlags | grep -Fq UPDATED_SYSTEM_APP; then if echo "$OP" | grep -m1 pkgFlags | grep -Fq UPDATED_SYSTEM_APP; then
@@ -48,9 +33,7 @@ else
fi fi
INS=true INS=true
if BASEPATH=$(pmex path "$PKG_NAME"); then if BASEPATH=$(get_basepath); then
echo >&2 "'$BASEPATH'"
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ "${BASEPATH:1:4}" != data ]; then if [ "${BASEPATH:1:4}" != data ]; then
ui_print "* Detected $PKG_NAME as a system app" ui_print "* Detected $PKG_NAME as a system app"
SCNM="/data/adb/post-fs-data.d/$PKG_NAME-uninstall.sh" SCNM="/data/adb/post-fs-data.d/$PKG_NAME-uninstall.sh"
@@ -63,7 +46,7 @@ if BASEPATH=$(pmex path "$PKG_NAME"); then
abort abort
fi fi
VERSION=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 versionName=) VERSION="${VERSION#*=}" VERSION=$(get_app_version)
if [ "$VERSION" ] && [ "$VERSION" = "$PKG_VER" ]; then if [ "$VERSION" ] && [ "$VERSION" = "$PKG_VER" ]; then
ui_print "* $PKG_NAME is up-to-date ($VERSION)" ui_print "* $PKG_NAME is up-to-date ($VERSION)"
INS=false INS=false
@@ -113,9 +96,13 @@ install() {
if ! op=$(pmex install-commit "$SES"); then if ! op=$(pmex install-commit "$SES"); then
ui_print "$op" ui_print "$op"
if echo "$op" | grep -q -e INSTALL_FAILED_VERSION_DOWNGRADE -e INSTALL_FAILED_UPDATE_INCOMPATIBLE; then if echo "$op" | grep -q -e INSTALL_FAILED_VERSION_DOWNGRADE -e INSTALL_FAILED_UPDATE_INCOMPATIBLE -e INSTALL_FAILED_DUPLICATE; then
ui_print "* Uninstalling..." ui_print "* Uninstalling..."
if ! op=$(pmex uninstall "$PKG_NAME"); then ex_unins_arg=""
if echo "$op" | grep -q INSTALL_FAILED_DUPLICATE; then
ex_unins_arg="-k"
fi
if ! op=$(pmex uninstall --user 0 $ex_unins_arg "$PKG_NAME"); then
ui_print "$op" ui_print "$op"
if [ $IT = 2 ]; then if [ $IT = 2 ]; then
install_err="ERROR: pm uninstall failed." install_err="ERROR: pm uninstall failed."
@@ -128,8 +115,8 @@ install() {
install_err="$op" install_err="$op"
break break
fi fi
if BASEPATH=$(pmex path "$PKG_NAME"); then if BASEPATH=$(get_basepath); then
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*} :
else else
install_err=" " install_err=" "
break break
@@ -154,37 +141,36 @@ if [ $INS = true ] || [ -z "$(ls -A1 "$BASEPATHLIB")" ]; then
fi fi
fi fi
ui_print "* Setting Permissions"
set_perm "$MODPATH/base.apk" 1000 1000 644 u:object_r:apk_data_file:s0 set_perm "$MODPATH/base.apk" 1000 1000 644 u:object_r:apk_data_file:s0
ui_print "* Mounting $PKG_NAME" ui_print "* Mounting $PKG_NAME"
# move out the apk from /data/adb/modules/.. to /data/adb/rvhc to not trip some root detections
mkdir -p "/data/adb/rvhc" mkdir -p "/data/adb/rvhc"
RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk
mv -f "$MODPATH/base.apk" "$RVPATH" mv -f "$MODPATH/base.apk" "$RVPATH"
if ! op=$(mm mount -o bind "$RVPATH" "$BASEPATH/base.apk" 2>&1); then if ! op=$(su -M -c mount -o bind "$RVPATH" "$BASEPATH/base.apk" 2>&1); then
ui_print "ERROR: Mount failed!" ui_print "ERROR: Mount failed!"
ui_print "$op" ui_print "$op"
fi fi
am force-stop "$PKG_NAME" am force-stop "$PKG_NAME"
ui_print "* Optimizing $PKG_NAME"
ui_print "* Optimizing $PKG_NAME"
cmd package compile -m speed-profile -f "$PKG_NAME" >/dev/null 2>&1 cmd package compile -m speed-profile -f "$PKG_NAME" >/dev/null 2>&1
# nohup cmd package compile -m speed-profile -f "$PKG_NAME" >/dev/null 2>&1 # nohup cmd package compile -m speed-profile -f "$PKG_NAME" >/dev/null 2>&1
if [ "$KSU" ]; then if [ "$KSU" ]; then
UID=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 uid=) DUMPSYS=$(dumpsys package "$PKG_NAME" 2>&1)
UID=$(echo "$DUMPSYS" | grep -m1 uid=)
UID=${UID#*=} UID=${UID%% *} UID=${UID#*=} UID=${UID%% *}
if [ -z "$UID" ]; then if [ -z "$UID" ]; then
UID=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 userId=) UID=$(echo "$DUMPSYS" | grep -m1 userId=)
UID=${UID#*=} UID=${UID%% *} UID=${UID#*=} UID=${UID%% *}
fi fi
if [ "$UID" ]; then if [ "$UID" ]; then
if ! OP=$("${MODPATH:?}/bin/$ARCH/ksu_profile" "$UID" "$PKG_NAME" 2>&1); then if ! OP=$("${MODPATH:?}/bin/$ARCH/ksu_profile" "$UID" "$PKG_NAME" 2>&1); then
ui_print " $OP" ui_print " $OP"
ui_print "* Because you are using a fork of KernelSU, " ui_print " * In your root manager app,"
ui_print " you need to go to your root manager app and" ui_print " disable 'Unmount modules' for $PKG_NAME"
ui_print " disable 'Unmount modules' for $PKG_NAME"
fi fi
else else
ui_print "ERROR: UID could not be found for $PKG_NAME" ui_print "ERROR: UID could not be found for $PKG_NAME"
@@ -192,6 +178,7 @@ if [ "$KSU" ]; then
fi fi
rm -rf "${MODPATH:?}/bin" "$MODPATH/stock/" rm -rf "${MODPATH:?}/bin" "$MODPATH/stock/"
cp -f "$MODPATH/module.prop" "$MODPATH/module.prop.orig"
ui_print "* Done" ui_print "* Done"
ui_print " by j-hc (github.com/j-hc)" ui_print " by j-hc (github.com/j-hc)"
+15 -38
View File
@@ -1,49 +1,26 @@
#!/system/bin/sh #!/system/bin/sh
MODDIR=${0%/*} MODDIR=${0%/*}
RVPATH=/data/adb/rvhc/${MODDIR##*/}.apk . "$MODDIR/utils.sh"
. "$MODDIR/config"
err() {
[ ! -f "$MODDIR/err" ] && cp "$MODDIR/module.prop" "$MODDIR/err"
sed -i "s/^des.*/description=⚠️ Needs reflash: '${1}'/g" "$MODDIR/module.prop"
}
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
until [ -d "/sdcard/Android" ]; do sleep 1; done
while
BASEPATH=$(pm path "$PKG_NAME" 2>&1 </dev/null)
SVCL=$?
[ $SVCL = 20 ]
do sleep 2; done
run() { run() {
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
until [ -d "/sdcard/Android" ]; do sleep 1; done
while
BASEPATH=$(get_basepath)
SVCL=$?
[ $SVCL = 20 ]
do sleep 2; done
if [ $SVCL != 0 ]; then if [ $SVCL != 0 ]; then
err "app not installed" ch_desc_err "App not installed"
return return
fi fi
sleep 4 sleep 4
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*} mount_rv "$BASEPATH"
if [ ! -d "$BASEPATH/lib" ]; then
err "mount failed. Dont report this, consider using rvmm-zygisk-mount"
return
fi
VERSION=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 versionName) VERSION="${VERSION#*=}"
if [ "$VERSION" != "$PKG_VER" ] && [ "$VERSION" ]; then
err "version mismatch (installed:${VERSION}, module:$PKG_VER)"
return
fi
grep "$PKG_NAME" /proc/mounts | while read -r line; do
mp=${line#* } mp=${mp%% *}
umount -l "${mp%%\\*}"
done
if ! chcon u:object_r:apk_data_file:s0 "$RVPATH"; then
err "apk not found"
return
fi
mount -o bind "$RVPATH" "$BASEPATH/base.apk"
am force-stop "$PKG_NAME"
[ -f "$MODDIR/err" ] && mv -f "$MODDIR/err" "$MODDIR/module.prop"
} }
run if [ ! -f "$MODDIR/disabled_by_action" ]; then
run
fi
+74
View File
@@ -0,0 +1,74 @@
#!/system/bin/sh
RVPATH=/data/adb/rvhc/${MODDIR##*/}.apk
. "$MODDIR/config"
ch_desc() {
sed -i "s/^des.*/description=${1}/g" "$MODDIR/module.prop"
}
ch_desc_err() {
ch_desc "⚠️ Needs reflash: '${1}'"
}
pmex() {
OP=$(pm "$@" 2>&1 </dev/null)
RET=$?
echo "$OP"
return $RET
}
get_app_version() {
VERSION=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 versionName=) VERSION="${VERSION#*=}"
echo "$VERSION"
}
get_basepath() {
BASEPATH=$(pmex path "$PKG_NAME")
SVCL=$?
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
echo "$BASEPATH"
return $SVCL
}
umount_all() {
su -M -c grep -F "$PKG_NAME" /proc/mounts | while read -r line; do
mp=${line#* } mp=${mp%% *} mp=${mp%%\\*}
su -M -c umount -l "${mp}"
done
am force-stop "$PKG_NAME" || :
}
get_mounts() {
su -M -c grep -F "$PKG_NAME" /proc/mounts || :
}
mount_rv() {
if [ ! -d "${1}/lib" ]; then
ch_desc_err "Mount failed. Dont report this, consider using rvmm-zygisk-mount"
return 1
fi
VERSION=$(get_app_version)
if [ "$VERSION" != "$PKG_VER" ] && [ "$VERSION" ]; then
ch_desc_err "Version mismatch (installed:${VERSION}, module:$PKG_VER)"
return 1
fi
umount_all
if ! chcon u:object_r:apk_data_file:s0 "$RVPATH"; then
ch_desc_err "Apk not found"
return 1
fi
mount -o bind "$RVPATH" "${1}/base.apk"
am force-stop "$PKG_NAME"
cp -f "$MODDIR/module.prop.orig" "$MODDIR/module.prop"
return 0
}
mount_nosleep() {
if ! BASEPATH=$(get_basepath); then
ch_desc_err "App not installed"
return 1
fi
mount_rv "$BASEPATH"
}
@@ -1,33 +0,0 @@
#!/sbin/sh
#################
# Initialization
#################
umask 022
# echo before loading util_functions
ui_print() { echo "$1"; }
require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v20.4+! "
ui_print "*******************************"
exit 1
}
#########################
# Load util_functions.sh
#########################
OUTFD=$2
ZIPFILE=$3
mount /data 2>/dev/null
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /data/adb/magisk/util_functions.sh
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
install_module
exit 0
@@ -1 +0,0 @@
#MAGISK
-185
View File
@@ -1,185 +0,0 @@
. "$MODPATH/config"
ui_print ""
if [ -n "$MODULE_ARCH" ] && [ "$MODULE_ARCH" != "$ARCH" ]; then
abort "ERROR: Wrong arch
Your device: $ARCH
Module: $MODULE_ARCH"
fi
if [ "$ARCH" = "arm" ]; then
ARCH_LIB=armeabi-v7a
elif [ "$ARCH" = "arm64" ]; then
ARCH_LIB=arm64-v8a
elif [ "$ARCH" = "x86" ]; then
ARCH_LIB=x86
elif [ "$ARCH" = "x64" ]; then
ARCH_LIB=x86_64
else abort "ERROR: unreachable: ${ARCH}"; fi
RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk
set_perm_recursive "$MODPATH/bin" 0 0 0755 0777
if su -M -c true >/dev/null 2>/dev/null; then
alias mm='su -M -c'
else alias mm='nsenter -t1 -m'; fi
mm grep -F "$PKG_NAME" /proc/mounts | while read -r line; do
ui_print "* Un-mount"
mp=${line#* } mp=${mp%% *}
mm umount -l "${mp%%\\*}"
done
am force-stop "$PKG_NAME"
pmex() {
OP=$(pm "$@" 2>&1 </dev/null)
RET=$?
echo "$OP"
return $RET
}
if ! pmex path "$PKG_NAME" >&2; then
if pmex install-existing "$PKG_NAME" >&2; then
BASEPATH=$(pmex path "$PKG_NAME") || abort "ERROR: pm path failed $BASEPATH"
echo >&2 "'$BASEPATH'"
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ "${BASEPATH:1:4}" = data ]; then
if pmex uninstall -k --user 0 "$PKG_NAME" >&2; then
rm -rf "$BASEPATH" 2>&1
ui_print "* Cleared existing $PKG_NAME package"
ui_print "* Reboot and reflash"
abort
else abort "ERROR: pm uninstall failed"; fi
else ui_print "* Installed stock $PKG_NAME package"; fi
fi
fi
IS_SYS=false
INS=true
if BASEPATH=$(pmex path "$PKG_NAME"); then
echo >&2 "'$BASEPATH'"
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ "${BASEPATH:1:4}" != data ]; then
ui_print "* $PKG_NAME is a system app."
IS_SYS=true
elif [ ! -f "$MODPATH/$PKG_NAME.apk" ]; then
ui_print "* Stock $PKG_NAME APK was not found"
VERSION=$(dumpsys package "$PKG_NAME" | grep -m1 versionName) VERSION="${VERSION#*=}"
if [ "$VERSION" = "$PKG_VER" ] || [ -z "$VERSION" ]; then
ui_print "* Skipping stock installation"
INS=false
else
abort "ERROR: Version mismatch
installed: $VERSION
module: $PKG_VER
"
fi
elif "${MODPATH:?}/bin/$ARCH/cmpr" "$BASEPATH/base.apk" "$MODPATH/$PKG_NAME.apk"; then
ui_print "* $PKG_NAME is up-to-date"
INS=false
fi
fi
install() {
if [ ! -f "$MODPATH/$PKG_NAME.apk" ]; then
abort "ERROR: Stock $PKG_NAME apk was not found"
fi
ui_print "* Updating $PKG_NAME to $PKG_VER"
install_err=""
VERIF1=$(settings get global verifier_verify_adb_installs)
VERIF2=$(settings get global package_verifier_enable)
settings put global verifier_verify_adb_installs 0
settings put global package_verifier_enable 0
SZ=$(stat -c "%s" "$MODPATH/$PKG_NAME.apk")
for IT in 1 2; do
if ! SES=$(pmex install-create --user 0 -i com.android.vending -r -d -S "$SZ"); then
ui_print "ERROR: install-create failed"
install_err="$SES"
break
fi
SES=${SES#*[} SES=${SES%]*}
set_perm "$MODPATH/$PKG_NAME.apk" 1000 1000 644 u:object_r:apk_data_file:s0
if ! op=$(pmex install-write -S "$SZ" "$SES" "$PKG_NAME.apk" "$MODPATH/$PKG_NAME.apk"); then
ui_print "ERROR: install-write failed"
install_err="$op"
break
fi
if ! op=$(pmex install-commit "$SES"); then
if echo "$op" | grep -q INSTALL_FAILED_VERSION_DOWNGRADE; then
ui_print "* Handling INSTALL_FAILED_VERSION_DOWNGRADE.."
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"
chmod +x "$SCNM"
ui_print "* Created the uninstall script."
ui_print ""
ui_print "* Reboot and reflash the module!"
install_err=" "
break
else
ui_print "* Uninstalling..."
if ! op=$(pmex uninstall -k --user 0 "$PKG_NAME"); then
ui_print "$op"
if [ $IT = 2 ]; then
install_err="ERROR: pm uninstall failed."
break
fi
fi
continue
fi
fi
ui_print "ERROR: install-commit failed"
install_err="$op"
break
fi
if BASEPATH=$(pmex path "$PKG_NAME"); then
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
else
install_err="ERROR: install $PKG_NAME manually and reflash the module"
break
fi
break
done
settings put global verifier_verify_adb_installs "$VERIF1"
settings put global package_verifier_enable "$VERIF2"
if [ "$install_err" ]; then abort "$install_err"; fi
}
if [ $INS = true ] && ! install; then abort; fi
BASEPATHLIB=${BASEPATH}/lib/${ARCH}
if [ $INS = true ] || [ -z "$(ls -A1 "$BASEPATHLIB")" ]; then
ui_print "* Extracting native libs"
if [ ! -d "$BASEPATHLIB" ]; then mkdir -p "$BASEPATHLIB"; else rm -f "$BASEPATHLIB"/* >/dev/null 2>&1 || :; fi
if ! op=$(unzip -o -j "$MODPATH/$PKG_NAME.apk" "lib/${ARCH_LIB}/*" -d "$BASEPATHLIB" 2>&1); then
ui_print "ERROR: extracting native libs failed"
abort "$op"
fi
set_perm_recursive "${BASEPATH}/lib" 1000 1000 755 755 u:object_r:apk_data_file:s0
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"
if ! op=$(mm mount -o bind "$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"
if [ "$KSU" ] && [ -d "/data/adb/modules/zygisk-assistant" ]; then
ui_print "* If you are using zygisk-assistant, you need to"
ui_print " give root permissions to $PKG_NAME"
fi
ui_print "* Done"
ui_print " by j-hc (github.com/j-hc)"
ui_print " "
-49
View File
@@ -1,49 +0,0 @@
#!/system/bin/sh
MODDIR=${0%/*}
RVPATH=/data/adb/rvhc/${MODDIR##*/}.apk
. "$MODDIR/config"
err() {
[ ! -f "$MODDIR/err" ] && cp "$MODDIR/module.prop" "$MODDIR/err"
sed -i "s/^des.*/description=⚠️ Needs reflash: '${1}'/g" "$MODDIR/module.prop"
}
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
until [ -d "/sdcard/Android" ]; do sleep 1; done
while
BASEPATH=$(pm path "$PKG_NAME" 2>&1 </dev/null)
SVCL=$?
[ $SVCL = 20 ]
do sleep 2; done
run() {
if [ $SVCL != 0 ]; then
err "app not installed"
return
fi
sleep 4
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ ! -d "$BASEPATH/lib" ]; then # TODO: is this ok? idk
ls -Zla "$BASEPATH" >"$MODDIR/log.txt"
ls -Zla "$BASEPATH/lib" >>"$MODDIR/log.txt"
else rm "$MODDIR/log.txt" >/dev/null 2>&1; fi
VERSION=$(dumpsys package "$PKG_NAME" | grep -m1 versionName) VERSION="${VERSION#*=}"
if [ "$VERSION" != "$PKG_VER" ] && [ "$VERSION" ]; then
err "version mismatch (installed:${VERSION}, module:$PKG_VER)"
return
fi
grep "$PKG_NAME" /proc/mounts | while read -r line; do
mp=${line#* } mp=${mp%% *}
umount -l "${mp%%\\*}"
done
if ! chcon u:object_r:apk_data_file:s0 "$RVPATH"; then
err "apk not found"
return
fi
mount -o bind "$RVPATH" "$BASEPATH/base.apk"
am force-stop "$PKG_NAME"
[ -f "$MODDIR/err" ] && mv -f "$MODDIR/err" "$MODDIR/module.prop"
}
run
-9
View File
@@ -1,9 +0,0 @@
#!/system/bin/sh
{
MODDIR=${0%/*}
. "$MODDIR/config"
rm "/data/adb/rvhc/${MODDIR##*/}.apk"
rmdir "/data/adb/rvhc"
rm "/data/adb/post-fs-data.d/$PKG_NAME-uninstall.sh"
} &
+42 -24
View File
@@ -45,11 +45,16 @@ wpr() {
echo >&2 -e "\033[0;33m[!] ${1}\033[0m" echo >&2 -e "\033[0;33m[!] ${1}\033[0m"
if [ "${GITHUB_REPOSITORY-}" ]; then echo >&2 -e "::warning::utils.sh [!] ${1}\n"; fi if [ "${GITHUB_REPOSITORY-}" ]; then echo >&2 -e "::warning::utils.sh [!] ${1}\n"; fi
} }
_clean_tmp() {
rm -rf ./${TEMP_DIR}/*tmp.* ./${TEMP_DIR}/*tmp_* ./${TEMP_DIR}/*/*tmp.* ./${TEMP_DIR}/*-temporary-files ./*-temporary-files
}
abort() { abort() {
epr "ABORT: ${1-}" epr "ABORT: ${1-}"
rm -rf ./${TEMP_DIR}/*tmp.* ./${TEMP_DIR}/*/*tmp.* ./${TEMP_DIR}/*-temporary-files ./*-temporary-files _clean_tmp
trap - SIGTERM SIGINT EXIT trap - SIGTERM SIGINT EXIT
kill -- -$$ 2>/dev/null kill -9 -- -$$ 2>/dev/null
exit 1 exit 1
} }
java() { env -i java --enable-native-access=ALL-UNNAMED "$@"; } java() { env -i java --enable-native-access=ALL-UNNAMED "$@"; }
@@ -61,15 +66,9 @@ get_prebuilts() {
cl_dir=${TEMP_DIR}/${cl_dir,,}-rv cl_dir=${TEMP_DIR}/${cl_dir,,}-rv
[ -d "$cl_dir" ] || mkdir "$cl_dir" [ -d "$cl_dir" ] || mkdir "$cl_dir"
for src_ver in "$cli_src CLI $cli_ver cli" "$patches_src Patches $patches_ver patches"; do for src_ver in "Patches $patches_src $patches_ver" "CLI $cli_src $cli_ver"; do
set -- $src_ver set -- $src_ver
local src=$1 tag=$2 ver=${3-} fprefix=$4 local tag=$1 src=$2 ver=${3-}
if [ "$tag" = "CLI" ]; then
local grab_cl=false
elif [ "$tag" = "Patches" ]; then
local grab_cl=true
else abort unreachable; fi
local dir=${src%/*} local dir=${src%/*}
dir=${TEMP_DIR}/${dir,,}-rv dir=${TEMP_DIR}/${dir,,}-rv
@@ -89,8 +88,16 @@ get_prebuilts() {
name_ver="$ver" name_ver="$ver"
fi fi
local url file tag_name matches local file
file=$(find "$dir" -name "*${fprefix}-${name_ver#v}.*" -type f 2>/dev/null) if [ "$tag" = "CLI" ]; then
file=$(find "$dir" -maxdepth 1 -name "*cli-${name_ver#v}*.jar" -o -name "*desktop-${name_ver#v}*.jar" -type f 2>/dev/null)
local grab_cl=false
elif [ "$tag" = "Patches" ]; then
file=$(find "$dir" -maxdepth 1 -name "*patches-${name_ver#v}.*" -type f 2>/dev/null)
local grab_cl=true
else abort unreachable; fi
local url tag_name matches
if [ "$ver" = "latest" ]; then if [ "$ver" = "latest" ]; then
file=$(grep -v '/[^/]*dev[^/]*$' <<<"$file" | head -1) file=$(grep -v '/[^/]*dev[^/]*$' <<<"$file" | head -1)
else else
@@ -244,7 +251,7 @@ get_highest_ver() {
local vers m local vers m
vers=$(tee) vers=$(tee)
m=$(head -1 <<<"$vers") m=$(head -1 <<<"$vers")
if ! semver_validate "$m"; then echo "$m"; else sort -rV <<<"$vers" | head -1; fi if ! semver_validate "$m"; then echo "$m"; else sort -s -t- -k1,1Vr <<<"$vers" | head -1; fi
} }
semver_validate() { semver_validate() {
local a="${1%-*}" local a="${1%-*}"
@@ -349,7 +356,7 @@ apkmirror_search() {
local dlurl="" node app_table emptyCheck local dlurl="" node app_table emptyCheck
local apparch=('universal' 'noarch' 'arm64-v8a + armeabi-v7a') local apparch=('universal' 'noarch' 'arm64-v8a + armeabi-v7a')
if [ "$arch" != all ]; then if [ "$arch" != "all" ]; then
apparch+=("$arch") apparch+=("$arch")
fi fi
@@ -504,7 +511,7 @@ get_uptodown_pkg_name() { $HTMLQ --text "tr.full:nth-child(1) > td:nth-child(3)"
# -------------------- archive -------------------- # -------------------- archive --------------------
dl_archive() { dl_archive() {
local url=$1 version=$2 output=$3 arch=$4 local url=$1 version=$2 output=$3 arch=$4
local path output_m version=${version// /} local path version=${version// /}
if [ -f "${output}.apkm" ]; then if [ -f "${output}.apkm" ]; then
merge_splits "${output}.apkm" "$output" merge_splits "${output}.apkm" "$output"
@@ -513,13 +520,10 @@ dl_archive() {
path=$(grep -m1 "${version_f#v}-${arch// /}" <<<"$__ARCHIVE_RESP__") || return 1 path=$(grep -m1 "${version_f#v}-${arch// /}" <<<"$__ARCHIVE_RESP__") || return 1
if [ "${path##*.}" = "apkm" ]; then if [ "${path##*.}" = "apkm" ]; then
output_m="${output}.apkm" req "${url}/${path}" "${output}.apkm" || return 1
merge_splits "${output}.apkm" "$output"
else else
output_m=$output req "${url}/${path}" "${output}" || return 1
fi
req "${url}/${path}" "$output_m" || return 1
if [ "${path##*.}" = "apkm" ]; then
merge_splits "$output_m" "$output"
fi fi
} }
get_archive_resp() { get_archive_resp() {
@@ -534,7 +538,16 @@ get_archive_pkg_name() { echo "$__ARCHIVE_PKG_NAME__"; }
# -------------------- direct -------------------- # -------------------- direct --------------------
dl_direct() { dl_direct() {
local url=$1 version=${2// /-} output=$3 arch=$4 _dpi=$5 local url=$1 version=${2// /-} output=$3 arch=$4 _dpi=$5
req "$url" "${output}" || return 1 if ! grep -q "${version_f#v}-${arch// /}" <<<"$url"; then
epr "Given direct-dlurl for $output is not compatible. Set proper 'arch' and 'version' options."
return 1
fi
if [ "${url##*.}" = "apkm" ]; then
req "$url" "${output}.apkm" || return 1
merge_splits "${output}.apkm" "$output"
else
req "$url" "${output}" || return 1
fi
} }
get_direct_vers() { cut -d- -f2 <<<"$__DIRECT_APKNAME__"; } get_direct_vers() { cut -d- -f2 <<<"$__DIRECT_APKNAME__"; }
get_direct_pkg_name() { cut -d- -f1 <<<"$__DIRECT_APKNAME__"; } get_direct_pkg_name() { cut -d- -f1 <<<"$__DIRECT_APKNAME__"; }
@@ -543,8 +556,11 @@ get_direct_resp() { __DIRECT_APKNAME__=$(awk -F/ '{print $NF}' <<<"$1"); }
patch_apk() { patch_apk() {
local stock_input=$1 patched_apk=$2 patcher_args=$3 cli_jar=$4 patches_jar=$5 local stock_input=$1 patched_apk=$2 patcher_args=$3 cli_jar=$4 patches_jar=$5
local cmd="java -jar '$cli_jar' patch '$stock_input' --purge -o '$patched_apk' -p '$patches_jar' --keystore=ks.keystore \ local tmp_files
--keystore-entry-password=123456789 --keystore-password=123456789 --signer=jhc --keystore-entry-alias=jhc $patcher_args" tmp_files="$(pwd)/$(mktemp -d -p "$TEMP_DIR")"
local cmd="java -jar '$cli_jar' patch '$stock_input' -o '$patched_apk' -p '$patches_jar' --keystore=ks.keystore \
--keystore-entry-password=123456789 --keystore-password=123456789 --signer=jhc --keystore-entry-alias=jhc -t '$tmp_files' $patcher_args"
# TODO: remove this later # TODO: remove this later
local cli_name local cli_name
@@ -743,6 +759,8 @@ build_rv() {
if [ "$build_mode" = apk ]; then if [ "$build_mode" = apk ]; then
if [ "${NORB:-}" != true ] || { [ ! -f "$patched_apk" ] && [ ! -f "$apk_output" ]; }; then if [ "${NORB:-}" != true ] || { [ ! -f "$patched_apk" ] && [ ! -f "$apk_output" ]; }; then
mv -f "$patched_apk" "$apk_output" mv -f "$patched_apk" "$apk_output"
else
cp -f "$patched_apk" "$apk_output"
fi fi
pr "Built ${table} (non-root): '${apk_output}'" pr "Built ${table} (non-root): '${apk_output}'"
continue continue