[OnePlus 3 & 3T Cross Device Themes, Apps & Mods] anupritaisno1:
Fixed it some more

# Script by 2Tweak
# Last modified 17-09-2019

################################################

# First setup
clear

echo
echo "##########################################"
echo "# LINEAGE CLEANUP SCRIPT #"
echo "##########################################"
echo

mount -o remount,rw /cache
mount -o remount,rw /data
mount -o remount,rw /sdcard
mount -o remount,rw /system

################################################

echo -n "Shrinking ROM to the bare minimum..."

# app list to remove
applist="
AntHalService
AudioFX
BackupRestoreConfirmation
BasicDreams
BluetoothMidiService
BookmarkProvider
BuiltInPrintService
Calendar
CaptivePortalLogin
CNEService
CallLogBackup
CellBroadcastReceiver
CompanionDeviceManager
com.qualcomm.location
Contacts
CtsShimPrebuilt
CtsShimPrivPrebuilt
Development
DocumentsUI
EasterEgg
Eleven
Email
ExactCalculator
Exchange2
Gallery2
HTMLViewer
InputDevices
Jelly
LineageSetupWizard
LiveWallpapersPicker
LockClock
ManagedProvisioning
OneTimeInitializer
OneplusDoze
OneplusPocketMode
PhotoTable
PrintRecommendationService
SharedStorageBackup
SimAppDialog
Stk
Tag
Terminal
Traceur
Updater
UserDictionaryProvider
VpnDialogs
WallpaperBackup
WallpaperCropper
WeatherProvider
WfdService
"

for appname in $applist
do
if [ -e /system/app/"$appname" ]; then
chmod -R 777 /system/app/"$appname"
rm -rf /system/app/"$appname"
fi
if [ -e /system/priv-app/"$appname" ]; then
chmod -R 777 /system/priv-app/"$appname"
rm -rf /system/priv-app/"$appname"
fi
done

echo " done!"

################################################

echo -n "Removing unneeded and junk files...."

# file list to cleanup
filelist="
/cache
/data/anr
/data/backup
/data/cache
/data/dalvik-cache
/data/lineageos_updates
/data/local/tmp
/data/lost+found
/data/misc/bootstat
/data/ota
/data/ota_package
/data/resource-cache
/data/system/batterystats.bin
/data/system/dropbox
/data/system/graphicsstats
/data/system/install_sessions.xml
/data/system/last-fstrim
/data/system/package_cache
/data/system/procstats
/data/system/syncmanager-log
/data/system/uiderrors.txt
/data/system/usagestats/0/daily
/data/system/usagestats/0/monthly
/data/system/usagestats/0/weekly
/data/system/usagestats/0/yearly
/data/tombstones
/system/bin/bootanimation
/system/media/bootanimation.zip
"

