2018-03-20 17:52:53 +00:00
|
|
|
#!/sbin/sh
|
|
|
|
##########################################################################################
|
|
|
|
#
|
|
|
|
# NanoDroid Patcher survival script
|
|
|
|
# by Nanolx
|
|
|
|
#
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Generic Functions
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
setup_environment () {
|
|
|
|
TMPDIR=/dev/tmp/install
|
|
|
|
export ANDROID_DATA="${TMPDIR}"
|
|
|
|
PATH="${PATH}:/system/bin:/system/xbin"
|
|
|
|
MAGISK_IMG=/data/adb/magisk.img
|
|
|
|
MAGISK_PATH=/dev/tmp/magisk_img
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_print() {
|
|
|
|
if $BOOTMODE; then
|
|
|
|
echo "$1"
|
|
|
|
else
|
|
|
|
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
|
|
|
|
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
is_mounted () {
|
|
|
|
if [ ! -z "$2" ]; then
|
|
|
|
cat /proc/mounts | grep $1 | grep $2, >/dev/null
|
|
|
|
else
|
|
|
|
cat /proc/mounts | grep $1 >/dev/null
|
|
|
|
fi
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
mount_image() {
|
|
|
|
if [ ! -d "$2" ]; then
|
|
|
|
mount -o rw,remount rootfs /
|
|
|
|
mkdir -p "$2" 2>/dev/null
|
|
|
|
[ ! -d "$2" ] && return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! is_mounted "$2"; then
|
|
|
|
LOOPDEVICE=
|
|
|
|
for LOOP in 0 1 2 3 4 5 6 7; do
|
|
|
|
if ! is_mounted "$2"; then
|
|
|
|
LOOPDEVICE=/dev/block/loop$LOOP
|
|
|
|
[ -e $LOOPDEVICE ] || mknod $LOOPDEVICE b 7 $LOOP 2>/dev/null
|
|
|
|
losetup $LOOPDEVICE "$1" && mount -t ext4 -o loop $LOOPDEVICE "$2"
|
|
|
|
if is_mounted "$2"; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# taken from Magisk, with minor modifications for NanoDroid
|
|
|
|
mount_partitions () {
|
2018-07-08 17:10:37 +00:00
|
|
|
SLOT=$(grep_cmdline androidboot.slot_suffix)
|
2018-03-20 17:52:53 +00:00
|
|
|
if [ -z ${SLOT} ]; then
|
2018-08-05 11:17:16 +00:00
|
|
|
SLOT=_$(grep_cmdline androidboot.slot)
|
2018-03-20 17:52:53 +00:00
|
|
|
[ "${SLOT}" = "_" ] && SLOT=
|
|
|
|
fi
|
|
|
|
|
2018-08-05 11:17:16 +00:00
|
|
|
is_mounted /data || mount /data
|
2018-03-20 17:52:53 +00:00
|
|
|
|
|
|
|
${BOOTMODE} || mount -o bind /dev/urandom /dev/random
|
|
|
|
|
2018-08-05 11:17:16 +00:00
|
|
|
! is_mounted /system && mount -o rw /system
|
2018-03-20 17:52:53 +00:00
|
|
|
|
|
|
|
if [ ! -f /system/build.prop ]; then
|
|
|
|
SYSTEMBLOCK=$(find /dev/block -iname system${SLOT} | head -n 1)
|
2018-08-05 11:17:16 +00:00
|
|
|
mount -t ext4 -o rw ${SYSTEMBLOCK} /system
|
2018-03-20 17:52:53 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-05 11:17:16 +00:00
|
|
|
[ -f /system/build.prop ] || is_mounted /system || error "failed to mount /system (unsupported A/B device?)"
|
2018-07-08 17:10:37 +00:00
|
|
|
|
|
|
|
if [ -f /system/init ]; then
|
2018-03-20 17:52:53 +00:00
|
|
|
mkdir /system_root 2>/dev/null
|
|
|
|
mount --move /system /system_root
|
|
|
|
mount -o bind /system_root/system /system
|
|
|
|
fi
|
2018-08-05 11:17:16 +00:00
|
|
|
|
|
|
|
[ ! -f /system/build.prop ] && error "failed to mount /system (unsupported A/B device?)"
|
2018-08-27 16:12:17 +00:00
|
|
|
|
|
|
|
if [ -L /system/vendor ]; then
|
|
|
|
is_mounted /vendor || mount -o ro /vendor 2>/dev/null
|
|
|
|
if ! is_mounted /vendor; then
|
|
|
|
VENDORBLOCK=$(find /dev/block -iname vendor${SLOT} | head -n 1)
|
|
|
|
mount -t ext4 -o ro ${VENDORBLOCK} /vendor
|
|
|
|
fi
|
|
|
|
is_mounted /vendor || error "failed to mount /vendor"
|
|
|
|
fi
|
2018-03-20 17:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
error () {
|
|
|
|
ui_print "${@}"
|
|
|
|
magisk_cleanup
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Device Functions
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
detect_outfd () {
|
|
|
|
readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null
|
|
|
|
if [ "$?" -eq "0" ]; then
|
|
|
|
OUTFD=0
|
|
|
|
|
|
|
|
for FD in `ls /proc/$$/fd`; do
|
|
|
|
readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null
|
|
|
|
if [ "$?" -eq "0" ]; then
|
|
|
|
ps | grep " 3 $FD " | grep -v grep >/dev/null
|
|
|
|
if [ "$?" -eq "0" ]; then
|
|
|
|
OUTFD=$FD
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
detect_bootmode () {
|
|
|
|
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
|
|
|
|
${BOOTMODE} || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
|
|
|
${BOOTMODE} || id | grep -q 'uid=0' || BOOTMODE=true
|
|
|
|
}
|
|
|
|
|
|
|
|
grep_prop() {
|
2018-08-05 11:17:16 +00:00
|
|
|
REGEX="${1}"
|
2018-03-20 17:52:53 +00:00
|
|
|
shift
|
2018-08-05 11:17:16 +00:00
|
|
|
FILES="${@}"
|
|
|
|
[ -z "${@}" ] && FILES='/system/build.prop'
|
|
|
|
sed -n "s/^${REGEX}=//p" ${FILES} | \
|
|
|
|
head -n 1
|
|
|
|
}
|
|
|
|
|
|
|
|
grep_cmdline() {
|
|
|
|
local REGEX="s/^${1}=//p"
|
|
|
|
sed -E 's/ +/\n/g' /proc/cmdline | \
|
|
|
|
sed -n "${REGEX}" 2>/dev/null
|
2018-03-20 17:52:53 +00:00
|
|
|
}
|
|
|
|
|
2018-08-26 19:07:23 +00:00
|
|
|
detect_classes_dex () {
|
2018-08-25 21:23:26 +00:00
|
|
|
SERVICES_JAR_DEX=$(unzip -lq /system/framework/services.jar | grep classes.dex)
|
|
|
|
|
2018-08-26 19:07:23 +00:00
|
|
|
if [ "${SERVICES_JAR_DEX}" ]; then
|
|
|
|
ROM_DEX_STATUS=DEODEX
|
|
|
|
else ROM_DEX_STATUS=${1}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
detect_odex () {
|
2018-08-25 21:23:26 +00:00
|
|
|
if [ -n "$(find '/system/framework/' -name '*.vdex')" ]; then
|
|
|
|
ui_print " "
|
|
|
|
ui_print " ++"
|
|
|
|
ui_print " ++ vdexed ROM detected"
|
|
|
|
ui_print " ++"
|
|
|
|
|
2018-08-26 19:07:23 +00:00
|
|
|
detect_classes_dex VDEX
|
2018-08-25 21:23:26 +00:00
|
|
|
elif [ -n "$(find '/system/framework/' -name '*.odex')" ]; then
|
|
|
|
ui_print " "
|
|
|
|
ui_print " ++"
|
|
|
|
ui_print " ++ odexed ROM detected"
|
|
|
|
ui_print " ++"
|
|
|
|
|
2018-08-26 19:07:23 +00:00
|
|
|
detect_classes_dex ODEX
|
2018-08-26 16:58:59 +00:00
|
|
|
elif [ "${SERVICES_JAR_DEX}" ]; then
|
2018-08-26 19:07:23 +00:00
|
|
|
ROM_DEX_STATUS=DEODEX
|
2018-08-26 16:58:59 +00:00
|
|
|
else
|
|
|
|
ROM_DEX_STATUS=UNKOWN
|
2018-08-24 19:24:01 +00:00
|
|
|
fi
|
2018-08-26 19:08:04 +00:00
|
|
|
|
|
|
|
echo " [++] ROM_DEX_STATUS=${ROM_DEX_STATUS}"
|
2018-03-20 17:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
detect_arch () {
|
|
|
|
ABI=$(grep_prop ro.product.cpu.abi | cut -c-3)
|
|
|
|
ABI2=$(grep_prop ro.product.cpu.abi2 | cut -c-3)
|
|
|
|
ABILONG=$(grep_prop ro.product.cpu.abi)
|
|
|
|
|
|
|
|
ARCH=arm
|
|
|
|
|
|
|
|
[ "$ABI" = "x86" ] && ARCH=x86
|
|
|
|
[ "$ABI2" = "x86" ] && ARCH=x86
|
|
|
|
[ "$ABILONG" = "arm64-v8a" ] && ARCH=arm64
|
|
|
|
[ "$ABILONG" = "x86_64" ] && ARCH=x86_64
|
|
|
|
|
|
|
|
case ${ARCH} in
|
|
|
|
arm | arm64 )
|
|
|
|
FILE=${BASEDIR}/file.arm
|
|
|
|
ZIPB=${BASEDIR}/zip.arm
|
2018-08-26 16:58:59 +00:00
|
|
|
|
|
|
|
if [ -f ${TMPDIR}/busybox.arm ]; then
|
|
|
|
BUSY=${TMPDIR}/busybox.arm
|
|
|
|
else BUSY=${BASEDIR}/busybox.arm
|
|
|
|
fi
|
2018-03-20 17:52:53 +00:00
|
|
|
;;
|
|
|
|
x86 | x86_64 )
|
|
|
|
FILE=${BASEDIR}/file.x86
|
|
|
|
ZIPB=${BASEDIR}/zip.x86
|
2018-08-26 16:58:59 +00:00
|
|
|
|
|
|
|
if [ -f ${TMPDIR}/busybox.x86 ]; then
|
|
|
|
BUSY=${TMPDIR}/busybox.x86
|
|
|
|
else BUSY=${BASEDIR}/busybox.x86
|
|
|
|
fi
|
2018-03-20 17:52:53 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-08-26 13:04:23 +00:00
|
|
|
V_EX=${BASEDIR}/vdexExtractor.${ARCH}
|
|
|
|
|
2018-08-26 16:58:59 +00:00
|
|
|
OLD_PATH=${PATH}
|
|
|
|
|
|
|
|
chmod 0755 ${BUSY}
|
|
|
|
mkdir -p ${BASEDIR}/busybox
|
|
|
|
ln -s ${BUSY} ${BASEDIR}/busybox/busybox
|
|
|
|
|
|
|
|
${BUSY} --install -s ${BASEDIR}/busybox/
|
|
|
|
|
|
|
|
export PATH="${BASEDIR}/busybox:${PATH}"
|
|
|
|
|
2018-03-20 17:52:53 +00:00
|
|
|
case ${ARCH} in
|
|
|
|
arm | x86 )
|
|
|
|
C_LD="/system/lib:/system/vendor/lib"
|
|
|
|
;;
|
|
|
|
|
|
|
|
arm64 | x86_64 )
|
|
|
|
C_LD="/system/lib64:/system/vendor/lib64"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
ui_print " > device architecture: ${ARCH}"
|
|
|
|
}
|
|
|
|
|
|
|
|
detect_sdk () {
|
|
|
|
SDK_VERSION=$(grep_prop ro.build.version.sdk)
|
|
|
|
|
2018-08-24 19:24:01 +00:00
|
|
|
[ "${SDK_VERSION}" -gt 28 ] && \
|
|
|
|
error " !! Android versions beyond Pie are not yet supported"
|
2018-03-20 17:52:53 +00:00
|
|
|
|
2018-08-26 17:03:06 +00:00
|
|
|
if [ "${SDK_VERSION}" -eq 28 ]; then
|
|
|
|
ui_print " "
|
|
|
|
ui_print " ++ Android Pie (9.0) support"
|
|
|
|
ui_print " ++ is currently experimental"
|
|
|
|
ui_print " "
|
|
|
|
fi
|
|
|
|
|
2018-03-20 17:52:53 +00:00
|
|
|
[ "${SDK_VERSION}" -lt 16 ] && \
|
|
|
|
error " !! Android versions before Jelly Bean are not supported"
|
|
|
|
|
|
|
|
if [ "${SDK_VERSION}" -lt 24 ]; then
|
|
|
|
ui_print " > Android 4.1 - 6.0 (SDK ${SDK_VERSION}) detected"
|
|
|
|
PATCH_HOOK="${BASEDIR}/hook_4.1-6.0_services.jar.dex"
|
|
|
|
PATCH_UI_SERVICES="${BASEDIR}/ui_4.1-6.0_services.jar.dex"
|
|
|
|
else
|
2018-08-24 19:24:01 +00:00
|
|
|
ui_print " > Android 7.0 - 9.0 (SDK ${SDK_VERSION}) detected"
|
|
|
|
PATCH_HOOK="${BASEDIR}/hook_7.0-9.0_services.jar.dex"
|
2018-03-20 17:52:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
[ "${SDK_VERSION}" -gt 21 ] && DEX_OPTS="--multi-dex-threaded"
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Magisk Functions
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
grow_magisk_img () {
|
|
|
|
request_size_check /tmp/services.jar
|
|
|
|
image_size_check ${MAGISK_IMG}
|
|
|
|
if [ "$reqSizeM" -gt "$curFreeM" ]; then
|
|
|
|
SIZE=$(((reqSizeM + curUsedM) / 32 * 32 + 64))
|
|
|
|
resize2fs -f ${MAGISK_IMG} ${SIZE}M
|
|
|
|
e2fsck -yf ${MAGISK_IMG}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
shrink_magisk_img () {
|
|
|
|
image_size_check ${MAGISK_IMG}
|
|
|
|
NEWDATASIZE=$((curUsedM / 32 * 32 + 32))
|
|
|
|
if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then
|
|
|
|
resize2fs -f ${MAGISK_IMG} ${NEWDATASIZE}M
|
|
|
|
e2fsck -yf ${MAGISK_IMG}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
request_size_check() {
|
|
|
|
reqSizeM=`unzip -l "$1" 2>/dev/null | tail -n 1 | awk '{ print $1 }'`
|
|
|
|
reqSizeM=$((reqSizeM / 1048576 + 1))
|
|
|
|
}
|
|
|
|
|
|
|
|
image_size_check() {
|
|
|
|
e2fsck -yf $1
|
|
|
|
curBlocks=`e2fsck -n $1 2>/dev/null | grep $1 | cut -d, -f3 | cut -d\ -f2`;
|
|
|
|
curUsedM=`echo "$curBlocks" | cut -d/ -f1`
|
|
|
|
curSizeM=`echo "$curBlocks" | cut -d/ -f1`
|
|
|
|
curFreeM=$(((curSizeM - curUsedM) * 4 / 1024))
|
|
|
|
curUsedM=$((curUsedM * 4 / 1024 + 1))
|
|
|
|
curSizeM=$((curSizeM * 4 / 1024))
|
|
|
|
}
|
|
|
|
|
|
|
|
magisk_setup () {
|
|
|
|
if [ -f ${MAGISK_IMG} ]; then
|
|
|
|
grow_magisk_img || \
|
|
|
|
error " !! failed to grow magisk.img"
|
|
|
|
mount_image ${MAGISK_IMG} ${MAGISK_PATH} || \
|
|
|
|
error " !! failed to mount ${MAGISK_PATH}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
magisk_cleanup () {
|
|
|
|
if (is_mounted ${MAGISK_PATH}); then
|
|
|
|
umount ${MAGISK_PATH}
|
|
|
|
losetup -d $LOOPDEVICE
|
|
|
|
rmdir ${MAGISK_PATH}
|
|
|
|
shrink_magisk_img || \
|
|
|
|
error " !! failed to shrink magisk.img"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Patcher Functions
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
setup_patcher () {
|
|
|
|
ui_print " > preparing environment"
|
|
|
|
|
|
|
|
rm -rf ${TMPDIR}
|
|
|
|
mkdir -p ${TMPDIR}
|
|
|
|
|
|
|
|
unzip -o "${ZIP}" -d ${TMPDIR} || \
|
|
|
|
error " !! failed to prepare environment"
|
|
|
|
|
2018-08-25 19:43:43 +00:00
|
|
|
for bin in zip.arm zip.x86 file.arm file.x86 \
|
2018-08-26 16:02:36 +00:00
|
|
|
vdexExtractor.arm vdexExtractor.x86 \
|
2018-08-26 16:58:59 +00:00
|
|
|
vdexExtractor.arm64 vdexExtractor.x86_64; do
|
2018-03-20 17:52:53 +00:00
|
|
|
chmod 0755 "${BASEDIR}/${bin}" || \
|
|
|
|
error " !! failed to prepare environment"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
patch_services () {
|
|
|
|
ui_print " "
|
|
|
|
ui_print " > patching signature spoofing support"
|
|
|
|
ui_print " "
|
|
|
|
|
|
|
|
cp /system/framework/services.jar \
|
|
|
|
${BASEDIR}/services.jar || \
|
|
|
|
error " !! failed to copy services.jar"
|
|
|
|
|
2018-08-26 10:53:17 +00:00
|
|
|
for jar in /system/framework/*.jar ; do
|
|
|
|
BOOTCLASSES=${BOOTCLASSES}:${jar}
|
|
|
|
done
|
|
|
|
|
2018-08-24 19:47:56 +00:00
|
|
|
#
|
2018-08-26 09:29:14 +00:00
|
|
|
# XXX vdex stuff
|
2018-08-24 19:47:56 +00:00
|
|
|
#
|
2018-08-25 19:43:43 +00:00
|
|
|
if [ "${ROM_DEX_STATUS}" = "VDEX" ]; then
|
|
|
|
ui_print " >> deodexing services.jar [VDEX]"
|
|
|
|
|
2018-08-25 19:44:44 +00:00
|
|
|
cp /system/framework/oat/${ARCH}/services.vdex \
|
2018-08-25 19:43:43 +00:00
|
|
|
${BASEDIR}/services.vdex || \
|
|
|
|
error " !! failed to copy services.vdex"
|
|
|
|
|
2018-08-25 19:44:14 +00:00
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
2018-08-26 16:02:36 +00:00
|
|
|
${V_EX} -i ${BASEDIR}/services.vdex \
|
|
|
|
--ignore-crc-error --debug=4 || \
|
2018-08-25 19:43:43 +00:00
|
|
|
error " !! failed to deodex services.vdex"
|
|
|
|
|
|
|
|
mv ${BASEDIR}/services.apk_classes.dex ${BASEDIR}/classes.dex || \
|
|
|
|
error " !! failed to deodex services.vdex"
|
|
|
|
|
|
|
|
# just in case | not allowed to call error() !
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
${ZIPB} -d "${BASEDIR}/services.jar" \
|
|
|
|
'classes.dex'
|
|
|
|
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
${ZIPB} -j "${BASEDIR}/services.jar" \
|
2018-08-26 09:38:19 +00:00
|
|
|
"${BASEDIR}/classes.dex" || \
|
2018-08-25 19:43:43 +00:00
|
|
|
error " !! zip failed"
|
|
|
|
#
|
2018-08-25 21:23:26 +00:00
|
|
|
# XXX odex stuff
|
2018-08-24 19:47:56 +00:00
|
|
|
#
|
2018-08-25 21:23:26 +00:00
|
|
|
elif [ "${ROM_DEX_STATUS}" = "ODEX" ]; then
|
|
|
|
ui_print " >> deodexing services.jar [ODEX]"
|
|
|
|
|
|
|
|
mkdir -p "${BASEDIR}/services.jar-mod"
|
|
|
|
unzip -d "${BASEDIR}/services.jar-mod" "${BASEDIR}/services.jar"
|
|
|
|
|
|
|
|
ui_print " [1] baksmali services/classes.dex"
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
/system/bin/dalvikvm \
|
|
|
|
-classpath "${BASEDIR}/baksmali.dex" \
|
|
|
|
org.jf.baksmali.Main \
|
|
|
|
x "${BASEDIR}/services.jar-mod/classes.dex" \
|
2018-08-26 19:58:10 +00:00
|
|
|
-b "/system/framework/${ARCH}/boot.oat" \
|
|
|
|
-d "/system/framework" \
|
2018-08-25 21:23:26 +00:00
|
|
|
-o "${BASEDIR}/services.jar-deodex" || \
|
|
|
|
error " !! failed to deodex services.jar"
|
|
|
|
|
|
|
|
ui_print " [2] smali services/classes.dex"
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
/system/bin/dalvikvm \
|
|
|
|
-classpath "${BASEDIR}/smali.dex" \
|
|
|
|
org.jf.smali.Main \
|
|
|
|
a "${BASEDIR}/services.jar-deodex" \
|
|
|
|
-o "${BASEDIR}/services.jar-deodex/classes.dex" || \
|
|
|
|
error " !! failed to rebuild classes.dex"
|
|
|
|
|
|
|
|
# just in case | not allowed to call error() !
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
${ZIPB} -d "${BASEDIR}/services.jar" \
|
2018-08-26 10:53:17 +00:00
|
|
|
'classes*.dex'
|
2018-08-25 21:23:26 +00:00
|
|
|
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
${ZIPB} -j "${BASEDIR}/services.jar" \
|
2018-08-26 10:53:17 +00:00
|
|
|
"${BASEDIR}/services.jar-deodex"/classes*.dex || \
|
2018-08-25 21:23:26 +00:00
|
|
|
error " !! zip failed"
|
2018-08-25 19:43:43 +00:00
|
|
|
|
2018-08-25 21:23:26 +00:00
|
|
|
rm -rf "${BASEDIR}/services.jar-deodex" \
|
|
|
|
"${BASEDIR}/services.jar-mod"
|
2018-08-25 19:43:43 +00:00
|
|
|
fi
|
2018-08-24 19:47:56 +00:00
|
|
|
|
|
|
|
mkdir -p "${BASEDIR}/services.jar-mod"
|
2018-03-20 17:52:53 +00:00
|
|
|
|
|
|
|
PATCHES="${PATCH_HOOK} ${PATCH_CORE}"
|
|
|
|
|
|
|
|
ui_print " >> patching services.jar"
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
/system/bin/dalvikvm \
|
|
|
|
-classpath "${BASEDIR}/dexpatcher.dex" \
|
|
|
|
lanchon.dexpatcher.Main \
|
|
|
|
${DEX_OPTS} --api-level "${SDK_VERSION}" \
|
2018-08-26 16:02:36 +00:00
|
|
|
--verbose --debug --output ${BASEDIR}/services.jar-mod \
|
2018-03-20 17:52:53 +00:00
|
|
|
${BASEDIR}/services.jar ${PATCHES} || \
|
|
|
|
error " !! failed to apply patches"
|
|
|
|
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
${ZIPB} -d "${BASEDIR}/services.jar" \
|
2018-08-26 10:53:17 +00:00
|
|
|
'classes*.dex' || \
|
2018-03-20 17:52:53 +00:00
|
|
|
error " !! zip failed"
|
|
|
|
|
|
|
|
LD_LIBRARY_PATH=${C_LD} \
|
|
|
|
${ZIPB} -j "${BASEDIR}/services.jar" \
|
2018-08-26 10:53:17 +00:00
|
|
|
"${BASEDIR}/services.jar-mod"/classes*.dex || \
|
2018-03-20 17:52:53 +00:00
|
|
|
error " !! zip failed"
|
|
|
|
}
|
|
|
|
|
|
|
|
backup_services_jar () {
|
|
|
|
ui_print " << backing up services.jar to: /sdcard/nanodroid_backups"
|
|
|
|
mkdir -p /sdcard/nanodroid_backups
|
|
|
|
cp /system/framework/services.jar /sdcard/nanodroid_backups || \
|
|
|
|
error " !! failed to backup services.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
install_services () {
|
|
|
|
ui_print " "
|
|
|
|
for destination in /dev/tmp/magisk_img/NanoDroid /dev/tmp/magisk_img/NanoDroid_microG \
|
|
|
|
/sbin/.core/img/NanoDroid /sbin/.core/img/NanoDroid_microG /; do
|
|
|
|
if [ -d ${destination} ]; then
|
|
|
|
install_path="${destination}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "${install_path}" = "/" ]; then
|
|
|
|
mount -orw,remount /system || \
|
|
|
|
error " !! failed to mount /system read-write"
|
|
|
|
backup_services_jar
|
|
|
|
fi
|
|
|
|
|
|
|
|
ui_print " << installing patched files to: ${install_path}"
|
|
|
|
|
|
|
|
mkdir -p "${install_path}/system/framework"
|
|
|
|
cp ${BASEDIR}/services.jar "${install_path}/system/framework" \
|
|
|
|
|| error " !! failed to install services.jar"
|
|
|
|
|
|
|
|
if [ "${install_path}" = "/" ]; then
|
2018-08-24 19:26:33 +00:00
|
|
|
echo /system/framework/services.jar >> /data/adb/NanoDroid_FileList
|
2018-03-20 17:52:53 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-24 19:24:01 +00:00
|
|
|
touch /data/adb/NanoDroid_Patched
|
2018-03-20 17:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# addon.d
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
install_addond () {
|
|
|
|
ui_print " "
|
|
|
|
ui_print " Installing addon.d restoration setup"
|
|
|
|
|
|
|
|
mkdir -p /data/adb/nanodroid_patcher
|
|
|
|
|
|
|
|
[ -d /data/nanomod.patcher ] && rm -rf /data/nanomod.patcher
|
|
|
|
[ -d /data/adb/nanomod_patcher ] && rm -rf /data/nanomod_patcher
|
2018-04-10 19:47:19 +00:00
|
|
|
rm -f /system/addon.d/75-nanomodpatcher.sh \
|
|
|
|
/system/addon.d/75-nanodroidpatcher.sh
|
2018-03-20 17:52:53 +00:00
|
|
|
|
|
|
|
for file in core_services.jar.dex dexpatcher.dex file.arm file.x86 \
|
2018-08-24 19:24:01 +00:00
|
|
|
hook_4.1-6.0_services.jar.dex hook_7.0-9.0_services.jar.dex \
|
2018-08-26 11:19:16 +00:00
|
|
|
zip.arm zip.x86 magic.mgc vdexExtractor.arm vdexExtractor.x86 \
|
2018-08-26 13:04:23 +00:00
|
|
|
vdexExtractor.arm64 vdexExctractor.x86_64 baksmali.dex smali.dex; do
|
2018-03-20 17:52:53 +00:00
|
|
|
cp "${BASEDIR}/${file}" /data/adb/nanodroid_patcher/
|
|
|
|
done
|
|
|
|
|
|
|
|
cp /dev/tmp/CommonPatcher /data/adb/nanodroid_patcher/
|
|
|
|
|
2018-08-26 16:58:59 +00:00
|
|
|
cp ${BUSY} /data/adb/nanodroid_patcher/
|
|
|
|
chmod 0755 /data/adb/nanodroid_patcher/${BUSY}
|
|
|
|
|
2018-04-10 19:47:19 +00:00
|
|
|
cp "${BASEDIR}/999-nanodroidpatcher.sh" /system/addon.d/
|
|
|
|
chmod 0755 /system/addon.d/999-nanodroidpatcher.sh
|
2018-03-20 17:52:53 +00:00
|
|
|
}
|
|
|
|
|