mirror of
https://gitlab.com/Nanolx/NanoDroid
synced 2024-11-02 03:40:13 +00:00
remove on-pc framework patcher (it's non-functional beyond Nougat [and a new implementation will follow, soon-ish])
This commit is contained in:
parent
a270951583
commit
5119803ea8
@ -216,14 +216,6 @@ Extra packages, always flash through TWRP.
|
|||||||
|
|
||||||
Misc. Script for use from PC/Notebook, while device is in TWRP, they are found in this repository
|
Misc. Script for use from PC/Notebook, while device is in TWRP, they are found in this repository
|
||||||
|
|
||||||
* **framework-patcher**
|
|
||||||
* on-device framework-patcher for signature spoofing support
|
|
||||||
* requires an deodexed ROM
|
|
||||||
* [> Deodex Instructions](doc/DeodexServices.md)
|
|
||||||
* creates the file `/data/adb/NanoDroid_Patched` after successful patching
|
|
||||||
* invoke like `framework-patcher [ver]`
|
|
||||||
* where [ver] is your Android version (6.0, 7.1, ...)
|
|
||||||
* the original, unpatched `services.jar` is backed up to `/sdcard/nanodroid_backups`
|
|
||||||
* **force-debloat**
|
* **force-debloat**
|
||||||
* system debloater
|
* system debloater
|
||||||
* the list of applications resides in the script itself
|
* the list of applications resides in the script itself
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
GITHUB_URL="https://github.com/Lanchon/haystack.git"
|
|
||||||
PATCH_CORE="sigspoof-core"
|
|
||||||
CWD=$(readlink -m "${BASH_SOURCE[0]}")
|
|
||||||
CWD=$(dirname "${CWD}")
|
|
||||||
|
|
||||||
error () {
|
|
||||||
echo -e "${@}"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
help () {
|
|
||||||
|
|
||||||
echo -e "haystack framework patcher helper
|
|
||||||
|
|
||||||
provide Android Version like:
|
|
||||||
framework-patcher.sh [version] [--gui]
|
|
||||||
|
|
||||||
there version is one of:
|
|
||||||
4.1 [JB]
|
|
||||||
4.2 [JB]
|
|
||||||
4.3 [JB]
|
|
||||||
4.4 [KK]
|
|
||||||
5.0 [LL]
|
|
||||||
5.1 [LL]
|
|
||||||
6.0 [MM]
|
|
||||||
7.0 [N]
|
|
||||||
7.1 [N]
|
|
||||||
8.0 [O]
|
|
||||||
8.1 [O]
|
|
||||||
|
|
||||||
your device must be in TWRP and connected to PC."
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
4.1 ) API=16 ;;
|
|
||||||
4.2 ) API=17 ;;
|
|
||||||
4.3 ) API=18 ;;
|
|
||||||
4.4 ) API=19 ;;
|
|
||||||
5.0 ) API=21 ;;
|
|
||||||
5.1 ) API=22 ;;
|
|
||||||
6.0 ) API=23 ;;
|
|
||||||
7.0 ) API=24 ;;
|
|
||||||
7.1 ) API=25 ;;
|
|
||||||
8.0 ) API=26 ;;
|
|
||||||
8.1 ) API=27 ;;
|
|
||||||
* ) help ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ ${API} -lt 24 ]]; then
|
|
||||||
PATCH_HOOK="sigspoof-hook-4.1-6.0"
|
|
||||||
PATCH_UI="sigspoof-ui-global-4.1-6.0"
|
|
||||||
else
|
|
||||||
PATCH_HOOK="sigspoof-hook-7.0-7.1"
|
|
||||||
PATCH_UI="sigspoof-ui-global-7.0-7.1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
adb shell "[[ -d /twres ]] && exit 0" || error "Device is not in TWRP!"
|
|
||||||
|
|
||||||
if [[ -d ${CWD}/haystack/.git ]]; then
|
|
||||||
cd "${CWD}/haystack"
|
|
||||||
rm -rf mydevice*
|
|
||||||
git pull
|
|
||||||
else
|
|
||||||
rm -rf "${CWD}/haystack"
|
|
||||||
git clone "${GITHUB_URL}" || error "Failed to down haystack!"
|
|
||||||
cd "${CWD}/haystack"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
if ! [ -x "$(command -v brew)" ]; then
|
|
||||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
||||||
fi
|
|
||||||
if ! [ -x "$(command -v greadlink)" ]; then
|
|
||||||
brew install coreutils
|
|
||||||
fi
|
|
||||||
alias readlink=greadlink
|
|
||||||
alias cp=gcp
|
|
||||||
fi
|
|
||||||
|
|
||||||
adb push "${CWD}/framework-patcher-remote" /tmp/ || \
|
|
||||||
error "Failed to push helper script to device"
|
|
||||||
|
|
||||||
adb shell "chmod 0755 /tmp/framework-patcher-remote" || \
|
|
||||||
error "Failed to set permissions for helper script"
|
|
||||||
|
|
||||||
adb shell "/tmp/framework-patcher-remote --mount" || \
|
|
||||||
error "Failed to install /system"
|
|
||||||
|
|
||||||
rm -rf "${CWD}/haystack/mydevice*"
|
|
||||||
|
|
||||||
"${CWD}/haystack/pull-fileset" mydevice || error "Failed to pull files from device!"
|
|
||||||
|
|
||||||
"${CWD}/haystack/patch-fileset" "${CWD}/haystack/patches/${PATCH_HOOK}" \
|
|
||||||
"${API}" "${CWD}/haystack/mydevice" || \
|
|
||||||
error "Failed applying sigspoof hook patch!"
|
|
||||||
|
|
||||||
"${CWD}/haystack/patch-fileset" "${CWD}/haystack/patches/${PATCH_CORE}" "${API}" \
|
|
||||||
"${CWD}/haystack/mydevice__${PATCH_HOOK}" \
|
|
||||||
|| error "Failed applying sigspoof core patch!"
|
|
||||||
|
|
||||||
|
|
||||||
adb push "${CWD}/haystack/mydevice__${PATCH_HOOK}__${PATCH_CORE}/services.jar" \
|
|
||||||
/tmp/services.jar || error "Failed to push services.jar to device"
|
|
||||||
|
|
||||||
adb shell "/tmp/framework-patcher-remote --patch" || \
|
|
||||||
error "Failed to install services.jar"
|
|
||||||
|
|
||||||
echo -e "\nNow reboot device and enjoy microG!"
|
|
||||||
|
|
||||||
cd "${CWD}"
|
|
@ -1,174 +0,0 @@
|
|||||||
#!/sbin/sh
|
|
||||||
|
|
||||||
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 $?
|
|
||||||
}
|
|
||||||
|
|
||||||
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))
|
|
||||||
}
|
|
||||||
|
|
||||||
grow_magisk_img () {
|
|
||||||
request_size_check /tmp/services.jar
|
|
||||||
image_size_check /data/adb/magisk.img
|
|
||||||
if [ "$reqSizeM" -gt "$curFreeM" ]; then
|
|
||||||
SIZE=$(((reqSizeM + curUsedM) / 32 * 32 + 64))
|
|
||||||
resize2fs /data/adb/magisk.img ${SIZE}M
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
shrink_magisk_img () {
|
|
||||||
image_size_check /data/adb/magisk.img
|
|
||||||
NEWDATASIZE=$((curUsedM / 32 * 32 + 32))
|
|
||||||
if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then
|
|
||||||
resize2fs $IMG ${NEWDATASIZE}M
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
echo "$LOOPDEVICE" > /tmp/loopdevice
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
mount_magisk () {
|
|
||||||
mount /data &>/dev/null
|
|
||||||
mount_image /data/adb/magisk.img /magisk
|
|
||||||
}
|
|
||||||
|
|
||||||
umount_magisk () {
|
|
||||||
umount /magisk
|
|
||||||
losetup -d $(cat /tmp/loopdevice)
|
|
||||||
rm /tmp/loopdevice
|
|
||||||
}
|
|
||||||
|
|
||||||
grep_cmdline() {
|
|
||||||
local REGEX="s/^${1}=//p"
|
|
||||||
sed -E 's/ +/\n/g' /proc/cmdline | \
|
|
||||||
sed -n "${REGEX}" 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# taken from Magisk, with minor modifications for NanoDroid
|
|
||||||
mount_partitions () {
|
|
||||||
SLOT=$(grep_cmdline androidboot.slot_suffix)
|
|
||||||
if [ -z ${SLOT} ]; then
|
|
||||||
SLOT=_$(grep_cmdline androidboot.slot)
|
|
||||||
[ "${SLOT}" = "_" ] && SLOT=
|
|
||||||
fi
|
|
||||||
|
|
||||||
is_mounted /data || mount /data
|
|
||||||
|
|
||||||
! is_mounted /system && mount -o rw /system
|
|
||||||
|
|
||||||
if [ ! -f /system/build.prop ]; then
|
|
||||||
SYSTEMBLOCK=$(find /dev/block -iname system${SLOT} | head -n 1)
|
|
||||||
mount -t ext4 -o rw ${SYSTEMBLOCK} /system
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -f /system/build.prop ] || is_mounted /system || exit 1
|
|
||||||
|
|
||||||
if [ -f /system/init ]; then
|
|
||||||
mkdir /system_root 2>/dev/null
|
|
||||||
mount --move /system /system_root
|
|
||||||
mount -o bind /system_root/system /system
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ ! -f /system/build.prop ] && exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
patch_system () {
|
|
||||||
if [[ -f /data/adb/magisk.img ]]; then
|
|
||||||
grow_magisk_img
|
|
||||||
echo "magisk found: mount to /magisk"
|
|
||||||
mount_magisk
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f /data/adb/.nanodroid-patcher ]]; then
|
|
||||||
echo " ++ /data/adb/.nanodroid-patcher exists"
|
|
||||||
echo " ++ assuming ROM is already patched"
|
|
||||||
exit 0
|
|
||||||
elif [[ -f /data/adb/NanoDroid_Patched ]]; then
|
|
||||||
echo " ++ /data/adb/NanoDroid_Patched exists"
|
|
||||||
echo " ++ assuming ROM is already patched"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
install_path=""
|
|
||||||
|
|
||||||
if [[ -d /magisk/NanoDroid ]]; then
|
|
||||||
echo "NanoDroid detected"
|
|
||||||
install_path="/magisk/NanoDroid/system"
|
|
||||||
mkdir -p "${install_path}"
|
|
||||||
elif [[ -d /magisk/NanoDroid_microG ]]; then
|
|
||||||
echo "NanoDroid microG detected"
|
|
||||||
install_path="/magisk/NanoDroid_microG/system"
|
|
||||||
mkdir -p "${install_path}"
|
|
||||||
else
|
|
||||||
echo "backing up services.jar to /sdcard/nanodroid_backups"
|
|
||||||
mkdir -p /sdcard/nanodroid_backups
|
|
||||||
cp /tmp/services.jar /sdcard/nanodroid_backups
|
|
||||||
|
|
||||||
echo "using ROM as destination"
|
|
||||||
install_path="/system"
|
|
||||||
|
|
||||||
echo /system/framework/services.jar >> \
|
|
||||||
/data/adb/NanoDroid_FileList
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "install to \"${install_path}\""
|
|
||||||
cp /tmp/services.jar "${install_path}/framework" || exit 1
|
|
||||||
|
|
||||||
touch /data/adb/NanoDroid_Patched
|
|
||||||
|
|
||||||
if (is_mounted /magisk); then
|
|
||||||
echo "unmount /magisk"
|
|
||||||
umount_magisk
|
|
||||||
shrink_magisk_img
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "unmount /system"
|
|
||||||
umount /system
|
|
||||||
}
|
|
||||||
|
|
||||||
case ${1} in
|
|
||||||
*mount )
|
|
||||||
mount_partitions || exit 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
*patch )
|
|
||||||
patch_system || exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
Loading…
Reference in New Issue
Block a user