for filename in $filelist
do
if [ -d "$filename" ]; then
chmod -R 777 "$filename"
rm -rf "${filename:?}"/*
fi
if [ -f "$filename" ]; then
chmod 777 "$filename"
rm -f "$filename"
fi
done

# Remove bak, log, tmp files
find /data -iname "*.bak" -iname "*.log" -iname "*.tmp" -iname "*.odex" -iname "*.vdex" -type f -exec rm -f {} +
find /system -iname "*.bak" -iname "*.log" -iname "*.tmp" -type f -exec rm -f {} +

# Reduce fonts to the bare minimum
find /system/fonts ! -iname "*roboto*.*" ! -name "DroidSansMono.ttf" ! -name "NotoColorEmoji.ttf" -name "NotoSansSymbols-Regular-Subsetted*.ttf" -type f -exec rm -f {} +

# Some other useless system related files
rm -f /data/stock_boot_*.img.gz
rm -rf /system/vendor/overlay

echo " done!"

################################################

echo -n "Cleaning app data..................."

for i in $(ls /data/data/)
do
if [ -e /data/data/"$i"/cache ]; then
chmod -R 777 /data/data/"$i"/cache
rm -rf /data/data/"$i"/cache/*
fi
if [ -e /data/data/"$i"/code_cache ]; then
chmod -R 777 /data/data/"$i"/code_cache
rm -rf /data/data/"$i"/code_cache/*
fi
if [ -e /data/data/"$i"/files/.Fabric ]; then
chmod -R 777 /data/data/"$i"/files/.Fabric
rm -rf /data/data/"$i"/files/.Fabric/*
fi
if [ -e /data/data/"$i"/files/cache ]; then
chmod -R 777 /data/data/"$i"/files/cache
rm -rf /data/data/"$i"/files/cache/*
fi
if [ -e /data/data/"$i"/app_webview ]; then
chmod -R 777 /data/data/"$i"/app_webview
# keep cookies for webapp logins
if [ -e /data/data/"$i"/app_webview/Cookies ]; then
mv -f /data/data/"$i"/app_webview/Cookies /data/local/tmp/"$i".Cookies
fi
rm -rf /data/data/"$i"/app_webview/*
if [ -e /data/local/tmp/"$i".Cookies ]; then
mv -f /data/local/tmp/"$i".Cookies /data/data/"$i"/app_webview/Cookies
fi
fi
done

for k in $(ls /sdcard/Android/data/)
do
if [ -e /sdcard/Android/data/"$k"/cache ]; then
chmod -R 777 /sdcard/Android/data/"$k"/cache
rm -rf /sdcard/Android/data/"$k"/cache/*
fi
done

echo " done!"

################################################

echo -n "Cleaning app oat files.............."

for j in $(ls /data/app/)
do
if [ -e /data/app/"$j"/oat/arm ]; then
chmod -R 777 /data/app/"$j"/oat/arm
rm -rf /data/app/"$j"/oat/arm/*
fi
if [ -e /data/app/"$j"/oat/arm64 ]; then
chmod -R 777 /data/app/"$j"/oat/arm64
rm -rf /data/app/"$j"/oat/arm64/*
fi
done

echo " done!"

################################################

echo -n "Remove some app specific files......"

# App specific
rm -rf /data/data/com.abnamro.nl.mobile.payments/app_dex/oat/arm64/*
rm -rf /data/data/org.fdroid.fdroid/files/*.apk
rm -rf /data/data/org.videolan.vlc/app_vlc/*

echo " done!"

################################################

echo -n "Optimizing app databases............"

# Optimize databases
for i in $(find /data -iname "*.db" -type f)
do
sqlite3 "$i" "VACUUM;" 2>/dev/null
sqlite3 "$i" "REINDEX;" 2>/dev/null
done

for i in $(find /sdcard -iname "*.db" -type f)
do
sqlite3 "$i" "VACUUM;" 2>/dev/null
sqlite3 "$i" "REINDEX;" 2>/dev/null
done

echo " done!"

################################################

echo -n "Remove live display functionality..."

rm -f '/system/vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.oneplus3'
rm -f '/system/vendor/etc/init/vendor.lineage.livedisplay@2.0-service.oneplus3.rc'
fname="/system/vendor/etc/vintf/manifest.xml"

found=0
startstop=0
tstr=""
nstr=""
IFS=$'\n'
while read line
do
if [[ "$line" == *'<hal'* ]]; then
startstop=1
elif [[ "$line" == *'</hal'* ]]; then
startstop=2
elif [[ "$line" == *'livedisplay'* ]]; then
found=1
fi
if [ $startstop -eq 1 ]; then
tstr="${tstr}\n${line}"
elif [ $startstop -eq 2 ]; then
tstr="${tstr}\n${line}"
if [ $found -eq 0 ]; then
nstr="${nstr}${tstr}"
else
found=0
fi
tstr=""
startstop=0
else
if [ "$nstr" == "" ]; then
nstr="${line}"
else
nstr="${nstr}\n${line}"
fi
fi
done <"$fname"

echo "$nstr" > $fname

echo " done!"

################################################

echo -n "Remove empty directories............"

# Remove empty directories
find /data/data -type d -depth -exec rmdir {} + 2>/dev/null
find /sdcard -type d -depth -exec rmdir {} + 2>/dev/null

echo " done!"

################################################

echo -n "Setting log permissions read-only..."

chmod 000 /data/tombstones
chmod 000 /data/system/dropbox
chmod 000 /data/system/graphicsstats
chmod 000 /data/system/procstats
chmod 000 /data/system/usagestats/0/daily
chmod 000 /data/system/usagestats/0/weekly
chmod 000 /data/system/usagestats/0/monthly
chmod 000 /data/system/usagestats/0/yearly

echo " done!"

################################################

echo -n "Adding my build.prop settings......."

fname="/system/build.prop"
tmpvar=$(sed '/.*My settings.*/{s///;q;}' $fname | sed '$d')
echo "$tmpvar" > $fname
echo '
# My settings

# Disable multi user
fw.max_users=1
fw.show_multiuserui=0
fw.show_hidden_users=0
fw.power_user_switcher=0

# Disable logging
logcat.live=disable

# Disable boot animation
debug.sf.nobootanimation=1

# Disable USB debugging notification
persist.adb.notify=0

# Disable ring delay
ro.telephony.call_ring.delay=0
ring.delay=0

# Remove fps limit
debug.gr.swapinterval=0

# Disable dithering
persist.sys.use_dithering=0

# Disable scrolling cache
persist.sys.scrollingcache=4

# End of my settings
' >> $fname
chmod 644 $fname

echo " done!"

################################################

echo -n "Adding my gps.conf settings........."

rm -f /system/vendor/etc/gps.conf
touch /system/vendor/etc/gps.conf
echo '# My settings

# NTP Server - only one allowed!
NTP_SERVER=nl.pool.ntp.org

# Debug level
DEBUG_LEVEL=0

# End of my settings
' > /system/vendor/etc/gps.conf
chmod 644 /system/vendor/etc/gps.conf

echo " done!"

################################################

echo -n "Adding my userinit.sh settings......"

echo '#!/system/bin/sh
# My settings

# Optimize databases
for i in $(find /data -iname "*.db" -type f)
do
sqlite3 $i "VACUUM;" 2>/dev/null
sqlite3 $i "REINDEX;" 2>/dev/null
done

for i in $(find /storage/emulated/0 -iname "*.db" -type f)
do
sqlite3 $i "VACUUM;" 2>/dev/null
sqlite3 $i "REINDEX;" 2>/dev/null
done

# Instead of disabling fsync remount with higher fsync interval
mount -o remount,rw,commit=300 /data

# Enable power_efficient workqueue
chmod 666 /sys/module/workqueue/parameters/power_efficient
echo 1 > /sys/module/workqueue/parameters/power_efficient
chmod 444 /sys/module/workqueue/parameters/power_efficient

# Disable iostats
chmod 666 /sys/block/sda/queue/iostats
echo "0" > /sys/block/sda/queue/iostats
chmod 444 /sys/block/sda/queue/iostats

# When there, use Boeffla to disable some wakelocks
if [ -e /sys/devices/virtual/misc/boeffla_wakelock_blocker ]; then
echo "IPA_WS;NETLINK;bms;netmgr_wl;qcom_rx_wakelock;sensor_SMD;wlan;wlan_extscan_wl;wlan_ipa;wlan_pno_wl;wlan_wow_wl" > /sys/devices/virtual/misc/boeffla_wakelock_blocker/wakelock_blocker
fi

# End of my settings
' > /data/local/userinit.sh
chmod 777 /data/local/userinit.sh

echo " done!"

echo