voku1987

Galaxy S II TweakLite

Jan 17th, 2012
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/system/bin/sh
  2. #
  3. # file: /system/etc/init.d/98S2TweakLite v1
  4. # - adapted from "SSSwitch by voku1987 [voku(at)voku-online(dot)de] (Screen State Switch Lite)"
  5. #  
  6.  
  7.  
  8. # =========
  9. # One-time tweaks to apply on every boot;
  10. # =========
  11. MMC=`ls -d /sys/block/mmc*`;
  12.  
  13. # =========
  14. # Remount all partitions
  15. # =========
  16. for j in $(busybox mount | cut -d " " -f3);
  17. do
  18.     sync;
  19.     busybox mount -o remount,noatime,nodiratime $j;
  20. done;
  21.  
  22. for k in $(busybox mount | grep relatime | cut -d " " -f3);
  23. do
  24.     sync;
  25.     busybox mount -o remount,noatime,nodiratime $k;
  26. done;
  27.  
  28. for l in $(busybox mount | grep ext3 | cut -d " " -f3);
  29. do
  30.     sync;
  31.     busybox mount -o remount,noatime,nodiratime,commit=15 $l;
  32. done;
  33.  
  34. for m in $(busybox mount | grep ext4 | cut -d " " -f3);
  35. do
  36.     sync;
  37.     busybox mount -o remount,noatime,nodiratime,commit=15 $m;
  38. done;
  39.  
  40. # =========
  41. # Optimize io scheduler
  42. # =========
  43. for i in $MMC;
  44. do
  45.     if [ -e $i/queue/scheduler ];
  46.     then
  47.         /system/xbin/echo "bfq" > $i/queue/scheduler;
  48.     fi;
  49.  
  50.     if [ -e $i/queue/iostats ];
  51.     then
  52.         /system/xbin/echo "0" > $i/queue/iostats;
  53.     fi;
  54.  
  55.     if [ -e $i/queue/iosched/back_seek_penalty ];
  56.     then
  57.         /system/xbin/echo "1" > $i/queue/iosched/back_seek_penalty;
  58.     fi;
  59.  
  60.     if [ -e $i/queue/iosched/slice_idle ];
  61.     then
  62.         /system/xbin/echo "0" > $i/queue/iosched/slice_idle;
  63.     fi;
  64.  
  65.     if [ -e $i/queue/iosched/slice_async_rq ];
  66.     then
  67.         /system/xbin/echo "2" > $i/queue/iosched/slice_async_rq;
  68.     fi;
  69.  
  70.     if [ -e $i/queue/read_ahead_kb ];
  71.     then
  72.         /system/xbin/echo "512" > $i/queue/read_ahead_kb;
  73.     fi;
  74.  
  75.     if [ -e $i/queue/iosched/back_seek_max ];
  76.     then
  77.         /system/xbin/echo "1000000000" > $i/queue/iosched/back_seek_max;
  78.     fi;
  79.  
  80.     if [ -e $i/queue/iosched/quantu ];
  81.     then
  82.         /system/xbin/echo "16" > $i/queue/iosched/quantum;
  83.     fi;
  84.  
  85.     if [ -e $i/queue/nr_requests ];
  86.     then
  87.         /system/xbin/echo "2048" > $i/queue/nr_requests;
  88.     fi;
  89.  
  90.     if [ -e $i/queue/iosched/group_isolation ];
  91.     then
  92.         /system/xbin/echo "0" > $i/queue/iosched/group_isolation;
  93.     fi;
  94. done;
  95.  
  96. # =========
  97. # Optimize SQLite databases from apps
  98. # =========
  99. #
  100. for i in `busybox find /data -iname "*.db"`;
  101. do
  102.   /system/xbin/sqlite3 $i 'VACUUM;';
  103.   /system/xbin/sqlite3 $i 'REINDEX;';
  104. done;
  105.  
  106. if [ -d "/dbdata" ]; then
  107.     for i in `busybox find /dbdata -iname "*.db"`;
  108.     do
  109.         /system/xbin/sqlite3 $i 'VACUUM;';
  110.         /system/xbin/sqlite3 $i 'REINDEX;';
  111.     done;
  112. fi;
  113.  
  114. if [ -d "/datadata" ]; then
  115.     for i in `busybox find /datadata -iname "*.db"`;
  116.     do
  117.         /system/xbin/sqlite3 $i 'VACUUM;';
  118.         /system/xbin/sqlite3 $i 'REINDEX;';
  119.     done;
  120. fi;
  121.  
  122. if [ -d "/sdcard" ]; then
  123.     for i in `busybox find /sdcard -iname "*.db"`;
  124.     do
  125.         /system/xbin/sqlite3 $i 'VACUUM;';
  126.         /system/xbin/sqlite3 $i 'REINDEX;';
  127.     done;
  128. fi;
  129.  
  130. # =========
  131. # TWEAKS: for TCP read/write
  132. # =========
  133. /system/xbin/echo "0" > /proc/sys/net/ipv4/tcp_timestamps;
  134. /system/xbin/echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse;
  135. /system/xbin/echo "1" > /proc/sys/net/ipv4/tcp_sack;
  136. /system/xbin/echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle;
  137. /system/xbin/echo "1" > /proc/sys/net/ipv4/tcp_window_scaling;
  138. /system/xbin/echo "5" > /proc/sys/net/ipv4/tcp_keepalive_probes;
  139. /system/xbin/echo "30" > /proc/sys/net/ipv4/tcp_keepalive_intvl;
  140. /system/xbin/echo "30" > /proc/sys/net/ipv4/tcp_fin_timeout;
  141. /system/xbin/echo "404480" > /proc/sys/net/core/wmem_max;
  142. /system/xbin/echo "404480" > /proc/sys/net/core/rmem_max;
  143. /system/xbin/echo "256960" > /proc/sys/net/core/rmem_default;
  144. /system/xbin/echo "256960" > /proc/sys/net/core/wmem_default;
  145. /system/xbin/echo "4096 16384 404480" > /proc/sys/net/ipv4/tcp_wmem;
  146. /system/xbin/echo "4096 87380 404480" > /proc/sys/net/ipv4/tcp_rmem;
  147. setprop net.tcp.buffersize.default 4096,87380,404480,4096,16384,404480;
  148. setprop net.tcp.buffersize.wifi 4096,87380,404480,4096,16384,404480;
  149. setprop net.tcp.buffersize.umts 4096,87380,404480,4096,16384,404480;
  150.  
  151. # =========
  152. # TWEAKS: optimized for 3G/Edge speed
  153. # =========
  154. setprop ro.ril.hsxpa 2;
  155. setprop ro.ril.gprsclass 12;
  156. setprop ro.ril.hep 1;
  157. setprop ro.ril.enable.dtm 1;
  158. setprop ro.ril.hsdpa.category 8;
  159. setprop ro.ril.enable.a53 1;
  160. setprop ro.ril.enable.3g.prefix 1;
  161. setprop ro.ril.htcmaskw1.bitmask 4294967295;
  162. setprop ro.ril.htcmaskw1 14449;
  163. setprop ro.ril.hsupa.category 5;
  164.  
  165. # =========
  166. # TWEAKS
  167. # =========
  168. setprop ro.telephony.call_ring.delay 1000;
  169. setprop wifi.supplicant_scan_interval 180;
  170. setprop windowsmgr.max_events_per_sec 60;
  171. setprop ro.media.dec.jpeg.memcap 20000000;
  172. setprop ro.media.enc.jpeg.quality 95,85,75;
  173. #setprop dalvik.vm.startheapsize 12m;
  174. #setprop dalvik.vm.heapsize 32m;
  175. #setprop debug.sf.hw 1;
  176. /system/xbin/echo "8" > /proc/sys/vm/page-cluster;
  177. /system/xbin/echo "1" /proc/sys/kernel/sched_compat_yield;
  178. /system/xbin/echo "0" /proc/sys/kernel/sched_child_runs_first;
  179. /system/xbin/echo "256000" /proc/sys/kernel/sched_shares_ratelimit;
  180. /system/xbin/echo "64000" > /proc/sys/kernel/msgmni;
  181. /system/xbin/echo "64000" > /proc/sys/kernel/msgmax;
  182. /system/xbin/echo "10" > /proc/sys/fs/lease-break-time;
  183. /system/xbin/echo "500 512000 64 2048" > /proc/sys/kernel/sem;
  184. /system/xbin/echo "5000" > /proc/sys/kernel/threads-max;
  185. /system/xbin/echo "0" > /proc/sys/vm/oom_kill_allocating_task;
  186. /system/xbin/echo "0" > /proc/sys/vm/panic_on_oom;
  187.  
  188. # =========
  189. # Battery-TWEAKS
  190. # =========
  191. mount -t debugfs none /sys/kernel/debug;
  192. /system/xbin/echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features;
  193. /system/xbin/echo "NO_NORMALIZED_SLEEPERS" > /sys/kernel/debug/sched_features;
  194. umount /sys/kernel/debug;
  195.  
  196. # =========
  197. # MEMORY-TWEAKS
  198. # =========
  199. /system/xbin/echo "50" > /proc/sys/vm/swappiness;
  200. /system/xbin/echo "50" > /proc/sys/vm/vfs_cache_pressure;
  201. /system/xbin/echo "4096" > /proc/sys/vm/min_free_kbytes;
  202. /system/xbin/echo "500" > /proc/sys/vm/dirty_expire_centisecs;
  203. /system/xbin/echo "3000" > /proc/sys/vm/dirty_writeback_centisecs;
  204. /system/xbin/echo "22" > /proc/sys/vm/dirty_ratio;
  205. /system/xbin/echo "4" > /proc/sys/vm/dirty_background_ratio;
  206. /system/xbin/echo "3" > /proc/sys/vm/drop_caches;
  207. /system/xbin/echo "1" > /proc/sys/vm/overcommit_memory;
  208. /system/xbin/echo "8" > /proc/sys/vm/min_free_order_shift;
  209. #/system/xbin/echo "0,1,2,4,6,15" > /sys/module/lowmemorykiller/parameters/adj;
  210. /system/xbin/echo "0" > /sys/module/lowmemorykiller/parameters/debug_level;
  211. /system/xbin/echo "64" > /sys/module/lowmemorykiller/parameters/cost;
  212. # Define the memory thresholds at which the above process classes will
  213. # be killed. These numbers are in pages (4k) -> (1 MB * 1024) / 4 = 256
  214. FOREGROUND_APP_MEM=1536;
  215. VISIBLE_APP_MEM=2048;
  216. SECONDARY_SERVER_MEM=4096;
  217. BACKUP_APP_MEM=4096;
  218. HOME_APP_MEM=4096;
  219. HIDDEN_APP_MEM=5120;
  220. CONTENT_PROVIDER_MEM=15360;
  221. EMPTY_APP_MEM=23040;
  222. #/system/xbin/echo "$FOREGROUND_APP_MEM,$VISIBLE_APP_MEM,$SECONDARY_SERVER_MEM,$HIDDEN_APP_MEM,$CONTENT_PROVIDER_MEM,$EMPTY_APP_MEM" > /sys/module/lowmemorykiller/parameters/minfree;
  223.  
  224. # =========
  225. # Firewall-TWEAKS
  226. # =========
  227.  
  228. #ping/icmp protection
  229. /system/xbin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts;
  230. /system/xbin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all;
  231. /system/xbin/echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses;
  232.  
  233. if [ -e /proc/sys/net/ipv6/icmp_echo_ignore_broadcasts ];
  234. then
  235.     /system/xbin/echo "1" > /proc/sys/net/ipv6/icmp_echo_ignore_broadcasts;
  236. fi
  237.  
  238. if [ -e /proc/sys/net/ipv6/icmp_echo_ignore_all ];
  239. then
  240.     /system/xbin/echo "1" > /proc/sys/net/ipv6/icmp_echo_ignore_all;
  241. fi
  242.  
  243. if [ -e /proc/sys/net/ipv6/icmp_ignore_bogus_error_responses ];
  244. then
  245.     /system/xbin/echo "1" > /proc/sys/net/ipv6/icmp_ignore_bogus_error_responses;
  246. fi
  247.  
  248. #syn protection
  249. /system/xbin/echo "2" > /proc/sys/net/ipv4/tcp_synack_retries;
  250.  
  251. if [ -e /proc/sys/net/ipv6/tcp_synack_retries ];
  252. then
  253.     /system/xbin/echo "2" > /proc/sys/net/ipv6/tcp_synack_retries;
  254. fi
  255.  
  256. if [ -e /proc/sys/net/ipv6/tcp_syncookies ];
  257. then
  258.     /system/xbin/echo "0" > /proc/sys/net/ipv6/tcp_syncookies;
  259. fi
  260.  
  261. if [ -e /proc/sys/net/ipv4/tcp_syncookies ];
  262. then
  263.     /system/xbin/echo "1" > /proc/sys/net/ipv4/tcp_syncookies;
  264. fi
  265.  
  266. #drop spoof, redirects, etc
  267. /system/xbin/echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter;
  268. /system/xbin/echo "1" > /proc/sys/net/ipv4/conf/default/rp_filter;
  269. /system/xbin/echo "0" > /proc/sys/net/ipv4/conf/all/send_redirects;
  270. /system/xbin/echo "0" > /proc/sys/net/ipv4/conf/default/send_redirects;
  271. /system/xbin/echo "0" > /proc/sys/net/ipv4/conf/default/accept_redirects;
  272. /system/xbin/echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route;
  273. /system/xbin/echo "0" > /proc/sys/net/ipv4/conf/default/accept_source_route;
  274.  
  275. if [ -e /proc/sys/net/ipv6/conf/all/rp_filter ];
  276. then
  277.     /system/xbin/echo "1" > /proc/sys/net/ipv6/conf/all/rp_filter;
  278. fi
  279.  
  280. if [ -e /proc/sys/net/ipv6/conf/default/rp_filter ];
  281. then
  282.     /system/xbin/echo "1" > /proc/sys/net/ipv6/conf/default/rp_filter;
  283. fi
  284.  
  285. if [ -e /proc/sys/net/ipv6/conf/all/send_redirects ];
  286. then
  287.     /system/xbin/echo "0" > /proc/sys/net/ipv6/conf/all/send_redirects;
  288. fi
  289.  
  290. if [ -e /proc/sys/net/ipv6/conf/default/send_redirects ];
  291. then
  292.     /system/xbin/echo "0" > /proc/sys/net/ipv6/conf/default/send_redirects;
  293. fi
  294.  
  295. if [ -e /proc/sys/net/ipv6/conf/default/accept_redirects ];
  296. then
  297.     /system/xbin/echo "0" > /proc/sys/net/ipv6/conf/default/accept_redirects;
  298. fi
  299.  
  300. if [ -e /proc/sys/net/ipv6/conf/all/accept_source_route ];
  301. then
  302.     /system/xbin/echo "0" > /proc/sys/net/ipv6/conf/all/accept_source_route;
  303. fi
  304.  
  305. if [ -e /proc/sys/net/ipv6/conf/default/accept_source_route ];
  306. then
  307.     /system/xbin/echo "0" > /proc/sys/net/ipv6/conf/default/accept_source_route;
  308. fi
  309.  
  310. # =========
  311. # CleanUp
  312. # =========
  313.  
  314. #drop caches to free some memory
  315. sync;
  316. /system/xbin/echo "3" > /proc/sys/vm/drop_caches;
  317. sleep 1;
  318. /system/xbin/echo "1" > /proc/sys/vm/drop_caches;
  319.  
  320.  
  321. log -p i -t Tweak_Lite_v1 "*** BOOT tweaks ***: applied miscellaneous performance tweaks";
RAW Paste Data