So it's nothing new, but solutions like "Link2SD", "Folder Mount" seems to don't work.
When I install for example AcrobatReader, Link2SD tells me that about 100% is linked, but still internal storage was decreased about 20MB-30MB - so I think that doesn't work.
I make some tryings on my own, broke system on my phone, upload another, make another tryings and got some reboots etc...
I want to move whole data partition to SD. Maybe someone know ready to use ROM which have that? Maybe it's very bad idea, but why?
Here is some details about phone:
Xperia Neo V, cm-10-20131006-NIGHTLY-haida (but I'm not relevant to it), unlocked bootloader.
(I cant post pictures....)
mount
Code:
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/mtdblock0 /system yaffs2 ro,relatime 0 0
/dev/block/mtdblock3 /data yaffs2 rw,nosuid,nodev,relatime 0 0
/dev/block/mtdblock2 /cache yaffs2 rw,nosuid,nodev,relatime 0 0
/dev/block/mmcblk0p2 /data/sdext2 ext2 rw,relatime,errors=continue 0 0
/sys/kernel/debug /sys/kernel/debug debugfs rw,relatime 0 0
/dev/block/vold/179:1 /storage/sdcard0 vfat rw,dirsync,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:1 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /storage/sdcard0/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
df
Code:
Filesystem Size Used Free Blksize
/dev 179.4M 48K 179.4M 4096
/mnt/asec 179.4M 0K 179.4M 4096
/mnt/obb 179.4M 0K 179.4M 4096
/system 400M 360.6M 39.4M 4096
/data 420M 132.1M 287.9M 4096
/cache 101.5M 73.7M 27.8M 4096
/data/sdext2 1.4G 135.5M 1.3G 4096
/storage/sdcard0 377.2M 93.9M 283.3M 4096
/mnt/secure/asec 377.2M 93.9M 283.3M 4096
mtd
Code:
dev: size erasesize name
mtd0: 19000000 00020000 "system"
mtd1: 00600000 00020000 "appslog"
mtd2: 06580000 00020000 "cache"
mtd3: 1a400000 00020000 "userdata"
vold.fstab
Code:
## Vold 2.0 fstab for Mogami
#
## - San Mehat ([email protected])
##
#######################
## Regular device mount
##
## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>
## label - Label for the volume
## mount_point - Where the volume will be mounted
## part - Partition # (1 based), or 'auto' for first usable partition.
## <sysfs_path> - List of sysfs paths to source devices
######################
# Mounts the first usable partition of the specified device
dev_mount sdcard /storage/sdcard0 auto /devices/platform/msm_sdcc.4/mmc_host/mmc1
init.rc
Code:
# Copyright (C) 2012 The Android Open Source Project
#
# IMPORTANT: Do not create world writable files or directories.
# This is a common source of Android security bugs.
#
import /init.${ro.hardware}.rc
import /init.usb.rc
import /init.trace.rc
on early-init
# Set init and its forked children's oom_adj.
write /proc/1/oom_adj -16
start ueventd
# create mountpoints
mkdir /mnt 0775 root system
on init
sysclktz 0
loglevel 3
# setup the global environment
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
export LD_LIBRARY_PATH /vendor/lib:/system/lib
export ANDROID_BOOTLOGO 1
export ANDROID_ROOT /system
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export ASEC_MOUNTPOINT /mnt/asec
export LOOP_MOUNTPOINT /mnt/obb
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar
# Backward compatibility
symlink /system/etc /etc
symlink /sys/kernel/debug /d
# Right now vendor lives on the same filesystem as system,
# but someday that may change.
symlink /system/vendor /vendor
# Create cgroup mount point for cpu accounting
mkdir /acct
mount cgroup none /acct cpuacct
mkdir /acct/uid
mkdir /system
mkdir /data 0771 system system
mkdir /cache 0771 system cache
mkdir /config 0500 root root
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Directory-target for where the secure container
# imagefile directory will be bind-mounted
mkdir /mnt/secure/asec 0700 root root
# Secure container public mount points.
mkdir /mnt/asec 0700 root system
mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
# Filesystem image public mount points.
mkdir /mnt/obb 0700 root system
mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
write /proc/sys/kernel/panic_on_oops 1
write /proc/sys/kernel/hung_task_timeout_secs 0
write /proc/cpu/alignment 4
write /proc/sys/kernel/sched_latency_ns 10000000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
write /proc/sys/kernel/sched_compat_yield 1
write /proc/sys/kernel/sched_child_runs_first 0
write /proc/sys/kernel/randomize_va_space 2
write /proc/sys/kernel/kptr_restrict 2
write /proc/sys/kernel/dmesg_restrict 1
write /proc/sys/vm/mmap_min_addr 32768
write /proc/sys/kernel/sched_rt_runtime_us 950000
write /proc/sys/kernel/sched_rt_period_us 1000000
# Create cgroup mount points for process groups
mkdir /dev/cpuctl
mount cgroup none /dev/cpuctl cpu
chown system system /dev/cpuctl
chown system system /dev/cpuctl/tasks
chmod 0660 /dev/cpuctl/tasks
write /dev/cpuctl/cpu.shares 1024
write /dev/cpuctl/cpu.rt_runtime_us 950000
write /dev/cpuctl/cpu.rt_period_us 1000000
mkdir /dev/cpuctl/apps
chown system system /dev/cpuctl/apps/tasks
chmod 0666 /dev/cpuctl/apps/tasks
write /dev/cpuctl/apps/cpu.shares 1024
write /dev/cpuctl/apps/cpu.rt_runtime_us 800000
write /dev/cpuctl/apps/cpu.rt_period_us 1000000
mkdir /dev/cpuctl/apps/bg_non_interactive
chown system system /dev/cpuctl/apps/bg_non_interactive/tasks
chmod 0666 /dev/cpuctl/apps/bg_non_interactive/tasks
# 5.0 %
write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000
# Allow everybody to read the xt_qtaguid resource tracking misc dev.
# This is needed by any process that uses socket tagging.
chmod 0644 /dev/xt_qtaguid
on fs
# mount mtd partitions
# Mount /system rw first to give the filesystem a chance to save a checkpoint
mount yaffs2 [email protected] /system
mount yaffs2 [email protected] /system ro remount
mount yaffs2 [email protected] /data nosuid nodev
mount yaffs2 [email protected] /cache nosuid nodev
on post-fs
# once everything is setup, no need to modify /
mount rootfs rootfs / ro remount
# We chown/chmod /cache again so because mount is run as root + defaults
chown system cache /cache
chmod 0771 /cache
# This may have been created by the recovery system with odd permissions
chown system cache /cache/recovery
chmod 0770 /cache/recovery
#change permissions on vmallocinfo so we can grab it from bugreports
chown root log /proc/vmallocinfo
chmod 0440 /proc/vmallocinfo
#change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
chown root system /proc/kmsg
chmod 0440 /proc/kmsg
chown root system /proc/sysrq-trigger
chmod 0220 /proc/sysrq-trigger
# create the lost+found directories, so as to enforce our permissions
mkdir /cache/lost+found 0770 root root
on post-fs-data
# We chown/chmod /data again so because mount is run as root + defaults
chown system system /data
chmod 0771 /data
# Create dump dir and collect dumps.
# Do this before we mount cache so eventually we can use cache for
# storing dumps on platforms which do not have a dedicated dump partition.
mkdir /data/dontpanic 0750 root log
# Collect apanic data, free resources and re-arm trigger
copy /proc/apanic_console /data/dontpanic/apanic_console
chown root log /data/dontpanic/apanic_console
chmod 0640 /data/dontpanic/apanic_console
copy /proc/apanic_threads /data/dontpanic/apanic_threads
chown root log /data/dontpanic/apanic_threads
chmod 0640 /data/dontpanic/apanic_threads
write /proc/apanic_console 1
# create basic filesystem structure
mkdir /data/misc 01771 system misc
mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
mkdir /data/misc/bluetooth 0770 system system
mkdir /data/misc/keystore 0700 keystore keystore
mkdir /data/misc/keychain 0771 system system
mkdir /data/misc/vpn 0770 system vpn
mkdir /data/misc/systemkeys 0700 system system
# give system access to wpa_supplicant.conf for backup and restore
mkdir /data/misc/wifi 0770 wifi wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
mkdir /data/local 0751 root root
# For security reasons, /data/local/tmp should always be empty.
# Do not place files or directories in /data/local/tmp
mkdir /data/local/tmp 0771 shell shell
mkdir /data/data 0771 system system
mkdir /data/app-private 0771 system system
mkdir /data/app-asec 0700 root root
mkdir /data/app 0771 system system
mkdir /data/property 0700 root root
mkdir /data/ssh 0750 root shell
mkdir /data/ssh/empty 0700 root root
mkdir /data/radio 0770 radio radio
# create dalvik-cache and double-check the perms, so as to enforce our permissions
mkdir /data/dalvik-cache 0771 system system
chown system system /data/dalvik-cache
chmod 0771 /data/dalvik-cache
# create resource-cache and double-check the perms
mkdir /data/resource-cache 0771 system system
chown system system /data/resource-cache
chmod 0771 /data/resource-cache
# create the lost+found directories, so as to enforce our permissions
mkdir /data/lost+found 0770 root root
# create directory for DRM plug-ins - give drm the read/write access to
# the following directory.
mkdir /data/drm 0770 drm drm
# If there is no fs-post-data action in the init.<device>.rc file, you
# must uncomment this line, otherwise encrypted filesystems
# won't work.
# Set indication (checked by vold) that we have finished this action
#setprop vold.post_fs_data_done 1
# Include extra init file
import /init.cm.rc
on boot
# basic network init
ifup lo
hostname localhost
domainname localdomain
# set RLIMIT_NICE to allow priorities from 19 to -20
setrlimit 13 40 40
# Memory management. Basic kernel parameters, and allow the high
# level system server to be able to adjust the kernel OOM driver
# parameters to match how it is managing things.
write /proc/sys/vm/overcommit_memory 1
write /proc/sys/vm/min_free_order_shift 4
chown root system /sys/module/lowmemorykiller/parameters/adj
chmod 0664 /sys/module/lowmemorykiller/parameters/adj
chown root system /sys/module/lowmemorykiller/parameters/minfree
chmod 0664 /sys/module/lowmemorykiller/parameters/minfree
# Tweak background writeout
write /proc/sys/vm/dirty_expire_centisecs 200
write /proc/sys/vm/dirty_background_ratio 5
# Permissions for System Server and daemons.
chown radio system /sys/android_power/state
chown radio system /sys/android_power/request_state
chown radio system /sys/android_power/acquire_full_wake_lock
chown radio system /sys/android_power/acquire_partial_wake_lock
chown radio system /sys/android_power/release_wake_lock
chown system system /sys/power/state
chown system system /sys/power/wakeup_count
chown radio system /sys/power/wake_lock
chown radio system /sys/power/wake_unlock
chmod 0660 /sys/power/state
chmod 0660 /sys/power/wake_lock
chmod 0660 /sys/power/wake_unlock
chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate
chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
chown system system /sys/devices/system/cpu/cpufreq/interactive/boost
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost
chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse
chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost
# Assume SMP uses shared cpufreq policy for all CPUs
chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/class/leds/keyboard-backlight/brightness
chown system system /sys/class/leds/lcd-backlight/brightness
chown system system /sys/class/leds/button-backlight/brightness
chown system system /sys/class/leds/jogball-backlight/brightness
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/module/sco/parameters/disable_esco
chown system system /sys/kernel/ipv4/tcp_wmem_min
chown system system /sys/kernel/ipv4/tcp_wmem_def
chown system system /sys/kernel/ipv4/tcp_wmem_max
chown system system /sys/kernel/ipv4/tcp_rmem_min
chown system system /sys/kernel/ipv4/tcp_rmem_def
chown system system /sys/kernel/ipv4/tcp_rmem_max
chown root radio /proc/cmdline
# Define TCP buffer sizes for various networks
# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
setprop net.tcp.buffersize.default 4096,87380,704512,4096,16384,110208
setprop net.tcp.buffersize.wifi 524288,1048576,2097152,262144,524288,1048576
setprop net.tcp.buffersize.lte 4096,87380,1220608,4096,16384,563200
setprop net.tcp.buffersize.umts 4096,87380,563200,4096,16384,110208
setprop net.tcp.buffersize.hspa 4096,87380,704512,4096,16384,110208
setprop net.tcp.buffersize.hsupa 4096,87380,704512,4096,16384,262144
setprop net.tcp.buffersize.hsdpa 4096,87380,704512,4096,16384,262144
setprop net.tcp.buffersize.hspap 4096,87380,1220608,4096,16384,393216
setprop net.tcp.buffersize.edge 4096,26280,35040,4096,16384,35040
setprop net.tcp.buffersize.gprs 4096,8760,11680,4096,8760,11680
setprop net.tcp.buffersize.evdo 4096,87380,563200,4096,16384,262144
setprop net.tcp.buffersize.evdo_b 4096,87380,704512,4096,16384,262144
# Set this property so surfaceflinger is not started by system_init
setprop system_init.startsurfaceflinger 0
# Run sysinit
exec /system/bin/sysinit
class_start core
class_start main
on nonencrypted
class_start late_start
on charger
class_start charger
on property:vold.decrypt=trigger_reset_main
class_reset main
on property:vold.decrypt=trigger_load_persist_props
load_persist_props
on property:vold.decrypt=trigger_post_fs_data
trigger post-fs-data
on property:vold.decrypt=trigger_restart_min_framework
class_start main
on property:vold.decrypt=trigger_restart_framework
class_start main
class_start late_start
on property:vold.decrypt=trigger_shutdown_framework
class_reset late_start
class_reset main
## Daemon processes to be run by init.
##
service ueventd /sbin/ueventd
class core
critical
service console /system/bin/sh
class core
console
disabled
user shell
group log
on property:ro.debuggable=1
start console
# adbd is controlled via property triggers in init.<platform>.usb.rc
service adbd /sbin/adbd
class core
disabled
# adbd on at boot in emulator
on property:ro.kernel.qemu=1
start adbd
service servicemanager /system/bin/servicemanager
class core
user system
group system
critical
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
onrestart restart drm
service vold /system/bin/vold
class core
socket vold stream 0660 root mount
ioprio be 2
service netd /system/bin/netd
class main
socket netd stream 0660 root system
socket dnsproxyd stream 0660 root inet
socket mdns stream 0660 root system
service debuggerd /system/bin/debuggerd
class main
service ril-daemon /system/bin/rild
class main
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root
group radio cache inet misc audio sdcard_r sdcard_rw qcom_oncrpc qcom_diag log
service surfaceflinger /system/bin/surfaceflinger
class main
user system
group graphics
onrestart restart zygote
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
class main
socket zygote stream 660 root system
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
onrestart restart media
onrestart restart netd
service drm /system/bin/drmserver
class main
user drm
group drm system inet drmrpc sdcard_r
service media /system/bin/mediaserver
class main
user media
group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc qcom_diag
ioprio rt 4
service bootanim /system/bin/bootanimation
class main
user graphics
group graphics
disabled
oneshot
service dbus /system/bin/dbus-daemon --system --nofork
class main
socket dbus stream 660 bluetooth bluetooth
user bluetooth
group bluetooth net_bt_admin
service bluetoothd /system/bin/bluetoothd -n
class main
socket bluetooth stream 660 bluetooth bluetooth
socket dbus_bluetooth stream 660 bluetooth bluetooth
# init.rc does not yet support applying capabilities, so run as root and
# let bluetoothd drop uid to bluetooth with the right linux capabilities
group bluetooth net_bt_admin misc
disabled
service installd /system/bin/installd
class main
socket installd stream 600 system system
service racoon /system/bin/racoon
class main
socket racoon stream 600 system system
# IKE uses UDP port 500. Racoon will setuid to vpn after binding the port.
group vpn net_admin inet
disabled
oneshot
service mtpd /system/bin/mtpd
class main
socket mtpd stream 600 system system
user vpn
group vpn net_admin inet net_raw
disabled
oneshot
service keystore /system/bin/keystore /data/misc/keystore
class main
user keystore
group keystore drmrpc
socket keystore stream 666
service dumpstate /system/bin/dumpstate -s
class main
socket dumpstate stream 0660 shell log
disabled
oneshot
service sshd /system/bin/start-ssh
class main
disabled
service mdnsd /system/bin/mdnsd
class main
user mdnsr
group inet net_raw
socket mdnsd stream 0660 mdnsr inet
disabled
oneshot
When I mount mmcblkp02 as /data "overwriting" existing one, there was much more free space in "storage" and in built-in application manager (bar at bottom of the screen), but most of apps crashes, or moment after that phone reboots.
Code:
mount -t ext2 -o rw,nosuid,nodev /dev/block/mmcblk0p2 /data
Also when I cd /data I was only seeing data from sd, and there wasn't data from internal memory. I try to copy internal data to sd cp /data/* /cache/jarek [jarek=mmcblk0p2 mount point]. but it still doesn't work after manual mount.
I read some posts and it's appear that I must change init.rc, which is overwrite on every shutdown, so to do that I need unpack recovery (boot.img), edit and repack, then upload. But than what? Probably there will problem with app's data that was in internal storage... ?
Questions:
1. is there any ready for use ROM with this feature?
2. is someone do something like this? is this work?
3. maybe it can't work and I shouldn't lose few more days on it, so tell me why? (technically only, I know I can just go buy new phone)
4. maybe I can extend existing /data with mmcblk0p2 instead swap this?
Jarek
The last months I am using LOS16 (Pie) on my OP3T and have implemented some tweaks to let it work as I want it to be.
The tweaks I am doing are implemented after a dirty flash, which I am doing roughly once a month.
After the dirty flash I am using the script enclosed to remove some apps, to clear as much as possible and startup almost clean without loosing settings.
Ofcourse also some other stuff like build.prop and userinit.sh settings are implemented.
Note:
Some people say it is not wise to clean all stuff like I do in the script, because a lot of writing is done afterwards, like building caches etc....
But, in my experience, the OP3(t) is a real killer and the cache building does not bother me.
Even after 3 years of heavy usage, everything is like new and performance is great.
So may be the result is a little more wearage of SSD, but I like a clean system and do not expect any troubles when only doing this once a month.
I want to share the script because it can help others, but I am sure there other OP3(t) users are also using scripts to optimise some settings, remove apps etc.... which can help me also.
So please, feel free to add your script(s) also and make this a place where OP3(t) users can find information to make their own script.
When you have some questions, please let me know!
BTW:
Never use a script like this when you do not know what it is doing, and ofcourse using it at your own risk!!
First read every line of it, try to understand what it is doing and what you are missing afterwards when implementing without any change (apps, launcher etc...)
Code:
#!/sbin/sh
#
# Script by 2Tweak
# Last modified 25-07-2019
################################################
# First setup
clear
sleep 0.3
echo
echo "##########################################"
echo "# ROM DEBLOAT SCRIPT #"
echo "##########################################"
echo
mount -o remount,rw /cache
mount -o remount,rw /data
mount -o remount,rw /sdcard
mount -o remount,rw /system
sleep 0.3
################################################
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
Contacts
CtsShimPrebuilt
CtsShimPrivPrebuilt
DocumentsUI
EasterEgg
Eleven
Email
ExactCalculator
Exchange2
Gallery2
HTMLViewer
InputDevices
Jelly
LatinIME
LineageSetupWizard
LiveWallpapersPicker
LockClock
ManagedProvisioning
OneTimeInitializer
OneplusDoze
OneplusPocketMode
PhotoTable
PrintRecommendationService
SharedStorageBackup
SimAppDialog
Stk
Tag
Terminal
Traceur
TrebuchetQuickStep
Updater
UserDictionaryProvider
VpnDialogs
WallpaperBackup
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!"
sleep 0.3
################################################
echo -n "Removing 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/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/monthly
/data/system/usagestats/0/weekly
/data/system/usagestats/0/yearly
/data/system/usagestats/daily
/data/tombstones
/sdcard/DCIM/.thumbnails
/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 and tmp files
find /data -iname "*.bak" -type f -exec rm -f {} +
find /data -iname "*.log" -type f -exec rm -f {} +
find /data -iname "*.tmp" -type f -exec rm -f {} +
find /data -iname "*.odex" -type f -exec rm -f {} +
find /data -iname "*.vdex" -type f -exec rm -f {} +
find /system -iname "*.bak" -type f -exec rm -f {} +
find /system -iname "*.log" -type f -exec rm -f {} +
find /system -iname "*.tmp" -type f -exec rm -f {} +
# Some other useless system related files
rm -f /data/stock_boot_*.img.gz
# Reduce fonts to the bare minimum
find /system/fonts ! -iname "*roboto*.*" ! -name "DroidSansMono.ttf" -type f -exec rm -f {} +
# Some resets after firmware upgrades
# Reset NFC
rm -f /data/nfc/nfaStorage.bin1
# Remove passwords
rm -f /data/system/locksettings.db
rm -f /data/system/locksettings.db-shm
rm -f /data/system/locksettings.db-wal
rm -f /data/system/gatekeeper.password.key
rm -f /data/system/gatekeeper.pattern.key
# Reset fingerprint
rm -f /data/system/users/0/fpdata/user.db
rm -f /data/system/users/0/settings_fingerprint.xml
echo " done!"
sleep 0.3
################################################
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 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
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
# 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/*
# 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!"
sleep 0.3
################################################
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!"
sleep 0.3
################################################
echo -n "Setting log permissions read-only..."
chmod 000 /data/system/dropbox
chmod 000 /data/system/procstats
chmod 000 /data/system/usagestats/0/daily
chmod 000 /data/system/usagestats/0/monthly
chmod 000 /data/system/usagestats/0/weekly
chmod 000 /data/system/usagestats/0/yearly
echo " done!"
sleep 0.3
################################################
echo -n "Repair Phone Is Starting error......"
rm -f '/system/vendor/bin/hw/[email protected]'
rm -f '/system/vendor/etc/init/[email protected]'
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!"
sleep 0.3
################################################
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, checks and sending data
logcat.live=disable
profiler.force_disable_err_rpt=1
profiler.force_disable_ulog=1
persist.android.strictmode=0
ro.config.nocheckin=1
ro.kernel.android.checkjni=0
ro.kernel.checkjni=0
# Disable boot animation
debug.sf.nobootanimation=1
# Disable USB debugging notification
persist.adb.notify=0
# Improve call quality
ro.ril.enable.amr.wideband=1
# Better network signals
persist.cust.tel.eons=1
ro.config.hw_fast_dormancy=1
# Enable Volte functionality
persist.dbg.ims_volte_enable=1
persist.dbg.volte_avail_ovr=1
persist.dbg.vt_avail_ovr=1
persist.dbg.wfc_avail_ovr=1
persist.volte_enalbed_by_hw=1
# Disable scrolling cache
persist.sys.scrollingcache=4
# Optimize Dalvik
dalvik.vm.dexopt-flags=v=n,o=v,m=y
# Power Savings
ro.ril.power_collapse=1
pm.sleep_mode=1
wifi.supplicant_scan_interval=500
ro.mot.eri.losalert.delay=1000
# End of my settings
' >> $fname
chmod 644 $fname
echo " done!"
sleep 0.3
################################################
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!"
sleep 0.3
################################################
echo -n "Adding my userinit.sh settings......"
echo '#!/system/bin/sh
# My settings
# Stop perfd before implementing tweaks
stop perfd
# Perfect mount options
mount -o remount,noatime,noauto_da_alloc,nodiratime,barrier=0,commit=60,nobh /system
mount -o remount,noatime,noauto_da_alloc,rw,nosuid,nodev,nodiratime,barrier=0,commit=60,nobh /data
mount -o remount,noatime,noauto_da_alloc,rw,nosuid,nodev,nodiratime,barrier=0,commit=60,nobh /cache
# Flags blocks as non-rotational and increases cache size
LOOP=`ls -d /sys/block/loop*`
RAM=`ls -d /sys/block/ram*`
for j in $LOOP $RAM
do
chmod 666 $j/queue/rotational
echo 0 > $j/queue/rotational
chmod 444 $j/queue/rotational
chmod 666 $j/queue/read_ahead_kb
echo 2048 > $j/queue/read_ahead_kb
chmod 444 $j/queue/read_ahead_kb
done
# 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
# 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
# Battery tweaks
chmod 666 proc/sys/vm/dirty_expire_centisecs
echo 1000 > /proc/sys/vm/dirty_expire_centisecs
chmod 444 proc/sys/vm/dirty_expire_centisecs
chmod 666 proc/sys/vm/dirty_writeback_centisecs
echo 2000 > /proc/sys/vm/dirty_writeback_centisecs
chmod 444 proc/sys/vm/dirty_writeback_centisecs
# Miscellaneous
chmod 666 /sys/module/sync/parameters/fsync_enabled
echo 'N' > /sys/module/sync/parameters/fsync_enabled
chmod 444 /sys/module/sync/parameters/fsync_enabled
chmod 666 /sys/block/sda/queue/iostats
echo '0' > /sys/block/sda/queue/iostats
chmod 444 /sys/block/sda/queue/iostats
# Start perfd again
start perfd
# Fstrim on boot
if [ -e /data/adb/magisk/busybox ]; then
/data/adb/magisk/busybox fstrim /cache &
/data/adb/magisk/busybox fstrim /data &
/data/adb/magisk/busybox fstrim /system &
fi
# End of my settings
' > /data/local/userinit.sh
chmod 777 /data/local/userinit.sh
echo " done!"
sleep 0.3
################################################
echo -n "Change all timestamps..............."
# Useless but nice to have most dates set to install date again
find / -type d -exec touch {} + 2>/dev/null
find / -type f -exec touch {} + 2>/dev/null
echo " done!"
sleep 0.3
################################################
if [ -e /data/adb/magisk/busybox ]; then
echo -n "Optimising disks using fstrim......."
/data/adb/magisk/busybox fstrim /cache
/data/adb/magisk/busybox fstrim /data
/data/adb/magisk/busybox fstrim /system
echo " done!"
fi
echo
Further setup (25-07-2019):
Oxygen 9.04 firmware
TWRP 3.3.1-0
Lineage OS 16
Flashkernel r58 (3.18.140) (sometimes changing to Mady's out of curiousity but performancewise I prefer Flash)
Magisk v19.3
Librechair launcher
No Google stuff, using AuroraStore and AuroraDroid as playstores.
Made some changes in setup to test if I can live without root and as simple as possible.
Further:
- removed some stuff from script,
- solved some small typings,
- added some more apk's and files to remove
I do not like the chmod lines in my userinit.sh, so probably I will add an array for that later.
Code:
#!/sbin/sh
#
# Script by 2Tweak
# Last modified 12-08-2019
################################################
# First setup
clear
echo
echo "##########################################"
echo "# ROM DEBLOAT 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
LatinIME
LineageSetupWizard
LiveWallpapersPicker
LockClock
ManagedProvisioning
OneTimeInitializer
OneplusDoze
OneplusPocketMode
PhotoTable
PrintRecommendationService
Profiles
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
/sdcard/DCIM/thumbnails
/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 and dex files
find /data -iname "*.bak" -type f -exec rm -f {} +
find /data -iname "*.log" -type f -exec rm -f {} +
find /data -iname "*.tmp" -type f -exec rm -f {} +
find /data -iname "*.odex" -type f -exec rm -f {} +
find /data -iname "*.vdex" -type f -exec rm -f {} +
find /system -iname "*.bak" -type f -exec rm -f {} +
find /system -iname "*.log" -type f -exec rm -f {} +
find /system -iname "*.tmp" -type f -exec rm -f {} +
# Some other useless system related files
rm -f /data/stock_boot_*.img.gz
rm -rf /system/vendor/overlay
# Some resets after firmware upgrades
# Reset NFC
rm -f /data/nfc/nfaStorage.bin1
# Remove passwords
rm -f /data/system/locksettings.db
rm -f /data/system/locksettings.db-shm
rm -f /data/system/locksettings.db-wal
rm -f /data/system/gatekeeper.password.key
rm -f /data/system/gatekeeper.pattern.key
# Reset fingerprint
rm -f /data/system/users/0/fpdata/user.db
rm -f /data/system/users/0/settings_fingerprint.xml
# Reduce fonts to the bare minimum
find /system/fonts ! -iname "*roboto*.*" ! -name "DroidSansMono.ttf" ! -name "NotoColorEmoji.ttf" -type f -exec rm -f {} +
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 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
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
# 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/*
# 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 "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 "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 "Repair Phone Is Starting error......"
rm -f '/system/vendor/bin/hw/[email protected]'
rm -f '/system/vendor/etc/init/[email protected]'
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 "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, checks and sending data
logcat.live=disable
profiler.force_disable_err_rpt=1
profiler.force_disable_ulog=1
persist.android.strictmode=0
ro.config.nocheckin=1
ro.kernel.android.checkjni=0
ro.kernel.checkjni=0
# Disable boot animation
debug.sf.nobootanimation=1
# Disable USB debugging notification
persist.adb.notify=0
# Disable dithering
persist.sys.use_dithering=0
# Disable scrolling cache
persist.sys.scrollingcache=4
# Optimize Dalvik
dalvik.vm.dexopt-flags=v=n,o=v,m=y
# Power Savings
ro.ril.power_collapse=1
pm.sleep_mode=1
wifi.supplicant_scan_interval=500
ro.mot.eri.losalert.delay=1000
# 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
# Stop perfd before implementing tweaks
stop perfd
# 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
# 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
# Battery tweaks
chmod 666 proc/sys/vm/dirty_expire_centisecs
echo '1000' > /proc/sys/vm/dirty_expire_centisecs
chmod 444 proc/sys/vm/dirty_expire_centisecs
chmod 666 proc/sys/vm/dirty_writeback_centisecs
echo '2000' > /proc/sys/vm/dirty_writeback_centisecs
chmod 444 proc/sys/vm/dirty_writeback_centisecs
# Disable fsync
chmod 666 /sys/module/sync/parameters/fsync_enabled
echo 'N' > /sys/module/sync/parameters/fsync_enabled
chmod 444 /sys/module/sync/parameters/fsync_enabled
# Disable iostats
chmod 666 /sys/block/sda/queue/iostats
echo '0' > /sys/block/sda/queue/iostats
chmod 444 /sys/block/sda/queue/iostats
# Start perfd again
start perfd
# Fstrim on boot
if [ -e /storage/emulated/fstrim ]; then
chmod 777 /storage/emulated/fstrim
/storage/emulated/fstrim /cache &
/storage/emulated/fstrim /data &
/storage/emulated/fstrim /system &
fi
# End of my settings
' > /data/local/userinit.sh
chmod 777 /data/local/userinit.sh
echo " done!"
################################################
if [ -e /sdcard/Config/Device/fstrim ]; then
echo -n "Optimising disks using fstrim......."
chmod 777 /sdcard/Config/Device/fstrim
/sdcard/Config/Device/fstrim /cache
/sdcard/Config/Device/fstrim /data
/sdcard/Config/Device/fstrim /system
echo " done!"
fi
echo
Further setup (12-08-2019):
Oxygen 9.05 firmware
TWRP 3.3.1-0
Lineage OS 16
Flashkernel r58 (3.18.140)
No Google stuff, using AuroraStore and AuroraDroid as playstores.
Magisk removed (no root), back to default Trebuchet launcher
Copied fstrim to /sdcard/Config/Device to use it in my script and userinit.sh.
I used trimmer app to get a good working fstrim, but probably also available elsewhere.
Removed some stuff because of issues, not working, or even not existing parameters in build.prop.
Pretty basic but working very well for me.
Code:
#!/sbin/sh
#
# Script by 2Tweak
# Last modified 24-08-2019
# Recommended to read before doing all kind of tweaks:
# https://************/most-common-android-optimization-myths-debunked/
################################################
# First setup
clear
echo
echo "##########################################"
echo "# ROM DEBLOAT 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
Contacts
CtsShimPrebuilt
CtsShimPrivPrebuilt
Development
DocumentsUI
EasterEgg
Eleven
Email
ExactCalculator
Exchange2
Gallery2
HTMLViewer
InputDevices
Jelly
LatinIME
LineageSetupWizard
LiveWallpapersPicker
LockClock
ManagedProvisioning
OneTimeInitializer
OneplusDoze
OneplusPocketMode
PhotoTable
PrintRecommendationService
Profiles
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
/sdcard/DCIM/thumbnails
/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 and dex files
find /data -iname "*.bak" -type f -exec rm -f {} +
find /data -iname "*.log" -type f -exec rm -f {} +
find /data -iname "*.tmp" -type f -exec rm -f {} +
find /data -iname "*.odex" -type f -exec rm -f {} +
find /data -iname "*.vdex" -type f -exec rm -f {} +
find /system -iname "*.bak" -type f -exec rm -f {} +
find /system -iname "*.log" -type f -exec rm -f {} +
find /system -iname "*.tmp" -type f -exec rm -f {} +
# Some other useless system related files
rm -f /data/stock_boot_*.img.gz
rm -rf /system/vendor/overlay
# Some resets after firmware upgrades
# Reset NFC
rm -f /data/nfc/nfaStorage.bin1
# Remove passwords
rm -f /data/system/locksettings.db
rm -f /data/system/locksettings.db-shm
rm -f /data/system/locksettings.db-wal
rm -f /data/system/gatekeeper.password.key
rm -f /data/system/gatekeeper.pattern.key
# Reset fingerprint
rm -f /data/system/users/0/fpdata/user.db
rm -f /data/system/users/0/settings_fingerprint.xml
echo " done!"
################################################
echo -n "Disable live display functionality.."
rm -f '/system/vendor/bin/hw/[email protected]'
rm -f '/system/vendor/etc/init/[email protected]'
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 "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 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
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
# 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/*
# 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 "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 "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
# Remove fps limit
debug.gr.swapinterval=0
# Disable boot animation
debug.sf.nobootanimation=1
# Disable USB debugging notification
persist.adb.notify=0
# Disable dithering
persist.sys.use_dithering=0
# Disable scrolling cache
persist.sys.scrollingcache=4
# Optimize Dalvik
dalvik.vm.dexopt-flags=v=n,o=v,m=y
# Disable ring delay
ro.telephony.call_ring.delay=0
ring.delay=0
# Misc power Savings
wifi.supplicant_scan_interval=500
ro.mot.eri.losalert.delay=1000
# 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
# Stop perfd - no side effects found
stop perfd
# Switch to noop
for i in /sys/block/mmc*; do
echo noop > $i/queue/scheduler
echo 0 > $i/queue/iostats
done
# 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
# Battery tweaks
chmod 666 /proc/sys/vm/dirty_expire_centisecs
echo 1000 > /proc/sys/vm/dirty_expire_centisecs
chmod 444 /proc/sys/vm/dirty_expire_centisecs
chmod 666 /proc/sys/vm/dirty_writeback_centisecs
echo 2000 > /proc/sys/vm/dirty_writeback_centisecs
chmod 444 /proc/sys/vm/dirty_writeback_centisecs
# 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 fsync
chmod 666 /sys/module/sync/parameters/fsync_enabled
echo N > /sys/module/sync/parameters/fsync_enabled
chmod 444 /sys/module/sync/parameters/fsync_enabled
# Disable iostats
chmod 666 /sys/block/sda/queue/iostats
echo 0 > /sys/block/sda/queue/iostats
chmod 444 /sys/block/sda/queue/iostats
# Fstrim on boot
if [ -e /storage/emulated/fstrim ]; then
chmod 777 /storage/emulated/fstrim
/storage/emulated/fstrim /cache
/storage/emulated/fstrim /data
/storage/emulated/fstrim /system
fi
# End of my settings
' > /data/local/userinit.sh
chmod 777 /data/local/userinit.sh
echo " done!"
################################################
if [ -e /sdcard/Config/Device/fstrim ]; then
echo -n "Optimising disks using fstrim......."
chmod 777 /sdcard/Config/Device/fstrim
/sdcard/Config/Device/fstrim /cache
/sdcard/Config/Device/fstrim /data
/sdcard/Config/Device/fstrim /system
echo " done!"
fi
echo
Further setup (24-08-2019):
Oxygen 9.05 firmware
TWRP 3.3.1-0
Lineage OS 16
Flashkernel r58 (3.18.140)
No Google stuff, using AuroraStore and AuroraDroid as playstores.
Magisk removed (no root),
Default Trebuchet launcher
Copied fstrim to /sdcard/Config/Device to use it in my script and userinit.sh.
I used trimmer app to get a good working fstrim, but probably also available elsewhere.
<removed>
After some reading and some input from people like @anupritaisno1 I came to the next setup.
I went back to rootless, encrypted my phone and made two scripts instead of one.
The install.sh script is used after installing the firmware, rom and kernel (normal dirty flashes) and is only removing the packages I am not using as some log files, and other useless stuff. Also used to implement some tweaks (userinit.sh, gps.conf, build.prop).
The cleanup.sh script is a script for removing all cache, dalvik-cache, app-caches etc.. and is the part I was only using about once a month to start almost clean without loosing settings.
install.sh, used to remove packages I am not using, some logging and other stuff, implementing some tweaks (userinit.sh):
Code:
#!/sbin/sh
#
# Script by 2Tweak
# Last modified 07-09-2019
################################################
# First setup
clear
echo
echo "##########################################"
echo "# DEBLOAT AND TWEAK 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
BasicDreams
BluetoothMidiService
BookmarkProvider
BuiltInPrintService
Calendar
CaptivePortalLogin
CNEService
CallLogBackup
CellBroadcastReceiver
CompanionDeviceManager
Contacts
CtsShimPrebuilt
CtsShimPrivPrebuilt
DocumentsUI
EasterEgg
Eleven
Email
ExactCalculator
Exchange2
Gallery2
HTMLViewer
InputDevices
Jelly
LineageSetupWizard
LiveWallpapersPicker
LockClock
ManagedProvisioning
OneTimeInitializer
PhotoTable
PrintRecommendationService
SharedStorageBackup
SimAppDialog
Stk
Tag
Terminal
Traceur
Updater
UserDictionaryProvider
VpnDialogs
WallpaperBackup
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/lineageos_updates
/data/local/tmp
/data/lost+found
/data/misc/bootstat
/data/ota
/data/ota_package
/data/system/batterystats.bin
/data/system/dropbox
/data/system/graphicsstats
/data/system/install_sessions.xml
/data/system/last-fstrim
/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" -type f -exec rm -f {} +
find /data -iname "*.log" -type f -exec rm -f {} +
find /data -iname "*.tmp" -type f -exec rm -f {} +
find /system -iname "*.bak" -type f -exec rm -f {} +
find /system -iname "*.log" -type f -exec rm -f {} +
find /system -iname "*.tmp" -type f -exec rm -f {} +
echo " done!"
################################################
echo -n "Cleaning app data..................."
for i in $(ls /data/data/)
do
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 "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 "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
# Enable VoLTE
persist.dbg.ims_volte_enable=1
persist.dbg.volte_avail_ovr=1
persist.dbg.vt_avail_ovr=1
persist.dbg.wfc_avail_ovr=1
persist.radio.rat_on=combine
persist.radio.data_ltd_sys_ind=1
persist.radio.data_con_rprt=1
persist.radio.calls.on.ims=1
# 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
# Disable iostats
chmod 666 /sys/block/sda/queue/iostats
echo "0" > /sys/block/sda/queue/iostats
chmod 444 /sys/block/sda/queue/iostats
# 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
cleanup.sh, used about once a month to have the feeling I start with an almost clean system (probably useless):
Code:
]#!/sbin/sh
#
# Script by 2Tweak
# Last modified 06-09-2019
################################################
# First setup
clear
echo
echo "##########################################"
echo "# DEEP CLEAN 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 "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 and dex files
find /data -iname "*.bak" -type f -exec rm -f {} +
find /data -iname "*.log" -type f -exec rm -f {} +
find /data -iname "*.tmp" -type f -exec rm -f {} +
find /data -iname "*.odex" -type f -exec rm -f {} +
find /data -iname "*.vdex" -type f -exec rm -f {} +
find /system -iname "*.bak" -type f -exec rm -f {} +
find /system -iname "*.log" -type f -exec rm -f {} +
find /system -iname "*.tmp" -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 and caches........"
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/org.fdroid.fdroid/files/*.apk
rm -rf /data/data/org.videolan.vlc/app_vlc/*
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 "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 "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
My setup now:
Oxygen 9.05 firmware
op3_recovery 3.3.1-0 from @anupritaisno1
Lineage OS 16
Flash kernel 3.18.140
No Google stuff, using FDroid and Aurora Store as playstores.
The idea was to have a topic where also other people would share their scripts, tweaks etc...
Am I really the only one tweaking a little around??
2Tweak said:
Am I really the only one tweaking a little around??
Click to expand...
Click to collapse
Seems so
Instead of disabling fsync try raising the fsync interval
The default is 5 seconds. Most filesystems will allow up to 300
It can be changed as:
Code:
mount -o commit=300,remount /data
Remember the higher you set it the higher the chance of data loss in case of system failure
Some filesystems will warn you in dmesg if you set the commit interval too high
anupritaisno1 said:
Seems so
Instead of disabling fsync try raising the fsync interval
The default is 5 seconds. Most filesystems will allow up to 300
It can be changed as:
Code:
mount -o commit=300,remount /data
Remember the higher you set it the higher the chance of data loss in case of system failure
Some filesystems will warn you in dmesg if you set the commit interval too high
Click to expand...
Click to collapse
Thanks, will give it a try.
2Tweak said:
Am I really the only one tweaking a little around??
Click to expand...
Click to collapse
I can think of some reasons:
- many people are over the use of scripts and just flash one of the magic magisk modules (up to debate if they are useful and if at all which of them)
- Lack of understanding which stuff is save to remove and what breaks if you do so (I struggle with this point myself) Maybe there is a neat list what the removed apks do? I mean most are pretty self explaining but not all.
Maybe my response is useless because I might not be part of the target audience but I'm still very grateful that you took your time to set up this thread and that you shared your findings and thoughts with us. I learned some new things by visiting this thread
SenseSei said:
I can think of some reasons:
- many people are over the use of scripts and just flash one of the magic magisk modules (up to debate if they are useful and if at all which of them)
- Lack of understanding which stuff is save to remove and what breaks if you do so (I struggle with this point myself) Maybe there is a neat list what the removed apks do? I mean most are pretty self explaining but not all.
Maybe my response is useless because I might not be part of the target audience but I'm still very grateful that you took your time to set up this thread and that you shared your findings and thoughts with us. I learned some new things by visiting this thread
Click to expand...
Click to collapse
Thanks for your response SenseSei, nice to hear you have learned something! :good:
That is how it works, with sharing information we all benefit!
I understand your comment about some kind of neat list of what apk's are doing.
In fact I have searched the internet a lot, but did not keep a list with explanations...
When I see an apk which is not on my list already and I do not know what it is doing, I simply search on the internet.
Then I can make my decision to remove it or not, test if it is not breaking other parts and add it to my list or not.
I was planning to switch to Glassrom last weekend, but because I am very happy with my Lineage installation at the moment AND Android 10 is on it's way, I have decided to keep using Lineage till the switch to 10.
This also means I switched back to my old behaviour; one script with removal of apk's, some tweaks in build.prop and userinit.sh and the deep clean included.
Keep in mind it is not wise to use this every day, Android need's time to settle and using this script every day will result in higher drain and wearage of your drive.
Some small things added / changed. For example I included the remount with raised fsync interval for /data instead of disabling fsync completely; a tip of @anupritaisno1. Based on some tips from him the script is also changed a little; removed some spaces and added quotes to improve riability. Font removal is back, though more fonts are kept to keep special characters in for example the weather app I am using. I added the removal of the live display stuff again because I am not using it. The 'PIS'-error is solved though, so therefor you do not need the live display removal anymore.
My setup still is:
- Firmware 9.05
- TWRP from anupritaisno1
- Lineage 16 latest nightly
- Flash kernel 3.18.140 latest (hardened kernel; fast, secure and stable)
- No Google stuff, using FDroid and AuroraStore for app installs and updates
Code:
#!/sbin/sh
#
# 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/[email protected]'
rm -f '/system/vendor/etc/init/[email protected]'
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
2Tweak said:
Thanks for your response SenseSei, nice to hear you have learned something! :good:
That is how it works, with sharing information we all benefit!
I understand your comment about some kind of neat list of what apk's are doing.
In fact I have searched the internet a lot, but did not keep a list with explanations...
When I see an apk which is not on my list already and I do not know what it is doing, I simply search on the internet.
Then I can make my decision to remove it or not, test if it is not breaking other parts and add it to my list or not.
I was planning to switch to Glassrom last weekend, but because I am very happy with my Lineage installation at the moment AND Android 10 is on it's way, I have decided to keep using Lineage till the switch to 10.
This also means I switched back to my old behaviour; one script with removal of apk's, some tweaks in build.prop and userinit.sh and the deep clean included.
Keep in mind it is not wise to use this every day, Android need's time to settle and using this script every day will result in higher drain and wearage of your drive.
Some small things added / changed. For example I included the remount with raised fsync interval for /data instead of disabling fsync completely; a tip of @anupritaisno1. Based on some tips from him the script is also changed a little; removed some spaces and added quotes to improve riability. Font removal is back, though more fonts are kept to keep special characters in for example the weather app I am using. I added the removal of the live display stuff again because I am not using it. The 'PIS'-error is solved though, so therefor you do not need the live display removal anymore.
My setup still is:
- Firmware 9.05
- TWRP from anupritaisno1
- Lineage 16 latest nightly
- Flash kernel 3.18.140 latest (hardened kernel; fast, secure and stable)
- No Google stuff, using FDroid and AuroraStore for app installs and updates
Code:
#!/sbin/sh
#
# 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/[email protected]'
rm -f '/system/vendor/etc/init/[email protected]'
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
Click to expand...
Click to collapse
Fixed it some more
Code:
# 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/[email protected]'
rm -f '/system/vendor/etc/init/[email protected]'
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
anupritaisno1 said:
Fixed it some more
Code:
<cut>
Click to expand...
Click to collapse
I compared both scripts, but why did you remove the first two lines?
Further you added quotes for the echo command:
Code:
echo "$nstr" > $fname
which is indeed a good one; thanks!
Further any changes?
The latest script for Pie I guess, seeing a lot of Android 10 activity and always been an early adapter....
Some changes:
Switched back to LibreChair as launcher. Very nice option is the ability to shape your own icons (see screenshot)
Really like Apkgrabber and Aurora, so using the combi Aurora Droid, Aurora Store (wo automatic update) and Apkgrabber now instead of GPS.
Added New Pipe and Transistor to my apps but has nothing to do with the basic setup
Setup still:
Firmware 9.05
TWRP from anupritaisno1
Latest Lineage Nightly 16.0 (Pie)
Latest Flash Kernel (3.18.140)
Further the tweak and cleanup script is pretty stable now.
Nothing to optimise or other tweaks I want to implement, so here the latest lineage.sh (also added as attachment):
Code:
#!/sbin/sh
#
# Script by 2Tweak
# Last modified 21-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
TrebuchetQuickStep
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/[email protected]'
rm -f '/system/vendor/etc/init/[email protected]'
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
As you probably know; use at your own risc!
---
I am on NOS 10 at the moment and started with a new, in fact my old approach.
Not using Magisk or SuperSU and keeping it as default as possible.
Using adb to disable packages without removing, next step will be a short twrp cleanup script once a month for cache and other crap files.
Using the following bat file for disabling packages and setting some optimised doze settings:
Code:
:setup
@echo off
color 0A
cls
echo.
echo Connect device...
adb devices
:packages
echo.
echo Disable packages...
:: Tag
adb shell pm disable-user --user 0 com.android.apps.tag
adb shell am force-stop com.android.apps.tag
adb shell pm clear com.android.apps.tag
:: BackupRestoreConfirmation
adb shell pm disable-user --user 0 com.android.backupconfirm
adb shell am force-stop com.android.backupconfirm
adb shell pm clear com.android.backupconfirm
:: BuiltInPrintService
adb shell pm disable-user --user 0 com.android.bips
adb shell am force-stop com.android.bips
adb shell pm clear com.android.bips
:: BluetoothMidiService
adb shell pm disable-user --user 0 com.android.bluetoothmidiservice
adb shell am force-stop com.android.bluetoothmidiservice
adb shell pm clear com.android.bluetoothmidiservice
:: BookmarkProvider
adb shell pm disable-user --user 0 com.android.bookmarkprovider
adb shell am force-stop com.android.bookmarkprovider
adb shell pm clear com.android.bookmarkprovider
:: Calendar
adb shell pm disable-user --user 0 com.android.calendar
adb shell am force-stop com.android.calendar
adb shell pm clear com.android.calendar
:: CallLogBackup >> HAVE TO TEST!!
adb shell pm disable-user --user 0 com.android.calllogbackup
adb shell am force-stop com.android.calllogbackup
adb shell pm clear com.android.calllogbackup
:: CaptivePortalLogin
adb shell pm disable-user --user 0 com.android.captiveportallogin
adb shell am force-stop com.android.captiveportallogin
adb shell pm clear com.android.captiveportallogin
:: CellBroadcastReceiver
adb shell pm disable-user --user 0 com.android.cellbroadcastreceiver
adb shell am force-stop com.android.cellbroadcastreceiver
adb shell pm clear com.android.cellbroadcastreceiver
:: CompanionDeviceManager
adb shell pm disable-user --user 0 com.android.companiondevicemanager
adb shell am force-stop com.android.companiondevicemanager
adb shell pm clear com.android.companiondevicemanager
:: Contacts
adb shell pm disable-user --user 0 com.android.contacts
adb shell am force-stop com.android.contacts
adb shell pm clear com.android.contacts
:: CtsShimPrebuilt
adb shell pm disable-user --user 0 com.android.cts.ctsshim
adb shell am force-stop com.android.cts.ctsshim
adb shell pm clear com.android.cts.ctsshim
:: CtsShimPrivPrebuilt
adb shell pm disable-user --user 0 com.android.cts.priv.ctsshim
adb shell am force-stop com.android.cts.priv.ctsshim
adb shell pm clear com.android.cts.priv.ctsshim
:: DocumentsUI
adb shell pm disable-user --user 0 com.android.documentsui
adb shell am force-stop com.android.documentsui
adb shell pm clear com.android.documentsui
:: BasicDreams
adb shell pm disable-user --user 0 com.android.dreams.basic
adb shell am force-stop com.android.dreams.basic
adb shell pm clear com.android.dreams.basic
:: PhotoTable
adb shell pm disable-user --user 0 com.android.dreams.phototable
adb shell am force-stop com.android.dreams.phototable
adb shell pm clear com.android.dreams.phototable
:: DynamicSystemInstallationService
adb shell pm disable-user --user 0 com.android.dynsystem
adb shell am force-stop com.android.dynsystem
adb shell pm clear com.android.dynsystem
:: EasterEgg
adb shell pm disable-user --user 0 com.android.egg
adb shell am force-stop com.android.egg
adb shell pm clear com.android.egg
:: Email
adb shell pm disable-user --user 0 com.android.email
adb shell am force-stop com.android.email
adb shell pm clear com.android.email
:: ExternalStorageProvider
adb shell pm disable-user --user 0 com.android.externalstorage
adb shell am force-stop com.android.externalstorage
adb shell pm clear com.android.externalstorage
:: Gallery2
adb shell pm disable-user --user 0 com.android.gallery3d
adb shell am force-stop com.android.gallery3d
adb shell pm clear com.android.gallery3d
:: InputDevices
adb shell pm disable-user --user 0 com.android.inputdevices
adb shell am force-stop com.android.inputdevices
adb shell pm clear com.android.inputdevices
:: DisplayCutoutEmulationCorner
adb shell pm disable-user --user 0 com.android.internal.display.cutout.emulation.corner
adb shell am force-stop com.android.internal.display.cutout.emulation.corner
adb shell pm clear com.android.internal.display.cutout.emulation.corner
:: DisplayCutoutEmulationDouble
adb shell pm disable-user --user 0 com.android.internal.display.cutout.emulation.double
adb shell am force-stop com.android.internal.display.cutout.emulation.double
adb shell pm clear com.android.internal.display.cutout.emulation.double
:: DisplayCutoutEmulationTall
adb shell pm disable-user --user 0 com.android.internal.display.cutout.emulation.tall
adb shell am force-stop com.android.internal.display.cutout.emulation.tall
adb shell pm clear com.android.internal.display.cutout.emulation.tall
:: LocalTransport
adb shell pm disable-user --user 0 com.android.localtransport
adb shell am force-stop com.android.localtransport
adb shell pm clear com.android.localtransport
:: ManagedProvisioning
adb shell pm disable-user --user 0 com.android.managedprovisioning
adb shell am force-stop com.android.managedprovisioning
adb shell pm clear com.android.managedprovisioning
:: Music
adb shell pm disable-user --user 0 com.android.music
adb shell am force-stop com.android.music
adb shell pm clear com.android.music
:: MusicFX
adb shell pm disable-user --user 0 com.android.musicfx
adb shell am force-stop com.android.musicfx
adb shell pm clear com.android.musicfx
:: NfcNci
adb shell pm disable-user --user 0 com.android.nfc
adb shell am force-stop com.android.nfc
adb shell pm clear com.android.nfc
:: OneTimeInitializer
adb shell pm disable-user --user 0 com.android.onetimeinitializer
adb shell am force-stop com.android.onetimeinitializer
adb shell pm clear com.android.onetimeinitializer
:: PrintRecommendationService
adb shell pm disable-user --user 0 com.android.printservice.recommendation
adb shell am force-stop com.android.printservice.recommendation
adb shell pm clear com.android.printservice.recommendation
:: QuickSearchBox
adb shell pm disable-user --user 0 com.android.quicksearchbox
adb shell am force-stop com.android.quicksearchbox
adb shell pm clear com.android.quicksearchbox
:: SettingsIntelligence
adb shell pm disable-user --user 0 com.android.settings.intelligence
adb shell am force-stop com.android.settings.intelligence
adb shell pm clear com.android.settings.intelligence
:: SharedStorageBackup
adb shell pm disable-user --user 0 com.android.sharedstoragebackup
adb shell am force-stop com.android.sharedstoragebackup
adb shell pm clear com.android.sharedstoragebackup
:: SimAppDialog
adb shell pm disable-user --user 0 com.android.simappdialog
adb shell am force-stop com.android.simappdialog
adb shell pm clear com.android.simappdialog
:: Stk
adb shell pm disable-user --user 0 com.android.stk
adb shell am force-stop com.android.stk
adb shell pm clear com.android.stk
:: Terminal
adb shell pm disable-user --user 0 com.android.terminal
adb shell am force-stop com.android.terminal
adb shell pm clear com.android.terminal
:: Traceur
adb shell pm disable-user --user 0 com.android.traceur
adb shell am force-stop com.android.traceur
adb shell pm clear com.android.traceur
:: UserDictionaryProvider
adb shell pm disable-user --user 0 com.android.providers.userdictionary
adb shell am force-stop com.android.providers.userdictionary
adb shell pm clear com.android.providers.userdictionary
:: VpnDialogs
adb shell pm disable-user --user 0 com.android.vpndialogs
adb shell am force-stop com.android.vpndialogs
adb shell pm clear com.android.vpndialogs
:: WallpaperBackup
adb shell pm disable-user --user 0 com.android.wallpaperbackup
adb shell am force-stop com.android.wallpaperbackup
adb shell pm clear com.android.wallpaperbackup
:: LiveWallpapersPicker
adb shell pm disable-user --user 0 com.android.wallpaper.livepicker
adb shell am force-stop com.android.wallpaper.livepicker
adb shell pm clear com.android.wallpaper.livepicker
:: AntHalService
adb shell pm disable-user --user 0 com.dsi.ant.server
adb shell am force-stop com.dsi.ant.server
adb shell pm clear com.dsi.ant.server
:: HTMLViewer
adb shell pm disable-user --user 0 com.android.htmlviewer
adb shell am force-stop com.android.htmlviewer
adb shell pm clear com.android.htmlviewer
:: WfdService
adb shell pm disable-user --user 0 com.qualcomm.wfd.service
adb shell am force-stop com.qualcomm.wfd.service
adb shell pm clear com.qualcomm.wfd.service
:: datastatusnotification
adb shell pm disable-user --user 0 com.qti.qualcomm.datastatusnotification
adb shell am force-stop com.qti.qualcomm.datastatusnotification
adb shell pm clear com.qti.qualcomm.datastatusnotification
:: CNEService
adb shell pm disable-user --user 0 com.quicinc.cne.CNEService
adb shell am force-stop com.quicinc.cne.CNEService
adb shell pm clear com.quicinc.cne.CNEService
:: SoterService
adb shell pm disable-user --user 0 com.tencent.soter.soterserver
adb shell am force-stop com.tencent.soter.soterserver
adb shell pm clear com.tencent.soter.soterserver
:: Unknown
adb shell pm disable-user --user 0 org.chromium.webview_shell
adb shell am force-stop org.chromium.webview_shell
adb shell pm clear org.chromium.webview_shell
:: DO NOT DISABLE WHEN USING PASSWORD:
:: LatinIME - com.android.inputmethod.latin
:: DO NOT DISABLE WHEN NO OTHER LAUNCHER IS USED:
:: Launcher3QuickStep - com.android.launcher3
:: DO NOT DISABLE AT FIRST BOOT:
:: OneTimeInitializer - com.android.onetimeinitializer
:: DO NOT DISABLE ON NITROGEN BECAUSE OF CRASH ON BOOT:
:: WallpaperCropper - com.android.wallpapercropper
:doze
echo.
echo Modify doze settings...
:: Remove old modified settings
adb shell settings delete global device_idle_constants
:: Enable doze
adb shell dumpsys deviceidle enable
:: To put phone in deep sleep immediately
adb shell dumpsys deviceidle force-idle
:: Modified doze settings
adb shell settings put global device_idle_constants inactive_to=15000,sensing_to=0,locating_to=0,location_accuracy=20.0,motion_inactive_to=0,idle_after_inactive_to=0,idle_pending_to=60000,max_idle_pending_to=120000,idle_pending_factor=2.0,idle_to=900000,max_idle_to=86400000,idle_factor=2.0,min_time_to_alarm=600000,max_temp_app_whitelist_duration=10000,mms_temp_app_whitelist_duration=10000,sms_temp_app_whitelist_duration=10000
:reboot
echo.
echo Press button to reboot phone...
pause
adb reboot
GuestK00264 said:
I am on NOS 10 at the moment and started with a new, in fact my old approach.
Not using Magisk or SuperSU and keeping it as default as possible.
Using adb to disable packages without removing, next step will be a short twrp cleanup script once a month for cache and other crap files.
Using the following bat file for disabling packages and setting some optimised doze settings:
Click to expand...
Click to collapse
Hi!
Why did you go back to trebuchet, is there anything wrong with librechair? I installed librechair today and I kinda like it, so I'm curious whether you found a downside or just prefer the more simplistic trebuchet..
Thanks in advance
Okay script people, i'm currently using the following to delete a font on Pie ROMs:
Code:
run_program("/sbin/mount", "/system");
ui_print(" ");
ui_print("***Working***");
delete_recursive(
"/system/fonts/NotoColorEmoji.ttf"
);
ui_print("Removing Emoji");
show_progress(8.800000, 5);
run_program("/sbin/umount", "/system");
ui_print(" ");
ui_print("Done.");
ui_print("Ready to reboot.");
How should this be adapted to work on Android 10? As far as i know the folder is now system/system/fonts which is easy to change, but is there anything that needs changing regarding the mount point now that system is root? I know that bash scripts need adapting but don't know about edify.
Thanks.
<deleted>
<deleted>
The script as using it for latest LOS18.1:
Code:
#!/sbin/sh
#
# Last modified 2022-01-01
#############################################################
clear
sleep 0.1
echo
echo "#######################################################"
echo "# ANDROID SETUP SCRIPT #"
echo "#######################################################"
echo
# User input to choose what to do
echo "Choose one of the following options:"
echo "S or s = Setup Android without cleaning"
echo "C or c = Deep clean current installation"
echo "F or f = Setup Android including deep clean"
echo "Q or q = Quit the script"
echo
while true
do
# (1) prompt user, and read command line argument
# the second line is producing a backslash to hide output
read -s -n1 answer
echo -n -e "\b \b"
# (2) handle the input we were given
case $answer in
[sS]* ) parm="1"
echo "Your choice:"
echo "Setup of Android without cleaning"
break;;
[cC]* ) parm="2"
echo "Your choice:"
echo "Deep clean of current installation"
break;;
[fF]* ) parm="3"
echo "Your choice:"
echo "Setup of Android including deep clean"
break;;
[qQ]* ) echo "Exited script"
echo
exit;;
* ) echo "Please enter an existing option...";;
esac
done
echo
echo "#######################################################"
echo
#############################################################
echo -n "First script setup..............................."
# Mount or remount drives read-write
umount /system 2>/dev/null
umount /system_root 2>/dev/null
mount -o rw /cache 2>/dev/null
mount -o rw /data 2>/dev/null
mount -o rw /sdcard 2>/dev/null
mount -o rw /system_root 2>/dev/null
# Mount vendor/firmware_mnt
if ! mountpoint -q "/system_root/system/vendor/firmware_mnt"; then
mount /dev/block/by-name/modem /system_root/system/vendor/firmware_mnt
fi
if [ ! -e "/system_root/system/vendor/firmware_mnt" ]; then
echo " done!"
echo ""
echo "ERROR:"
echo "/system/vendor not mounted correctly, exiting script"
exit
fi
echo " done!"
#############################################################
if [ "$parm" == "1" ] || [ "$parm" == "3" ]; then
echo -n "Remove some system apps, modules and services...."
applist="
AntHalService
AudioFX
BasicDreams
BluetoothMidiService
BookmarkProvider
BuiltInPrintService
CallLogBackup
CaptivePortalLogin
CarrierDefaultApp
CellBroadcastLegacyApp
CneApp
CompanionDeviceManager
CtsShimPrebuilt
CtsShimPrivPrebuilt
datastatusnotification
dpmserviceapp
DynamicSystemInstallationService
EasterEgg
Eleven
embms
Gallery2
HTMLViewer
IFAAService
InputDevices
IWlanService
Jelly
LineageSetupWizard
LineageThemesStub
LiveWallpapersPicker
ManagedProvisioning
OneTimeInitializer
PhotoTable
PowerOffAlarm
PrintRecommendationService
QuickAccessWallet
Seedvault
SimAppDialog
SoterService
Stk
Traceur
Updater
VpnDialogs
WallpaperBackup
WallpaperCropper
WAPPushManager
"
# BASIC:
# AudioFX
# Eleven
# Gallery2
# IFAAService
# Jelly
# PowerOffAlarm
# SoterService
# Updater
for appname in $applist
do
if [ -e "/system_root/system/app/$appname" ]; then
chmod -R 777 "/system_root/system/app/$appname" 2>/dev/null
rm -rf "/system_root/system/app/$appname" 2>/dev/null
fi
if [ -e "/system_root/system/priv-app/$appname" ]; then
chmod -R 777 "/system_root/system/priv-app/$appname" 2>/dev/null
rm -rf "/system_root/system/priv-app/$appname" 2>/dev/null
fi
if [ -e "/system_root/system/product/app/$appname" ]; then
chmod -R 777 "/system_root/system/product/app/$appname" 2>/dev/null
rm -rf "/system_root/system/product/app/$appname" 2>/dev/null
fi
if [ -e "/system_root/system/product/priv-app/$appname" ]; then
chmod -R 777 "/system_root/system/product/priv-app/$appname" 2>/dev/null
rm -rf "/system_root/system/product/priv-app/$appname" 2>/dev/null
fi
if [ -e "/system_root/system/system_ext/app/$appname" ]; then
chmod -R 777 "/system_root/system/system_ext/app/$appname" 2>/dev/null
rm -rf "/system_root/system/system_ext/app/$appname" 2>/dev/null
fi
if [ -e "/system_root/system/system_ext/priv-app/$appname" ]; then
chmod -R 777 "/system_root/system/system_ext/priv-app/$appname" 2>/dev/null
rm -rf "/system_root/system/system_ext/priv-app/$appname" 2>/dev/null
fi
if [ -e "/system_root/system/vendor/app/$appname" ]; then
chmod -R 777 "/system_root/system/vendor/app/$appname" 2>/dev/null
rm -rf "/system_root/system/vendor/app/$appname" 2>/dev/null
fi
done
# Remove Soter Ifaa and Alipay blobs
# https://forum.xda-developers.com/oneplus-3/how-to/guide-deblob-alipay-ifaa-tencent-soter-t4064893/
find /system_root/system ! -name "*manager*" -name "*alipay*" -name "*soter*" -name "*ifaa*" -type f -exec rm -f {} + 2>/dev/null
# Remove emergency service
rm -rf /system_root/system/apex/com.android.cellbroadcast 2>/dev/null
# Reduce fonts to the bare minimum
find /system_root/system/fonts ! -name "Roboto*.*" ! -name "DroidSansMono.ttf" ! -name "NotoColorEmoji.ttf" ! -name "NotoSansSymbols-Regular-Subsetted*.ttf" -type f -exec rm -f {} +
# Remove most overlay and related stuff
rm -rf /system_root/system/product/fonts 2>/dev/null
find /system_root/system/product/overlay -maxdepth 1 -mindepth 1 -not -name "*LineageBlackTheme*" -not -name "." -exec rm -rf {} +
echo " done!"
fi
#############################################################
if [ "$parm" == "1" ] || [ "$parm" == "3" ]; then
echo -n "Remove live display functionality................"
rm -f '/system_root/system/vendor/bin/hw/[email protected]'
rm -f '/system_root/system/vendor/etc/init/[email protected]'
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 < "/system_root/system/vendor/etc/vintf/manifest.xml"
echo "$nstr" > "/system_root/system/vendor/etc/vintf/manifest.xml"
chmod 644 "/system_root/system/vendor/etc/vintf/manifest.xml"
echo " done!"
fi
#############################################################
if [ "$parm" == "1" ] || [ "$parm" == "3" ]; then
if [ -e /sdcard/Config/System/arm64_SystemWebView.apk ]; then
echo -n "Adding Bromite webview (install also after boot!)"
cp -f /sdcard/Config/System/arm64_SystemWebView.apk /system_root/system/product/app/webview/webview.apk
chmod 644 /system_root/system/product/app/webview/webview.apk
echo " done!"
fi
fi
#############################################################
if [ "$parm" == "1" ] || [ "$parm" == "3" ]; then
if [ -e /sdcard/Config/System/bootanimation.zip ]; then
echo -n "Adding customized boot animation................."
rm -f /system_root/system/media/bootanimation.zip
cp -f /sdcard/Config/System/bootanimation.zip /system_root/system/media/bootanimation.zip
chmod 644 /system_root/system/media/bootanimation.zip
echo " done!"
fi
fi
#############################################################
if [ "$parm" == "1" ] || [ "$parm" == "3" ]; then
echo -n "Adding optimised build.prop settings............."
iname="/system_root/system/vendor/build.prop"
jname="/system_root/system/build.prop"
kname="/system_root/system/product/build.prop"
lname="/system_root/system/system_ext/build.prop"
# Replace 3250mv by 3400mv for battery
sed -i 's/3250/3400/g' $jname
# Disable iwlan in build.prop as we actually removed the apk
sed -i 's/persist.data.iwlan.enable=true/persist.data.iwlan.enable=false/g' $jname
# Disable CNE in build.prop as we actually removed the apk
sed -i 's/persist.vendor.cne.feature=1/persist.vendor.cne.feature=0/g' $jname
# Remove all settings we are using in build.prop files
proplist="
persist.vendor.cne.feature
logcat.live
ro.config.nocheckin
profiler.force_disable_err_rpt
profiler.force_disable_ulog
pm.sleep_mode
ro.ril.disable.power.collapse
ro.ril.power_collapse
persist.android.strictmode
ro.kernel.checkjni
ro.kernel.android.checkjni
dalvik.vm.checkjni
dalvik.vm.dexopt-data-only
dalvik.vm.verify-bytecode
dalvik.vm.dexopt-flags
dalvik.vm.execution-mode
ro.mot.eri.losalert.delay
wifi.supplicant_scan_interval
debug.composition.type
debug.sf.hw
persist.debug.wfd.enable
ro.sf.lcd_density
hwui.disable_vsync
debug.sf.no_hw_vsync
hwui.render_dirty_regions
persist.sys.use_dithering
ro.build.selinux
ro.debuggable
ro.secure
ro.build.tags
ro.product.build.tags
ro.system.build.tags
ro.system_ext.build.tags
ro.vendor.build.tags
ro.build.type
ro.product.build.type
ro.system.build.type
ro.system_ext.build.type
ro.vendor.build.type
ro.build.version.security_patch
ro.vendor.build.security_patch
fw.max_users
fw.power_user_switcher
fw.show_hidden_users
fw.show_multiuserui
audio.safemedia.bypass
persist.adb.notify
"
for propname in $proplist
do
tmpvar1=$(sed "/$propname/d" $iname)
echo "$tmpvar1" > $iname
tmpvar2=$(sed "/$propname/d" $jname)
echo "$tmpvar2" > $jname
tmpvar3=$(sed "/$propname/d" $kname)
echo "$tmpvar3" > $kname
tmpvar4=$(sed "/$propname/d" $lname)
echo "$tmpvar4" > $lname
done
# Now add or replace settings
tmpvar5=$(sed '/.*My settings.*/{s///;q;}' $iname | sed '$d')
echo "$tmpvar5" > $iname
echo '
# My settings
# LOGGING & ERRORS
logcat.live=disable
ro.config.nocheckin=1
profiler.force_disable_err_rpt=1
profiler.force_disable_ulog=1
# EFFICIENCY
pm.sleep_mode=1
ro.ril.disable.power.collapse=0
ro.ril.power_collapse=1
persist.android.strictmode=0
ro.kernel.checkjni=0
ro.kernel.android.checkjni=0
dalvik.vm.checkjni=false
dalvik.vm.dexopt-data-only=1
dalvik.vm.verify-bytecode=false
dalvik.vm.dexopt-flags=v=n,o=a,u=y
dalvik.vm.execution-mode=int:jit
ro.mot.eri.losalert.delay=1000
wifi.supplicant_scan_interval=360
debug.composition.type=gpu
debug.sf.hw=1
# MIRACAST DISABLE
persist.debug.wfd.enable=0
# SCREEN
ro.sf.lcd_density=432
hwui.disable_vsync=true
debug.sf.no_hw_vsync=1
hwui.render_dirty_regions=false
persist.sys.use_dithering=0
# SECURITY SPOOFING
ro.build.selinux=0
ro.debuggable=0
ro.secure=1
ro.build.tags=release-keys
ro.product.build.tags=release-keys
ro.system.build.tags=release-keys
ro.system_ext.build.tags=release-keys
ro.vendor.build.tags=release-keys
ro.build.type=user
ro.product.build.type=user
ro.system.build.type=user
ro.system_ext.build.type=user
ro.vendor.build.type=user
ro.build.version.security_patch=2022-01-03
ro.vendor.build.security_patch=2022-01-03
# SINGLE USER
fw.max_users=1
fw.power_user_switcher=0
fw.show_hidden_users=0
fw.show_multiuserui=0
# WARNINGS
audio.safemedia.bypass=true
persist.adb.notify=0
' >> $iname
chmod 644 $iname
chmod 644 $jname
chmod 644 $kname
chmod 644 $lname
echo " done!"
fi
#############################################################
if [ "$parm" == "1" ] || [ "$parm" == "3" ]; then
echo -n "Adding optimised gps.conf settings..............."
rm -f "/system_root/system/vendor/etc/gps.conf"
rm -f "/system_root/system/etc/gps_debug.conf"
touch "/system_root/system/vendor/etc/gps.conf"
echo '# My secure gps only settings
# NTP Server - only one allowed!
NTP_SERVER=nl.pool.ntp.org
# Standalone mode
SUPL_MODE=0
# Disable AGPS injection
AGPS_CONFIG_INJECT=0
# No XTRA testing
XTRA_TEST_ENABLED=0
# AGPS secure settings
SUPL_HOST=localhost
SUPL_PORT=7275
SUPL_TLS_HOST=localhost
# Accuracy all better then 5000m
ACCURACY_THRES=5000
# Give position immediately also without lock
INTERMEDIATE_POS=1
# Debug level
DEBUG_LEVEL=0
# GPS lock for privacy when switched off
GPS_LOCK=3
# Disable emergency SUPL
SUPL_ES=0
# End of my settings
' > "/system_root/system/vendor/etc/gps.conf"
cp -f "/system_root/system/vendor/etc/gps.conf" "/system_root/system/etc/gps_debug.conf"
chmod 644 "/system_root/system/vendor/etc/gps.conf"
chmod 644 "/system_root/system/etc/gps_debug.conf"
echo " done!"
fi
#############################################################
if [ "$parm" == "2" ] || [ "$parm" == "3" ]; then
echo -n "Cleanup system files............................."
# file list to cleanup
filelist="
/cache
/data/anr
/data/backup
/data/cache
/data/dalvik-cache
/data/local/tmp
/data/lost+found
/data/misc/bootstat
/data/ota
/data/ota_package
/data/resource-cache
/data/system/battery-history
/data/system/battery-saver
/data/system/batterystats-checkin.bin
/data/system/batterystats-daily.bin
/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
/data/xtended_updates
/sdcard/DCIM/.thumbnails
/sdcard/Movies/.thumbnails
/sdcard/Music/.thumbnails
/sdcard/Pictures/.thumbnails
"
for filename in $filelist
do
if [ -d "$filename" ]; then
chmod -R 777 "$filename" 2>/dev/null
rm -rf "${filename:?}"/* 2>/dev/null
fi
if [ -f "$filename" ]; then
chmod 777 "$filename" 2>/dev/null
rm -f "$filename" 2>/dev/null
fi
done
# Remove bak, log, tmp files in /system
find /system_root/system -name "*.bak" -name "*.log" -name "*.tmp" -exec rm -f {} + 2>/dev/null
# Misc stuff
rm -f "/system_root/system/vendor/recovery-from-boot.p" 2>/dev/null
rm -f "/system_root/system/vendor/recovery-from-boot.bak" 2>/dev/null
# App specific
rm -rf /data/data/com.abnamro.nl.mobile.payments/app_dex/oat/arm64/* 2>/dev/null
rm -rf /data/data/org.fdroid.fdroid/files/*.apk 2>/dev/null
rm -rf /data/data/org.videolan.vlc/app_vlc/* 2>/dev/null
# Battery stuff
rm -rf /data/system/batt*.* 2>/dev/null
rm -rf /data/system/batt* 2>/dev/null
echo " done!"
fi
#############################################################
if [ "$parm" == "2" ] || [ "$parm" == "3" ]; then
echo -n "Cleanup app data................................."
# Remove bak, log, tmp, odex, vdex files
find /data -iname "*.bak" -iname "*.log" -iname "*.tmp" -iname "*.odex" -iname "*.vdex" -exec rm -f {} + 2>/dev/null
find /sdcard -iname "*.bak" -iname "*.log" -iname "*.tmp" -iname "*.odex" -iname "*.vdex" -exec rm -f {} + 2>/dev/null
# Some app file cleanup
for i in $(ls /data/data/)
do
if [ -e /data/data/"$i"/cache ]; then
chmod -R 777 /data/data/"$i"/cache 2>/dev/null
rm -rf /data/data/"$i"/cache/* 2>/dev/null
fi
if [ -e /data/data/"$i"/code_cache ]; then
chmod -R 777 /data/data/"$i"/code_cache 2>/dev/null
rm -rf /data/data/"$i"/code_cache/* 2>/dev/null
fi
if [ -e /data/data/"$i"/files/.Fabric ]; then
chmod -R 777 /data/data/"$i"/files/.Fabric 2>/dev/null
rm -rf /data/data/"$i"/files/.Fabric/* 2>/dev/null
fi
if [ -e /data/data/"$i"/files/cache ]; then
chmod -R 777 /data/data/"$i"/files/cache 2>/dev/null
rm -rf /data/data/"$i"/files/cache/* 2>/dev/null
fi
if [ -e /data/data/"$i"/app_webview ]; then
find /data/data/"$i"/app_webview ! -name "Cookies*" -type f -exec rm -f {} + 2>/dev/null
find /data/data/"$i"/app_webview -type d -depth -exec rmdir {} + 2>/dev/null
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 2>/dev/null
rm -rf /sdcard/Android/data/"$k"/cache/* 2>/dev/null
fi
done
# App specific
rm -rf /data/data/com.abnamro.nl.mobile.payments/app_dex/oat/arm64/* 2>/dev/null
rm -rf /data/data/org.fdroid.fdroid/files/*.apk 2>/dev/null
rm -rf /data/data/org.videolan.vlc/app_vlc/* 2>/dev/null
echo " done!"
fi
#############################################################
if [ "$parm" == "2" ] || [ "$parm" == "3" ]; then
echo -n "Cleanup empty directories........................"
# Remove empty directories
find /sdcard ! -name "*Downloads*" ! -name "*Camera*" -type d -depth -exec rmdir {} + 2>/dev/null
# Just to be sure they are (still) there...
mkdir /sdcard/Download 2>/dev/null
mkdir -p /sdcard/DCIM/Camera 2>/dev/null
chmod -R 770 /sdcard/Download 2>/dev/null
chmod -R 770 /sdcard/DCIM 2>/dev/null
echo " done!"
fi
#############################################################
echo -n "Optimising app databases........................."
# Optimize databases
for i in $(find /data -name "*.db" -type f)
do
sqlite3 "$i" "VACUUM;" 2>/dev/null
sqlite3 "$i" "REINDEX;" 2>/dev/null
done
for i in $(find /sdcard -name "*.db" -type f)
do
sqlite3 "$i" "VACUUM;" 2>/dev/null
sqlite3 "$i" "REINDEX;" 2>/dev/null
done
echo " done!"
#############################################################
# If available, run fstrim to optimise disks
if [ -e /sdcard/Config/System/fstrim ]; then
echo -n "Optimising disks using fstrim...................."
chmod 777 /sdcard/Config/System/fstrim
/sdcard/Config/System/fstrim /cache 2>/dev/null
/sdcard/Config/System/fstrim /data 2>/dev/null
/sdcard/Config/System/fstrim /sdcard 2>/dev/null
/sdcard/Config/System/fstrim /system 2>/dev/null
echo " done!"
fi
#############################################################
echo -n "Let us finish and unmount disks.................."
umount /system_root/system/vendor/firmware_mnt
umount /system 2>/dev/null
umount /system_root 2>/dev/null
echo " done!"
#############################################################
# User input to choose what to do
echo
echo "#######################################################"
echo
echo "Script completed, what now?"
echo "R or r = Reboot to system"
echo "Q or q = Quit the script"
echo
while true
do
# (1) prompt user, and read command line argument
# the second line is producing a backslash to hide output
read -s -n1 answer
echo -n -e "\b \b"
# (2) handle the input we were given
case $answer in
[rR]* ) echo "Your choice:"
echo "Reboot to system"
echo
sleep 0.5
reboot;;
[qQ]* ) echo "Your choice:"
echo "Quit the script"
echo
exit;;
* ) echo "Please enter an existing option...";;
esac
done
echo