-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decryption excluded for the time being. Fixed a build issue where the recovery image was always 12 bytes oversized? assumed it was size of additional binaries so initiallly removed unnecessary such as python, aapt, build currently still excludes them.
- Loading branch information
1 parent
da24048
commit c5d5802
Showing
4 changed files
with
324 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
#!/system/bin/sh | ||
# | ||
# A simple Samsung services disabler by Ian Macdonald. | ||
# | ||
# Use this to prime your device after installing TWRP. | ||
|
||
md5() { | ||
md5sum -b "$1" | ||
} | ||
|
||
file_changed() { | ||
local file="$1" | ||
local old_md5="$2" | ||
local new_md5=$( md5 "$file" ) | ||
|
||
if [ $new_md5 != $old_md5 ]; then | ||
echo " - ...modified." | ||
else | ||
echo " - ...unchanged." | ||
fi | ||
} | ||
|
||
resize_vendor() { | ||
local dm_block=$(df -k | cat | grep "/vendor" | cut -d' ' -f1) | ||
|
||
echo " - Unmounting /vendor..." | ||
umount /vendor | ||
echo " - Checking vendor block partition before resizing..." | ||
e2fsck -f $dm_block | ||
echo " - Resizing the filesystem on $dm_block..." | ||
resize2fs $dm_block | ||
echo " - Make the partition R/W by unsharing its blocks..." | ||
e2fsck -E unshare_blocks $dm_block | ||
echo " - Remounting /vendor..." | ||
mount /vendor | ||
mount -o remount,rw /vendor | ||
} | ||
|
||
vendor_free_size_check() { | ||
echo " - Checking vendor free size..." | ||
if dd if=/dev/zero of=/vendor/test bs=1 count=1 2>/dev/null; then | ||
echo " - ...succeeded." | ||
rm -f /vendor/test | ||
else | ||
echo " - ...No free space left on vendor, attempting to resize vendor..." | ||
echo " " | ||
rm -f /vendor/test | ||
resize_vendor | ||
fi | ||
} | ||
|
||
disable_fbe() { | ||
local md5 | ||
local i | ||
fstab_files=`grep -lr 'fileencryption' vendor/etc` | ||
|
||
# | ||
# Exynos devices = fstab.exynos*. | ||
# MediaTek devices = fstab.mt*. | ||
# Snapdragon devices = fstab.qcom, fstab.emmc, fstab.default | ||
# | ||
for i in $fstab_files; do | ||
if [ -f $i ]; then | ||
echo " - Disabling file-based encryption (FBE) for /data..." | ||
echo " - Found $i." | ||
md5=$( md5 $i ) | ||
# This comments out the offending line and adds an edited one. | ||
sed -i -e 's/^\([^#].*\)fileencryption=[^,]*\(.*\)$/# &\n\1encryptable\2/g' $i | ||
file_changed $i $md5 | ||
fi | ||
done | ||
} | ||
|
||
disable_fde() { | ||
local md5 | ||
local i | ||
fstab_files=`grep -lr 'forceencrypt' vendor/etc` | ||
|
||
# | ||
# Exynos devices = fstab.exynos*. | ||
# MediaTek devices = fstab.mt*. | ||
# Snapdragon devices = fstab.qcom, fstab.emmc, fstab.default | ||
# | ||
for i in $fstab_files; do | ||
if [ -f $i ]; then | ||
echo " - Disabling full-disk encryption (FDE) for /data..." | ||
echo " - Found $i." | ||
md5=$( md5 $i ) | ||
# This comments out the offending line and adds an edited one. | ||
sed -i -e 's/^\([^#].*\)forceencrypt=[^,]*\(.*\)$/# &\n\1encryptable\2/g' $i | ||
file_changed $i $md5 | ||
fi | ||
done | ||
} | ||
|
||
disable_recovery_restoration() { | ||
local r=recovery-from-boot.p | ||
local found | ||
local i | ||
|
||
echo " - Disabling restoration of stock recovery..." | ||
|
||
for i in $ANDROID_ROOT $ANDROID_ROOT/system /vendor; do | ||
if [ -f $i/$r~ ]; then | ||
echo " - ...already disabled." | ||
found=true | ||
break | ||
fi | ||
|
||
if [ -f $i/$r ]; then | ||
echo " - Found $i/$r. Disabling..." | ||
mv $i/$r $i/$r~ | ||
|
||
if [ -f $i/$r~ ]; then | ||
echo " - ...succeeded." | ||
else | ||
echo " - ...failed." | ||
fi | ||
|
||
found=true | ||
break | ||
fi | ||
|
||
done | ||
|
||
[ -z "$found" ] && echo " - Found no stock recovery. Pfft." | ||
} | ||
|
||
echo " " | ||
echo "Multi-disabler v3.1 for Samsung devices" | ||
echo "running Android 9 or later." | ||
echo "by Ian Macdonald, enhanced by afaneh92" | ||
echo " " | ||
|
||
os=$(getprop ro.build.version.release) | ||
major=${os%%.*} | ||
bl=$(getprop ro.boot.bootloader) | ||
dp=$(getprop ro.boot.dynamic_partitions) | ||
|
||
# Firmware version starts at either 8th or 9th character, depending on length | ||
# of bootloader string (12 or 13). | ||
# | ||
fw=${bl:$((${#bl} - 4)):4} | ||
|
||
# Device is first 5 characters of bootloader string. | ||
# | ||
device=${bl:0:$((${#bl} - 8))} | ||
mft=$(getprop ro.product.manufacturer | tr '[A-Z]' '[a-z]') | ||
|
||
if [ "$mft" != samsung ]; then | ||
echo " - Device appears not to be made by Samsung." | ||
fatal=true | ||
elif [ -z "$device" ]; then | ||
echo " - Could not determine device model." | ||
fatal=true | ||
elif [ $major -lt 9 ]; then | ||
echo " - This software is incompatible with Android $major." | ||
fatal=true | ||
fi | ||
if [ -n "$fatal" ]; then | ||
echo " - Installation aborted." | ||
echo " " | ||
exit 1 | ||
fi | ||
|
||
echo " - Detected a $device device with a $fw bootloader." | ||
echo " - The environment appears to be Android $major." | ||
echo " " | ||
|
||
echo " - Mounting $ANDROID_ROOT..." | ||
mount $ANDROID_ROOT 2>/dev/null | ||
mount -o remount,rw $ANDROID_ROOT 2>/dev/null | ||
|
||
if ! mount | grep $ANDROID_ROOT >/dev/null; then | ||
ANDROID_ROOT=/system_root | ||
echo " - Attempt failed. Mounting at $ANDROID_ROOT..." | ||
mount -o rw $ANDROID_ROOT | ||
if ! mount | grep $ANDROID_ROOT >/dev/null; then | ||
echo " - Even that attempt failed. Aborting..." | ||
exit 2 | ||
fi | ||
fi | ||
|
||
echo " - Mounting /vendor..." | ||
mount /vendor | ||
mount -o remount,rw /vendor | ||
|
||
if ! mount | grep /vendor >/dev/null; then | ||
echo " - Mount failed. Aborting..." | ||
exit 3 | ||
fi | ||
|
||
vendor_free_size_check | ||
disable_fbe | ||
disable_fde | ||
disable_recovery_restoration | ||
|
||
echo " - Unmounting /vendor..." | ||
umount /vendor | ||
echo " - Unmounting $ANDROID_ROOT..." | ||
umount $ANDROID_ROOT | ||
|
||
echo " " | ||
echo " - Finished." | ||
echo " " |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# | ||
# This file is part of the OrangeFox Recovery Project | ||
# Copyright (C) 2022 The OrangeFox Recovery Project | ||
# | ||
# OrangeFox is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# any later version. | ||
# | ||
# OrangeFox is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# This software is released under GPL version 3 or any later version. | ||
# See <http://www.gnu.org/licenses/>. | ||
# | ||
# Please maintain this if you use this script or any part of it | ||
# | ||
FDEVICE="a14m" | ||
#set -o xtrace | ||
|
||
fox_get_target_device() { | ||
local chkdev=$(echo "$BASH_SOURCE" | grep -w $FDEVICE) | ||
if [ -n "$chkdev" ]; then | ||
FOX_BUILD_DEVICE="$FDEVICE" | ||
else | ||
chkdev=$(set | grep BASH_ARGV | grep -w $FDEVICE) | ||
[ -n "$chkdev" ] && FOX_BUILD_DEVICE="$FDEVICE" | ||
fi | ||
} | ||
|
||
if [ -z "$1" -a -z "$FOX_BUILD_DEVICE" ]; then | ||
fox_get_target_device | ||
fi | ||
|
||
if [ "$1" = "$FDEVICE" -o "$FOX_BUILD_DEVICE" = "$FDEVICE" ]; then | ||
export TW_DEFAULT_LANGUAGE="en" | ||
export LC_ALL="C" | ||
export ALLOW_MISSING_DEPENDENCIES=true | ||
|
||
#reduce ofox size | ||
export FOX_REMOVE_AAPT=1 | ||
export FOX_REMOVE_BUSYBOX_BINARY=1 | ||
|
||
#Zip install fix - Non standard Boot Location | ||
export FOX_RECOVERY_BOOT_PARTITION="/dev/block/platform/bootdevice/by-name/boot" | ||
export FOX_RECOVERY_INSTALL_PARTITION="/dev/block/platform/bootdevice/by-name/recovery" | ||
export FOX_RECOVERY_SYSTEM_PARTITION="/dev/block/platform/bootdevice/by-name/system" | ||
export FOX_RECOVERY_VENDOR_PARTITION="/dev/block/platform/bootdevice/by-name/vendor" | ||
|
||
# flashlight not working | ||
export OF_FLASHLIGHT_ENABLE=1 | ||
export OF_FL_PATH1="/sys/devices/virtual/camera/flash/rear_torch_flash" | ||
export OF_FL_PATH2="/sys/devices/virtual/camera/flash/rear_torch_flash" | ||
|
||
# Explicit Do Not Patch vbmeta with magisk - Fastboot flash args suffice | ||
export OF_PATCH_VBMETA_FLAG=0 | ||
export OF_PATCH_AVB20=1 | ||
export OF_DISABLE_DM_VERITY_FORCED_ENCRYPTION=1 | ||
|
||
# AB and VARs reccomended by ofox devs | ||
export OF_USE_TWRP_SAR_DETECT=0 | ||
export FOX_AB_DEVICE=0 | ||
export FOX_USE_TWRP_RECOVERY_IMAGE_BUILDER=1 | ||
export OF_NO_TREBLE_COMPATIBILITY_CHECK=1 | ||
export OF_NO_MIUI_PATCH_WARNING=1 | ||
export OF_VANILLA_BUILD=0 | ||
|
||
export OF_SUPPORT_PRE_FLASH_SCRIPT=1 | ||
|
||
# run a process after formatting data to work-around MTP issues | ||
export OF_RUN_POST_FORMAT_PROCESS=1 | ||
|
||
# Custom pic for maintainer's about section info | ||
export OF_MAINTAINER_AVATAR="/recovery/root/twres/images/Default/maintainer.png" | ||
|
||
#Metadata restore resolves alot of bootloops | ||
export OF_QUICK_BACKUP_LIST="/boot;/metadata;" | ||
|
||
# tools | ||
export FOX_USE_BASH_SHELL=1 | ||
export FOX_ASH_IS_BASH=1 | ||
export FOX_USE_TAR_BINARY=1 | ||
export FOX_USE_SED_BINARY=1 | ||
export FOX_USE_XZ_UTILS=1 | ||
export FOX_REPLACE_TOOLBOX_GETPROP=1 | ||
export FOX_USE_NANO_EDITOR=1 | ||
export OF_ENABLE_LPTOOLS=1 | ||
export FOX_ENABLE_APP_MANAGER=1 | ||
export FOX_DELETE_AROMAFM=1 | ||
|
||
export FOX_VARIANT="ForForkSake" | ||
export FOX_BUILD_TYPE="beta" | ||
export OF_MAINTAINER="@CardiffIan CFkod@xda" | ||
|
||
# Screen Notch and status bar settings | ||
export OF_SCREEN_H=2408 | ||
export OF_STATUS_H=75 | ||
export OF_STATUS_INDENT_LEFT=48 | ||
export OF_STATUS_INDENT_RIGHT=48 | ||
export OF_CLOCK_POS=1 | ||
export OF_ALLOW_DISABLE_NAVBAR=0 | ||
export OF_HIDE_NOTCH=1 | ||
|
||
# build vars | ||
if [ -n "$FOX_BUILD_LOG_FILE" -a -f "$FOX_BUILD_LOG_FILE" ]; then | ||
export | grep "FOX" >> $FOX_BUILD_LOG_FILE | ||
export | grep "OF_" >> $FOX_BUILD_LOG_FILE | ||
export | grep "TARGET_" >> $FOX_BUILD_LOG_FILE | ||
export | grep "TW_" >> $FOX_BUILD_LOG_FILE | ||
fi | ||
fi |