CommonPatcher: don't do anything if ROM is pre-patched

merge-requests/23/head
Christopher Roy Bratusek 6 years ago
parent a3e9d116d4
commit 9c4d0f8b02

@ -16,9 +16,6 @@
### General Changes
* CommonInstaller
* when detecting system properties also look if /vendor/build.prop exists
* CommonAddon
* sync GApps removal list with CommonInstaller
@ -28,6 +25,7 @@
* Full, microG packages
* if the ROM is pre-patched with FAKE_PACKAGE_SIGNATURE include that permission from the default permission files
* solves incompatibility with LineageOS for microG @Vavun
* function to detect whether ROM is pre-patched @ale5000
* if the ROM includes a SetupWizard (mostly on stock), properly disable it (in Magisk Mode)
* solves incompatibility with stock ROM SetupWizard and microg @DoR3M3
* for System Mode installation, check the Issues section of the README on how to solve this
@ -36,11 +34,14 @@
* improved version of the `external_sd` init script @Vavun
* CommonInstaller, CommonPatcher
* when detecting system properties also look if /vendor/build.prop exists
* support both /data/adb/magisk and /data/magisk
* remove old code regarding Magisk
* CommonPatcher
* when creating a backup of `services.jar` append `ro.build.flavor` and `ro.build.id`
* if the ROM is pre-patched with FAKE_PACKAGE_SIGNATURE don't do anything
* function to detect whether ROM is pre-patched @ale5000
* re-add UnifiedNlp patch by Tom Vincent
* Uninstaller

@ -706,7 +706,7 @@ gapps_destroy_artifacts () {
}
##########################################################################################
# Magisk Mode Installation
# by @ale5000
##########################################################################################
search_fake_package_signature () {

@ -140,12 +140,11 @@ detect_bootmode () {
}
grep_prop() {
REGEX="${1}"
shift
FILES="${@}"
[ -z "${@}" ] && FILES='/system/build.prop'
sed -n "s/^${REGEX}=//p" ${FILES} | \
head -n 1
[ -f /vendor/build.prop ] && \
FILES="/system/build.prop /vendor/build.prop" || \
FILES="/system/build.prop"
sed -n "s/^${1}=//p" ${FILES} | head -n 1
}
grep_cmdline() {
@ -257,16 +256,16 @@ detect_sdk () {
[ "${SDK_VERSION}" -lt 16 ] && \
error "Android versions before Jelly Bean are not supported"
if [ "${SDK_VERSION}" -gt 25 ]; then
BAKSMALI="${BASEDIR}/baksmali_26.dex"
SMALI="${BASEDIR}/smali_26.dex"
elif [ "${SDK_VERSION}" -gt 23 ]; then
BAKSMALI="${BASEDIR}/baksmali_25.dex"
SMALI="${BASEDIR}/smali_25.dex"
else
BAKSMALI="${BASEDIR}/baksmali_23.dex"
SMALI="${BASEDIR}/smali_23.dex"
fi
if [ "${SDK_VERSION}" -gt 25 ]; then
BAKSMALI="${BASEDIR}/baksmali_26.dex"
SMALI="${BASEDIR}/smali_26.dex"
elif [ "${SDK_VERSION}" -gt 23 ]; then
BAKSMALI="${BASEDIR}/baksmali_25.dex"
SMALI="${BASEDIR}/smali_25.dex"
else
BAKSMALI="${BASEDIR}/baksmali_23.dex"
SMALI="${BASEDIR}/smali_23.dex"
fi
PATCH_CORE="${BASEDIR}/core_services.jar.dex"
PATCH_UNLP="${BASEDIR}/unifiednlp_services.jar.dex"
@ -282,6 +281,25 @@ detect_sdk () {
[ "${SDK_VERSION}" -gt 21 ] && DEX_OPTS="--multi-dex-threaded"
}
##########################################################################################
# by @ale5000
##########################################################################################
search_fake_package_signature () {
PERMISSION=android.permission.FAKE_PACKAGE_SIGNATURE
PERMISSION_OD=$(echo -n "${PERMISSION}" | od -A n -t x1 | tr -d '\n' | sed -e 's/^ //g;s/ /00/g')
HAS_FAKESIGN=false
FW_RES_DIR="${TMPDIR}/framework-res"
mkdir -p "${FW_RES_DIR}"
unzip -o /system/framework/framework-res.apk -d "${FW_RES_DIR}"
grep -qF "${PERMISSION}" "${FW_RES_DIR}/AndroidManifest.xml" && HAS_FAKESIGN=true
od -A n -t x1 "${FW_RES_DIR}/AndroidManifest.xml" | tr -d ' \n' | grep -qF "${PERMISSION_OD}" && HAS_FAKESIGN=true
${HAS_FAKESIGN} && return 0 || return 1
}
##########################################################################################
# Magisk Functions
##########################################################################################

@ -39,6 +39,8 @@ elif [ -f /data/adb/NanoDroid_Patched ]; then
ui_print " !! /data/adb/NanoDroid_Patched exists"
ui_print " !! if you want to force patching, then"
error " remove this file and try again"
elif search_fake_package_signature; then
error " ROM has native signature spoofing already!"
fi
setup_patcher

Loading…
Cancel
Save