mirror of
https://gitlab.com/Nanolx/NanoDroid
synced 2024-10-31 09:20:23 +00:00
patcher:
- import improved apex mount code from Magisk - import bootclasspath setup from Magisk - possibly improve support for Android <9
This commit is contained in:
parent
85c749c734
commit
0779e0cdff
@ -67,27 +67,29 @@ mount_apex_loop () {
|
|||||||
# taken from Magisk, with modifications for NanoDroid
|
# taken from Magisk, with modifications for NanoDroid
|
||||||
mount_apex () {
|
mount_apex () {
|
||||||
mkdir -p /apex
|
mkdir -p /apex
|
||||||
|
local pattern='s/.*"name":[^"]*"\([^"]*\).*/\1/p'
|
||||||
APEX_LD=""
|
mount -t tmpfs tmpfs /apex -o mode=755
|
||||||
|
|
||||||
for apex in /system/apex/*; do
|
for apex in /system/apex/*; do
|
||||||
apex_mount="/apex/$(basename ${apex} .apex)"
|
|
||||||
apex_loop="/dev/loop_apex_$(basename ${apex} .apex)"
|
apex_loop="/dev/loop_apex_$(basename ${apex} .apex)"
|
||||||
|
|
||||||
[ "${apex_mount}" == /apex/com.android.runtime.release ] && apex_mount=/apex/com.android.runtime
|
|
||||||
[ "${apex_mount}" == /apex/com.android.runtime.debug ] && apex_mount=/apex/com.android.runtime
|
|
||||||
[ "${apex_mount}" == /apex/com.android.art.release ] && apex_mount=/apex/com.android.art
|
|
||||||
[ "${apex_mount}" == /apex/com.android.art.debug ] && apex_mount=/apex/com.android.art
|
|
||||||
|
|
||||||
APEX_LD="${apex_mount}/lib:${APEX_LD}"
|
|
||||||
APEX_LD_64="${apex_mount}/lib64:${APEX_LD_64}"
|
|
||||||
|
|
||||||
mkdir -p "${apex_mount}"
|
|
||||||
|
|
||||||
if [ -f "${apex}" ]; then
|
if [ -f "${apex}" ]; then
|
||||||
unzip -oq "${apex}" apex_payload.img -d /apex
|
unzip -oq "${apex}" apex_payload.img -d /apex
|
||||||
|
apex_mount=$(unzip -qp ${apex} apex_manifest.pb | strings | head -n 1)
|
||||||
|
[ -z ${apex_mount} ] && apex_mount=$(unzip -qp ${apex} apex_manifest.json | sed -n ${pattern})
|
||||||
|
[ -z ${apex_mount} ] && continue
|
||||||
|
|
||||||
|
mkdir -p "${apex_mount}"
|
||||||
mount_apex_loop "${apex_mount}" || error "APEX loop setup failed!"
|
mount_apex_loop "${apex_mount}" || error "APEX loop setup failed!"
|
||||||
elif [ -d "${apex}" ]; then
|
elif [ -d "${apex}" ]; then
|
||||||
|
if [ -f ${apex}/apex_manifest.json ]; then
|
||||||
|
apex_mount=/apex/$(sed -n ${pattern} ${apex}/apex_manifest.json)
|
||||||
|
elif [ -f ${apex}/apex_manifest.pb ]; then
|
||||||
|
apex_mount=/apex/$(strings ${apex}/apex_manifest.pb | head -n 1)
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
mkdir -p "${apex_mount}"
|
||||||
mount -o bind "${apex}" "${apex_mount}"
|
mount -o bind "${apex}" "${apex_mount}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -202,14 +204,9 @@ mount_partitions () {
|
|||||||
|
|
||||||
[ ! -f /system/build.prop ] && error "failed to mount /system (unsupported A/B device?)"
|
[ ! -f /system/build.prop ] && error "failed to mount /system (unsupported A/B device?)"
|
||||||
|
|
||||||
if [ -d /apex/com.android.art ]; then
|
|
||||||
export ANDROID_ART_ROOT=/apex/com.android.art
|
|
||||||
export ANDROID_RUNTIME_ROOT=${ANDROID_ART_ROOT}
|
|
||||||
elif [ -d /apex/com.android.runtime ]; then
|
|
||||||
export ANDROID_RUNTIME_ROOT=/apex/com.android.runtime
|
export ANDROID_RUNTIME_ROOT=/apex/com.android.runtime
|
||||||
fi
|
|
||||||
|
|
||||||
export ANDROID_TZDATA_ROOT=/apex/com.android.tzdata
|
export ANDROID_TZDATA_ROOT=/apex/com.android.tzdata
|
||||||
|
export ANDROID_ART_ROOT=/apex/com.android.art
|
||||||
export ANDROID_I18N_ROOT=/apex/com.android.i18n
|
export ANDROID_I18N_ROOT=/apex/com.android.i18n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,8 +222,9 @@ umount_partitions () {
|
|||||||
done
|
done
|
||||||
|
|
||||||
unset ANDROID_RUNTIME_ROOT
|
unset ANDROID_RUNTIME_ROOT
|
||||||
unset ANDROID_ART_ROOT
|
|
||||||
unset ANDROID_TZDATA_ROOT
|
unset ANDROID_TZDATA_ROOT
|
||||||
|
unset ANDROID_ART_ROOT
|
||||||
|
unset ANDROID_I18N_ROOT
|
||||||
unset BOOTCLASSPATH
|
unset BOOTCLASSPATH
|
||||||
|
|
||||||
rm -rf /apex
|
rm -rf /apex
|
||||||
@ -523,14 +521,10 @@ call_dalvikvm () {
|
|||||||
DALVIKVM_OPTS=""
|
DALVIKVM_OPTS=""
|
||||||
|
|
||||||
if ! ${BOOTMODE}; then
|
if ! ${BOOTMODE}; then
|
||||||
for jar in /system/framework/*.jar; do
|
local apex_jars=$(find /apex -name '*.jar' | sort | tr '\n' ':')
|
||||||
ND_BOOTCLASSPATH="${jar}:${ND_BOOTCLASSPATH}"
|
local frame=/system/framework
|
||||||
done
|
ND_BOOTCLASSPATH="${apex_jars}:${frame}/framework.jar:${frame}/ext.jar:${frame}/telephony-common.jar:\
|
||||||
|
${frame}/voip-common.jar:${frame}/ims-common.jar:$frame}/telephony-ext.jar"
|
||||||
for jar in /apex/*/javalib/*.jar; do
|
|
||||||
ND_BOOTCLASSPATH="${jar}:${ND_BOOTCLASSPATH}"
|
|
||||||
done
|
|
||||||
|
|
||||||
export BOOTCLASSPATH=${ND_BOOTCLASSPATH}
|
export BOOTCLASSPATH=${ND_BOOTCLASSPATH}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -578,13 +572,13 @@ deodex_odex () {
|
|||||||
MAIN=main
|
MAIN=main
|
||||||
DEODEX="-x"
|
DEODEX="-x"
|
||||||
ASSEMBLE=
|
ASSEMBLE=
|
||||||
BOOTCLASSPATH="-c"
|
BOOTCLASS="-c"
|
||||||
else
|
else
|
||||||
MAIN=Main
|
MAIN=Main
|
||||||
DEODEX="x"
|
DEODEX="x"
|
||||||
ASSEMBLE="a"
|
ASSEMBLE="a"
|
||||||
BOOTCLASSPATH="-b"
|
BOOTCLASS="-b"
|
||||||
CLASSPATHDIR="-d"
|
CLASSPATH="-d"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ui_print " [1] baksmali services.odex"
|
ui_print " [1] baksmali services.odex"
|
||||||
@ -593,9 +587,9 @@ deodex_odex () {
|
|||||||
-classpath "${BAKSMALI}" \
|
-classpath "${BAKSMALI}" \
|
||||||
org.jf.baksmali.${MAIN} \
|
org.jf.baksmali.${MAIN} \
|
||||||
${DEODEX} \
|
${DEODEX} \
|
||||||
${BOOTCLASSPATH} "/system/framework/${ARCH}/boot.oat" \
|
${BOOTCLASS} "/system/framework/${ARCH}/boot.oat" \
|
||||||
${CLASSPATHDIR} "/system/framework/${ARCH}" \
|
${CLASSPATH} "/system/framework/${ARCH}" \
|
||||||
${CLASSPATHDIR} "/system/framework" \
|
${CLASSPATH} "/system/framework" \
|
||||||
-o "${BASEDIR}/services.jar-deodex" \
|
-o "${BASEDIR}/services.jar-deodex" \
|
||||||
"${BASEDIR}/services.odex" || \
|
"${BASEDIR}/services.odex" || \
|
||||||
error "failed to deodex services.jar"
|
error "failed to deodex services.jar"
|
||||||
|
Loading…
Reference in New Issue
Block a user