CommonInstaller:

- improve detecting block devices for /system and /vendor
- don't report magisk mount points when logging mounts
- change we way we detect whether we run Magisk Mode installation
- make check_fake_package_signature distinguish between native and self patched ROMs
- improve update information for Magisk Manager
- minor internal simplifications
merge-requests/33/head
Christopher Roy Bratusek 4 years ago
parent 27f3111005
commit 310479ce26

@ -305,7 +305,7 @@ mount_apex () {
mount_partitions () {
if ${BOOTMODE}; then
APEX_LD=/apex/com.android.runtime
export build_props=$(find /system /system_root /vendor -type f -name build.prop)
build_props=$(find /system /system_root /vendor -type f -name build.prop)
else
DEVICE_AB=FALSE
VENDOR_COMPAT=FALSE
@ -323,7 +323,7 @@ mount_partitions () {
fi
fi
system_tmp=$(find /dev/block -type l -name system${SLOT} | head -n 1)
system_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name system${SLOT} | head -n 1)
echo " INFO: #4 [system_tmp] ${system_tmp}"
SYSTEM_BLOCK=$(readlink -f ${system_tmp})
echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
@ -343,7 +343,7 @@ mount_partitions () {
mount -o bind /system_root/system /system
fi
vendor_tmp=$(find /dev/block -type l -name vendor${SLOT} | head -n 1)
vendor_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name vendor${SLOT} | head -n 1)
echo " INFO: #6 [vendor_tmp] ${vendor_tmp}"
VENDOR_BLOCK=$(readlink -f ${vendor_tmp})
echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
@ -357,13 +357,13 @@ mount_partitions () {
fi
echo " "
mount | awk '{print $1 " on " $3 " params: " $6}'
mount | sed -e '/magisk/d' | awk '{print $1 " on " $3 " params: " $6}'
echo " "
echo " INFO: #8 [prop]"
ls -l /system/*.prop
export build_props=$(find /system /system_root /vendor -type f -name build.prop)
build_props=$(find /system /system_root /vendor -type f -name build.prop)
echo " INFO: #9 [build_props] ${build_props}"
[ -z "${build_props}" ] && error "failed to mount /system (unsupported A/B device?)"
@ -401,20 +401,21 @@ detect_mode () {
;;
0 | *)
MODE=SYSTEM
MODE_DETECT=detected
MODE=SYSTEM
for magisk in /data/adb/magisk/magisk /data/magisk/magisk \
/data/.magisk/magisk /data/adb/modules; do
if [ -e ${magisk} ]; then
MODE=MAGISK
break
fi
done
[ -f /data/adb/magisk/util_functions.sh ] && \
. /data/adb/magisk/util_functions.sh || \
error "Could not load Magisk util_functions.sh"
if [ -f "${NANODROID_LIST}" ]; then
if [ ${MAGISK_VER_CODE} -ge 19000 ]; then
MODE=MAGISK
else
print_info " "
print_info "Magisk 19.0 or newer is required!"
print_info "falling back to /system installation!"
print_info " "
MODE=SYSTEM
NANODROID_UPGRADE=1
fi
;;
esac
@ -426,6 +427,8 @@ detect_mode () {
SYSTEM )
recovery_setup_env
unset MODPATH
[ -f "${NANODROID_LIST}" ] && NANODROID_UPGRADE=1
;;
MAGISK )
@ -722,20 +725,6 @@ magisk_install_setup () {
print_info " "
print_info " > setup Magisk environment"
if [ -f /data/adb/magisk/util_functions.sh ]; then
. /data/adb/magisk/util_functions.sh
else
error "Could not load Magisk util_functions.sh"
fi
if [ ${MAGISK_VER_CODE} -gt 18100 ]; then
MAGIKSBASE=/data/adb
recovery_setup_env
else
error "Magisk version 19.0 or newer is required"
fi
case ${MODID} in
NanoDroid )
# check for sub-modules which are not
@ -750,7 +739,6 @@ magisk_install_setup () {
if [ -d ${MAGIKSBASE}/modules_update/${dir} ]; then
print_info " !! ${dir} module detected - uninstalling!"
rm -rf ${MAGIKSBASE}/modules_update/${dir}
NANODROID_UPGRADE=1
fi
done
;;
@ -770,7 +758,7 @@ magisk_install_setup () {
;;
esac
[ -d ${MODPATH} -o -d ${OVERLAYPATH} ] && NANODROID_UPGRADE=1
[ -d ${MODPATH} ] && NANODROID_UPGRADE=1
[ "${NANODROID_UPGRADE}" -eq 1 ] && \
MODPATH=${MAGIKSBASE}/modules_update/${MODID} || \
@ -832,7 +820,10 @@ magisk_install_finish () {
;;
esac
${BOOTMODE} && touch ${MAGIKSBASE}/modules/${MODID}/update 2>/dev/null
if ${BOOTMODE}; then
touch "${MAGISKBASE}/modules/${MODID}/update" 2>/dev/null
cp -af "${INSTALLER}/module.prop" "${MAGISKBASE}/modules/${MODID}/module.prop" 2>/dev/null
fi
sync
nanodroid_storelogs
@ -904,28 +895,64 @@ gapps_destroy_artifacts () {
##########################################################################################
# check if ROM has native fake signature spoofing support
# by @ale5000
# origingally by @ale5000 - revised by me
##########################################################################################
check_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
FRAMEWORKRES_PATCH=false
SERVICESJAR_PATCH=false
mkdir -p ${TMPDIR}/sigcheck
# natively patched ROM: only framework-res.apk patched (old)
# natively patched ROM: both framework-res.apk and services.jar patched (new)
# self patched ROM: only services.jar patched
# check framework-res.apk for the patch
unzip -oq /system/framework/framework-res.apk AndroidManifest.xml -d "${TMPDIR}/sigcheck" \
|| error "failed to unpack framework-res.apk"
unzip -o /system/framework/services.jar *.dex -d "${TMPDIR}/sigcheck" \
if grep -qF "${PERMISSION}" "${TMPDIR}"/sigcheck/AndroidManifest.xml; then
HAS_FAKESIGN=true
FRAMEWORKRES_PATCH=true
fi
if od -A n -t x1 "${TMPDIR}"/sigcheck/AndroidManifest.xml | tr -d ' \n' | grep -qF "${PERMISSION_OD}"; then
HAS_FAKESIGN=true
FRAMEWORKRES_PATCH=true
fi
# check services.jar for the patch
unzip -oq /system/framework/services.jar *.dex -d "${TMPDIR}/sigcheck" \
|| error "failed to unpack services.jar"
grep -qF "${PERMISSION}" "${TMPDIR}"/sigcheck/* && HAS_FAKESIGN=true
od -A n -t x1 "${TMPDIR}"/sigcheck/* | tr -d ' \n' | grep -qF "${PERMISSION_OD}" && HAS_FAKESIGN=true
if grep -qF "${PERMISSION}" "${TMPDIR}"/sigcheck/*.dex; then
HAS_FAKESIGN=true
SERVICESJAR_PATCH=true
fi
if od -A n -t x1 "${TMPDIR}"/sigcheck/*.dex | tr -d ' \n' | grep -qF "${PERMISSION_OD}"; then
HAS_FAKESIGN=true
SERVICESJAR_PATCH=true
fi
# we don't use this anywhere (except in SysTest log),
# but may still come in hand in the future
if ${FRAMEWORKRES_PATCH} && ! ${SERVICESJAR_PATCH}; then
PATCH_TYPE="native_old"
elif ${FRAMEWORKRES_PATCH} && ${SERVICESJAR_PATCH}; then
PATCH_TYPE="native_new"
elif ! ${FRAMEWORKRES_PATCH} && ${SERVICESJAR_PATCH}; then
PATCH_TYPE="self_patched"
fi
${HAS_FAKESIGN} && return 0 || return 1
}
##########################################################################################
# check if Bromite System WebView is supported
##########################################################################################

Loading…
Cancel
Save