mirror of
https://gitlab.com/newbit/rootAVD.git
synced 2026-07-03 13:15:10 +02:00
Added FAKEBOOTIMG and toggleRamdisk Argument
This commit is contained in:
@@ -226,6 +226,16 @@ rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-31\google_apis_play
|
||||
* Starting Magisk from Terminal via `adb shell monkey -p com.topjohnwu.magisk -c android.intent.category.LAUNCHER 1`
|
||||
* API 28 (Pie) is **not supported** at all -> [because](https://source.android.com/devices/bootloader/partitions/system-as-root#sar-partitioning)
|
||||
|
||||
### Fake Boot.img Function
|
||||
* During runtime, the script will launch the Magisk APK so that you can patch the fake Boot.img within 60s
|
||||
* The script also detects if there is already a patched Boot.img present
|
||||
* This feature lets you also update and switch between Magisk Versions
|
||||
* All the ramdisk hacks like fstab, boot scripts and kernel+module updates, can not be applied,
|
||||
* (I don't know a way to Pause the patching process from the Magisk APK)
|
||||
* those hacks must be done first, the classical way via the script, and once the ramdisk hacks are applied, the desired Magisk Version can be installed
|
||||
* If a not proper working ramdisk prevents the Magisk APK from beeing installed and starting, use the toggleRamdisk Argument to stack your patched,\
|
||||
but not yet 100% working ramdisk away, boot the AVD with the Stock ramdisk, toggleRamdisk back, and run the script with the FAKEBOOTIMG Argument
|
||||
|
||||
### 2 Ways to boot the AVD into Safe Mode
|
||||
* 1st Way - If the AVD still boots normal:
|
||||
* Tap and Hold the **Power Button** until the 3 Options appear
|
||||
@@ -329,7 +339,10 @@ rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-31\google_apis_play
|
||||
</details>
|
||||
|
||||
### Change Logs
|
||||
#### [November 2022]
|
||||
* [rootAVD.sh] - Added FAKEBOOTIMG Argument that creates a fake Boot.img which can be patched directed from the Magisk APK
|
||||
#### [March 2022]
|
||||
* [rootAVD.sh] - Added toggleRamdisk Argument that toggles between patched and stock ramdisk
|
||||
* [rootAVD.sh] - Changed the need of a Magisk.zip file
|
||||
* [General] - Added Use Case Examples as Gif
|
||||
* [General] - Added Option to Download older Magisk Versions
|
||||
|
||||
+120
-24
@@ -210,6 +210,73 @@ detect_ramdisk_compression_method() {
|
||||
echo "[!] Ramdisk.img uses $METHOD compression"
|
||||
}
|
||||
|
||||
runMagisk_to_Patch_fake_boot_img() {
|
||||
am force-stop $PKG_NAME
|
||||
echo "[-] Starting Magisk"
|
||||
monkey -p $PKG_NAME -c android.intent.category.LAUNCHER 1 > /dev/null 2>&1
|
||||
echo "[*] Install/Patch $FBI and hit Enter when done(max. 60s)"
|
||||
read -t 60 proceed
|
||||
case $proceed in
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
create_fake_boot_img() {
|
||||
echo "[*] Creating a fake Boot.img"
|
||||
FBHI=$BASEDIR/fakebootheader.img
|
||||
FBI=$SDCARD/fakeboot.img
|
||||
|
||||
printf "\x41\x4E\x44\x52\x4F\x49\x44\x21" > $FBHI # ANDROID!
|
||||
printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> $FBHI
|
||||
printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> $FBHI
|
||||
printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> $FBHI
|
||||
printf "\x00\x00\x00\x00\x00\x08\x00\x00" >> $FBHI # 00080000 (Pagesize 2048)
|
||||
echo "[!] Only a minimal header is required for Magisk to repack the ramdisk"
|
||||
cp $RDF $CPIO
|
||||
echo "[*] repacking ramdisk.img into $FBI"
|
||||
$BASEDIR/magiskboot repack -n $FBHI $FBI > /dev/null 2>&1
|
||||
InstallMagiskTemporarily
|
||||
runMagisk_to_Patch_fake_boot_img
|
||||
RemoveTemporarilyMagisk
|
||||
}
|
||||
|
||||
unpack_patched_ramdisk_from_fake_boot_img() {
|
||||
|
||||
if [ "$MagiskPatchedFiles" != "" ]; then
|
||||
echo "[!] magisk_patched file(s) could be found!"
|
||||
for file in `ls -tu $SDCARD/*magisk_patched*`; do
|
||||
MagiskPatched=$file
|
||||
break
|
||||
done
|
||||
echo "[*] unpacking latest $MagiskPatched"
|
||||
$BASEDIR/magiskboot unpack -n $MagiskPatched > /dev/null 2>&1
|
||||
echo "[-] deleting all magisk_patched files"
|
||||
for file in `ls -tu $SDCARD/*magisk_patched*`; do
|
||||
rm -f $file
|
||||
done
|
||||
mv $CPIO "ramdiskpatched4AVD.img"
|
||||
else
|
||||
echo "[!] No magisk_patched file could be found!"
|
||||
fi
|
||||
}
|
||||
|
||||
process_fake_boot_img() {
|
||||
|
||||
SDCARD=/sdcard/Download
|
||||
|
||||
echo "[*] Processing fake Boot.img"
|
||||
MagiskPatchedFiles=$(ls "$SDCARD"/*magisk_patched*) > /dev/null 2>&1
|
||||
if [ "$MagiskPatchedFiles" != "" ]; then
|
||||
echo "[!] external magisk_patched file(s) could be found!"
|
||||
unpack_patched_ramdisk_from_fake_boot_img
|
||||
else
|
||||
create_fake_boot_img
|
||||
MagiskPatchedFiles=$(ls "$SDCARD"/*magisk_patched*) > /dev/null 2>&1
|
||||
unpack_patched_ramdisk_from_fake_boot_img
|
||||
fi
|
||||
}
|
||||
|
||||
# requires additional setup
|
||||
# EnvFixTask
|
||||
construct_environment() {
|
||||
@@ -906,26 +973,40 @@ CheckAvailableMagisks() {
|
||||
export MAGISKVERCHOOSEN
|
||||
}
|
||||
|
||||
InstallMagiskTemporarily() {
|
||||
PKG_NAMES=$(pm list packages magisk | cut -f 2 -d ":") > /dev/null 2>&1
|
||||
PKG_NAME=""
|
||||
echo "[!] Temporarily installing Magisk"
|
||||
|
||||
for PKG_NAME in $PKG_NAMES; do
|
||||
pm clear $PKG_NAME >/dev/null 2>&1
|
||||
pm uninstall $PKG_NAME >/dev/null 2>&1
|
||||
done
|
||||
|
||||
pm install -r $MZ >/dev/null 2>&1
|
||||
PKG_NAME=$(pm list packages magisk | cut -f 2 -d ":") > /dev/null 2>&1
|
||||
}
|
||||
|
||||
RemoveTemporarilyMagisk() {
|
||||
echo "[!] Removing Temporarily installed Magisk"
|
||||
pm clear $PKG_NAME >/dev/null 2>&1
|
||||
pm uninstall $PKG_NAME >/dev/null 2>&1
|
||||
}
|
||||
|
||||
DownloadUptoDateSript() {
|
||||
echo "[*] Trying to Download the Up-To-Date Script Version"
|
||||
|
||||
local DLL_URL="https://github.com/newbit1/rootAVD/raw/master/"
|
||||
local DLL_SCRIPT="rootAVD.sh"
|
||||
local DLL_ROOTAVD_ZIP="https://github.com/newbit1/rootAVD/archive/refs/heads/master.zip"
|
||||
local PKG_NAME="com.topjohnwu.magisk"
|
||||
local PKG_PATH=""
|
||||
|
||||
echo "[!] Temporarily installing Magisk"
|
||||
pm clear $PKG_NAME >/dev/null 2>&1
|
||||
pm uninstall $PKG_NAME >/dev/null 2>&1
|
||||
pm install -r $MZ >/dev/null 2>&1
|
||||
InstallMagiskTemporarily
|
||||
PKG_PATH=$(pm path $PKG_NAME)
|
||||
PKG_PATH=${PKG_PATH%/*}
|
||||
PKG_PATH=${PKG_PATH#*:}
|
||||
cp -Rf $PKG_PATH/lib $BASEDIR/
|
||||
pm clear $PKG_NAME >/dev/null 2>&1
|
||||
pm uninstall $PKG_NAME >/dev/null 2>&1
|
||||
|
||||
cp -Rf $PKG_PATH/lib $BASEDIR/
|
||||
RemoveTemporarilyMagisk
|
||||
CopyBusyBox
|
||||
DownLoadFile $DLL_URL $DLL_SCRIPT
|
||||
}
|
||||
@@ -1303,6 +1384,17 @@ patching_ramdisk(){
|
||||
"add 000 .backup/.magisk config"
|
||||
}
|
||||
|
||||
|
||||
rename_copy_magisk() {
|
||||
if ( "$MAGISKVERCHOOSEN" ); then
|
||||
echo "[!] Copy Magisk.zip to Magisk.apk"
|
||||
cp Magisk.zip Magisk.apk
|
||||
else
|
||||
echo "[!] Rename Magisk.zip to Magisk.apk"
|
||||
mv Magisk.zip Magisk.apk
|
||||
fi
|
||||
}
|
||||
|
||||
repacking_ramdisk(){
|
||||
if [ $((STATUS & 4)) -ne 0 ]; then
|
||||
echo "[!] Compressing ramdisk before repacking it"
|
||||
@@ -1312,14 +1404,6 @@ repacking_ramdisk(){
|
||||
echo "[*] repacking back to ramdisk.img format"
|
||||
# Rename and compress ramdisk.cpio back to ramdiskpatched4AVD.img
|
||||
./magiskboot compress=$METHOD "ramdisk.cpio" "ramdiskpatched4AVD.img"
|
||||
|
||||
if ( "$MAGISKVERCHOOSEN" ); then
|
||||
echo "[!] Copy Magisk.zip to Magisk.apk"
|
||||
cp Magisk.zip Magisk.apk
|
||||
else
|
||||
echo "[!] Rename Magisk.zip to Magisk.apk"
|
||||
mv Magisk.zip Magisk.apk
|
||||
fi
|
||||
}
|
||||
|
||||
strip_html_links() {
|
||||
@@ -2017,14 +2101,19 @@ InstallMagiskToAVD() {
|
||||
|
||||
if $INEMULATOR; then
|
||||
detect_ramdisk_compression_method
|
||||
decompress_ramdisk
|
||||
test_ramdisk_patch_status
|
||||
if [ "$DERIVATE" == "BlueStacks" ]; then
|
||||
InstallMagiskIntoBlueStacksRamdisk
|
||||
if $FAKEBOOTIMG; then
|
||||
process_fake_boot_img
|
||||
else
|
||||
patching_ramdisk
|
||||
fi
|
||||
repacking_ramdisk
|
||||
decompress_ramdisk
|
||||
test_ramdisk_patch_status
|
||||
if [ "$DERIVATE" == "BlueStacks" ]; then
|
||||
InstallMagiskIntoBlueStacksRamdisk
|
||||
else
|
||||
patching_ramdisk
|
||||
fi
|
||||
repacking_ramdisk
|
||||
fi
|
||||
rename_copy_magisk
|
||||
fi
|
||||
|
||||
if [ "$DERIVATE" == "BlueStacks" ]; then
|
||||
@@ -2171,6 +2260,7 @@ ProcessArguments() {
|
||||
AddRCscripts=false
|
||||
BLUESTACKS=false
|
||||
toggleRamdisk=false
|
||||
FAKEBOOTIMG=false
|
||||
|
||||
# Call rootAVD with SOURCING if you just want to source it
|
||||
# or export SOURCING=true if you are in crosh
|
||||
@@ -2253,6 +2343,11 @@ ProcessArguments() {
|
||||
toggleRamdisk=true
|
||||
fi
|
||||
|
||||
# Call rootAVD with FAKEBOOTIMG if you want to create a fake boot.img to patch the ramdisk.img via direct install
|
||||
if [[ "$@" == *"FAKEBOOTIMG"* ]]; then
|
||||
FAKEBOOTIMG=true
|
||||
fi
|
||||
|
||||
export DEBUG
|
||||
export PATCHFSTAB
|
||||
export GetUSBHPmodZ
|
||||
@@ -2268,6 +2363,7 @@ ProcessArguments() {
|
||||
export BLUESTACKS
|
||||
export toggleRamdisk
|
||||
export SOURCING
|
||||
export FAKEBOOTIMG
|
||||
}
|
||||
|
||||
# Script Entry Point
|
||||
|
||||
Reference in New Issue
Block a user