From a408df090d2d7ccae77a07b2a232b4dbab134137 Mon Sep 17 00:00:00 2001 From: Jim Wu Date: Wed, 29 Jan 2020 22:06:00 +0800 Subject: [PATCH] Add support for deprecated custom Magisk 20.1 --- edxp-core/template_override/customize.sh | 21 ++++++++---- edxp-core/template_override/post-fs-data.sh | 38 ++++++++++----------- edxp-core/template_override/uninstall.sh | 4 +-- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/edxp-core/template_override/customize.sh b/edxp-core/template_override/customize.sh index 8f8a66ff..3dbe9db7 100644 --- a/edxp-core/template_override/customize.sh +++ b/edxp-core/template_override/customize.sh @@ -31,11 +31,19 @@ HUAWEI require_new_magisk() { ui_print "******************************" ui_print "! Special device detected" - ui_print "! Magisk v20.2+ is required" + ui_print "! Magisk v20.2+ or custom Magisk v20.1(Deprecated) is required" ui_print "! You can update from 'Magisk Manager' or https://github.com/topjohnwu/Magisk/releases" abort "******************************" } +update_new_magisk() { + ui_print "******************************" + ui_print "- Deprecated custom Magisk v20.1 detected" + ui_print "- We will still keep the rule file for you" + ui_print "- You can update to the latest Magisk directly from official update channel" + ui_print "******************************" +} + require_riru() { ui_print "******************************" ui_print "! Requirement module 'Riru - Core' is not installed" @@ -76,7 +84,7 @@ check_old_magisk_device() { ui_print "- And support may be cancelled in subsequent versions" ui_print "- In any case, you should update to the latest version in time" ui_print "******************************" - if [[ "${DETECTED_DEVICE}" = true ]]; then + if [[ "${DETECTED_DEVICE}" == true ]]; then require_new_magisk fi } @@ -107,11 +115,12 @@ check_magisk_version() { DETECTED_DEVICE=true fi done - if [[ "${DETECTED_DEVICE}" = true ]]; then + if [[ "${DETECTED_DEVICE}" == true ]]; then ui_print "- Special device detected" fi ui_print "- Magisk version is ${MAGISK_VER_CODE}" - [[ ${MAGISK_VER_CODE} -ge 20102 ]] || check_old_magisk_device ${MAGISK_VER_CODE} + [[ ${MAGISK_VER_CODE} -ge 20101 ]] || check_old_magisk_device ${MAGISK_VER_CODE} + [[ ${MAGISK_VER_CODE} -eq 20101 ]] || update_new_magisk } check_riru_version() { @@ -163,12 +172,12 @@ if [[ "${ARCH}" == "x86" || "${ARCH}" == "x64" ]]; then rm -rf "${MODPATH}/system_x86" fi -if [[ "${IS64BIT}" = false ]]; then +if [[ "${IS64BIT}" == false ]]; then ui_print "- Removing 64-bit libraries" rm -rf "${MODPATH}/system/lib64" fi -if [[ "${OLD_MAGISK}" = true ]]; then +if [[ "${OLD_MAGISK}" == true ]]; then ui_print "- Removing sepolicy rule for old Magisk" rm ${MODPATH}/sepolicy.rule fi diff --git a/edxp-core/template_override/post-fs-data.sh b/edxp-core/template_override/post-fs-data.sh index 9f6b46f0..7de6fd0b 100644 --- a/edxp-core/template_override/post-fs-data.sh +++ b/edxp-core/template_override/post-fs-data.sh @@ -35,18 +35,15 @@ PATH_PREFIX_LEGACY="/data/user/0/" sepolicy() { # necessary for using mmap in system_server process - supolicy --live "allow system_server system_server process {execmem}" - supolicy --live "allow system_server system_server memprotect {mmap_zero}" - - # for built-in apps // TODO maybe narrow down the target classes - supolicy --live "allow coredomain coredomain process {execmem}" - # read configs set in our app - supolicy --live "allow coredomain app_data_file * *" - supolicy --live "attradd {system_app platform_app} mlstrustedsubject" - + # for built-in apps // TODO: maybe narrow down the target classes # read module apk file in zygote - supolicy --live "allow zygote apk_data_file * *" + supolicy --live "allow system_server system_server process { execmem }"\ + "allow system_server system_server memprotect { mmap_zero }"\ + "allow coredomain coredomain process { execmem }"\ + "allow coredomain app_data_file * *"\ + "attradd { system_app platform_app } mlstrustedsubject"\ + "allow zygote apk_data_file * *" } if [[ ${ANDROID_SDK} -ge 24 ]]; then @@ -88,12 +85,12 @@ start_log_cather () { LOG_FILE="${LOG_PATH}/${LOG_FILE_NAME}.log" PID_FILE="${LOG_PATH}/${LOG_FILE_NAME}.pid" mkdir -p ${LOG_PATH} - if [[ ${CLEAN_OLD} = true ]]; then + if [[ ${CLEAN_OLD} == true ]]; then rm "${LOG_FILE}.old" mv "${LOG_FILE}" "${LOG_FILE}.old" fi rm "${LOG_PATH}/${LOG_FILE_NAME}.pid" - if [[ ${START_NEW} = false ]]; then + if [[ ${START_NEW} == false ]]; then return fi touch ${LOG_FILE} @@ -140,13 +137,12 @@ start_bridge_log_catcher () { start_log_cather error "XSharedPreferences:V EdXposed-Bridge:V" true true } -chcon -R u:object_r:system_file:s0 "${MODDIR}" - -# Backup app_process to avoid bootloop caused by original Xposed replacement -#rm -rf "${MODDIR}/system/bin" -#mkdir "${MODDIR}/system/bin" -#cp -f "/system/bin/app_process32" "${MODDIR}/system/bin/app_process32" -#[[ -f "/system/bin/app_process64" ]] && cp -f "/system/bin/app_process64" "${MODDIR}/system/bin/app_process64" +# Backup app_process to avoid bootloop caused by original Xposed replacement in Android Oreo +# TODO: Magisk mount replace +rm -rf "${MODDIR}/system/bin" +mkdir "${MODDIR}/system/bin" +cp -f "/system/bin/app_process32" "${MODDIR}/system/bin/app_process32" +[[ -f "/system/bin/app_process64" ]] && cp -f "/system/bin/app_process64" "${MODDIR}/system/bin/app_process64" start_verbose_log_catcher start_bridge_log_catcher @@ -155,4 +151,6 @@ start_bridge_log_catcher cp "${MODDIR}/module.prop" "${TARGET}/module.prop" -[[ -f "${MODDIR}/sepolicy.rule" ]] || sepolicy \ No newline at end of file +[[ -f "${MODDIR}/sepolicy.rule" ]] || sepolicy + +chcon -R u:object_r:system_file:s0 "${MODDIR}" \ No newline at end of file diff --git a/edxp-core/template_override/uninstall.sh b/edxp-core/template_override/uninstall.sh index e498395b..f14483d2 100644 --- a/edxp-core/template_override/uninstall.sh +++ b/edxp-core/template_override/uninstall.sh @@ -6,13 +6,13 @@ REMOVE=false [[ "$(echo ${MODDIR} | grep sandhook)" != "" ]] && VARIANT="SandHook" -if [[ "${VARIANT}"=="SandHook" ]]; then +if [[ "${VARIANT}" == "SandHook" ]]; then [[ -f "${MODDIR}/../riru_edxposed/module.prop" ]] || REMOVE=true else [[ -f "${MODDIR}/../riru_edxposed_sandhook/module.prop" ]] || REMOVE=true fi -if [[ "${REMOVE}" = true ]]; then +if [[ "${REMOVE}" == true ]]; then rm -rf /data/misc/riru/modules/edxp fi