[Android Software/Hacking General [Developers Only]] pikachu01:
ATTENTION: Only the main CWM and screenstate_scaling addon is compatible with ICS for now. LMK only works half way and shouldn't be used until I can find out if there's a method to automate the services.jar (as used by Supercharger to lock down LMK settings.

ATTENTION: 3G addon canot be used for CM7/MIUI at the moment!

ATTENTION: Addons are at the second post!

ATTENTION: 40MB has a very unaggressive LMK that will face lags at the end of the day but have higher degree of multitasking. You were warned :)

ATTENTION: If you're on Fugumod build 1922, which came out Nov. 3, meaning also on CM nightly 168 (and Neo 18 just recently) or any latest CM7 that has the latest didle code integrated into it, don't flash the screenstate_scaling addon! I've troubleshoot it with lippol94 and I found a bug in the latest didle code. I've explained it in the post here: LINK

ATTENTION: Mount /system before flashing! The CWM zip doesn't mount it for you automatically!!! This is to enable all phones (almost all?) to use this script. Go to "Mounts and Storage" in CWM to do this.

News

Updated ThunderBolt! to v2.6.1 with fixes to the main CWM updater script as well as moved S98bolt_siyah to bolt_scripts. Move it to init.d if you want to use ThunderBolt!'s hotplug/cpuidle/brightness settings for SGSII kernels.

Introduction

ThunderBolt! is a script package by me, pikachu01 that combines a few notable tweaks shamelessly modified to the max as well as hacks and scripts that I came up on my own(and added tonnes of things over the months of development and testing). Without further delay, please read the rest of the OP :)

Benefits

Better performance, better battery life through Linux kernel tweaks catered for Android OS and flash memory.

Better battery life and performance through usage of screenstate_scaling whereby it switches governors/thresholds/VM depending on your screen state.

Better performance and battery life for database writes as fsync is not utilized anymore.

Better network throughput from TCP tweaks and 3G tweaks

Less RAM usage through zipalign. I found that market apps like Viber and PlantsVsZombies aren't zipaligned. Oh and Swype too. Surprised? Me too.

Reduced /dbdata, /data, /sdcard usage of *.db files and faster database access through defragmentization of sqlite db files (a lot of apps use Database to store data like Swype dictionaries, Game saves etc)

Faster disk access through remount script (noatime, disable barrier etc)

Less lags through Quasi-charger, with mutltasking (e.g. NFS shift + Opera mobile with 5 tabs fully opened and no lags)

Minimum Requirements

Android Gingerbread 2.3.x

Note: Only the main CWM is ICS compatible. The LMK and screenstate_scaling might work on certain ICS ROMs. Try them out first. Nandroid beforehand!

At least 2MB free on /system (Delete unused ringtones or useless apps like Aldiko/Allshare etc).

Root

Kernel that supports init.d

Ext4 lagfix if you want to use the remount script

Addons

The 3G CWM is an addon that in most cases improve your mobile wireless speed.

The libsqlite CWM is an addon that removes the need to fsync before a database write is done. It'll improve database write speeds (where apps like SMS, contacts etc use databases)

The bin files CWM is an addon that uses Fugutweaks + system_server from Honeycomb. Some say that it improves response rates.

The LMK addon strives to maintain an effective LowMemoryKiller so that you have a small degree of multitasking coupled with a huge performance boost and a phone that lasts for days without needing a reboot to "clear off the memory or something". Split the LMK downloads to two with "Talon" version used for TalonDev kernel and "Others" version used for kernels that are not TalonDev. TalonMTD is not TalonDev btw, and "Others" version should be used instead. The higher the LMK value, the less multitasking capability you get. You'll get more performance for it though.

The screenstate_scaling addon will perform VM scaling and ondemand threshold scaling to get the best of battery life and performance. Not for CM7 kernels that have didle (that includes the stock kernel from night 168 onwards).

The graphics addon purpotedly increases graphics acceleration through some prop tweaks. There might be some devices that won't work well with these tweaks, hence I'm making it an addon. Try it and see if it increases frame rate or introduces instabilities.

Touchscreen tweaks are only for i9000. I included it by default though. It'll just be skipped in other devices. No issues here.

Included bolt_siyah script that tweaks SGSII related tunables (Dual core hotplugging settings, brightness related etc). Other phones will just skip this.

Known Issues

If you're using a custom MP3/Wav file as a ringtone, flashing ThunderBolt! might erase that setting causing your ringtone to be silent. Be sure to restore the ringtone again.

Barriers are turned off in /data. Corruption can happen but risks are minimal if you still have journaling.

Libsqlite safety_level is tuned to "1" from "3". There is risk of corruption here. Revert the libsqlite*.so files from the restore pack if you face corruption This is due to no fsync is done before databases are committed into disk hence it'll be faster but at the risk of corruption i.e. Launcher widgets going missing or SMS messages going missing etc.

sqlite_optimize script will produce errors like "malformed database" or "unknown collation sequence". It's normal, it means that these databases are not sqlite compatible, hence erroring out (skipped).

You may sometimes lose access to busybox. Install busybox installer (stericson's) from the market and install 1.19.3 to /xbin.

Bootup (even to the point where you can see the launcher)may be a little slow as zipalign takes some time.

remount script has to be launched using script manager

Remount script is only for i9000 Samsung, i9000 CM7/MIUI and i9001 + a few others(check /sdcard/bolt_scripts)

CWM zip is only for devices that has /system as its mount points. Remember to mount it in CWM.

The LMK/OOM is on the aggressive side. Some apps that you've hidden behind other visible processes SHOULD be killed to make way for bigger apps. This is to ensure your Angry Birds or Fruit Ninja doesn't LAG LIKE HELL after some time.

Instructions

Copy the CWM zip and all the addons you need to your internal sdcard

Mount /system in CWM (IMPORTANT!) (When mounted, it will show "unmount /system" for example. This means that an unmounted partition will show a "mount /system" for the /system partition)

Install using CWM all the CWM zips without needing a reboot in between

Wait for bootup

Open up Script Manager and launch /etc/bolt_scripts/remount[device] (e.g. remounti9000) as Root (The skull icon) and as Boot (The wheel icon).

Open up Script Manager and launch /etc/bolt_scripts/sqlite_optimize as Root (The skull icon). This script can be used arbitrarily at anytime that you want. Don't load it as boot or copy it to init.d though, it'll significantly slow down your boot up as the script is a very long running script.

Open up Script Manager and launch /etc/bolt_scripts/s70darky_zipalign as Root (The skull icon). This script can be used arbitrarily at anytime that you want. You can copy it to init.d and setting its permission to rwx-rwx-rwx. I moved it to bolt_scripts so that first boot for some people won't be slowed down.

????

PROFIT

Note: The remount script is launched using Script Manager as any ROM lagfix will remount the partitions again later after init.d scripts finished launching hence reverting the mounts to stock lagfix mounts. This is true for MIUI/CM7, Voodoo and other lagfixes where partitions will be remounted to relatime just before Android OS appears, thus nullifying the init.d remount.The script then has to be launched only after the Android OS has launched.

Note: sqlite_optimize can be executed at anytime. i.e. once a week to optimize your *.db files. It's usually a 30secs - 2minutes process. Ignore the "malformed database" and "No collation found" errors.

Reverting/Undoing ThunderBolt!

To revert ThunderBolt!, download the appropriate zip packages of your device. Sorry, only CM7/MIUI/i9000 for now. Let me know of your device and I can probably make a restore package for you. All other devices other than CM7/MIUI/i9000, you're on your own if you need to restore. Hence, be sure to have a nandroid backup handy.

Go to CWM, mount /system. Install the restore CWM package.

Repackaging

Repackaging ThunderBolt! into custom ROMs is allowable as long as it is included as a prominent feature of the ROM as well as proper credits are included.

Please reply into the thread if you would like to include it as its just a nice thing to do :)

You are free to modify the contents of the scripts, but please make it known that you've modified it and also briefly include the modifications you've done to the list of features

How to find out if it works

Use File Expert/ Root Explorer, and navigate here:

/system/etc/init.d/

You will find at least these files inside (from the main ThunderBolt! package):

S98system_tweak
S98CFS

Now, using Terminal Emulator, do this:

To enter superuser mode:

su

Then:

sysctl -a | grep vm

You will get values like this:

dirty_ratio = 80
dirty_background_ratio = 40
vfs_cache_pressure = 10

If you use the screenstate_scaling addon and then use ADB, and when the screen is off, you will get:

dirty_ratio = 90
dirty_background_ratio = 75
vfs_cache_pressure = 1

Next, do this in Terminal Emulator to check for the installed the LMK addon if it works correctly:

getprop | grep ADJ

You will get:

[ro.FOREGROUND_APP_ADJ]: [0]
[ro.VISIBLE_APP_ADJ]: [1]
[ro.PERCEPTIBLE_APP_ADJ]: [2]
[ro.HEAVY_WEIGHT_APP_ADJ]: [4]
[ro.SECONDARY_SERVER_ADJ]: [5]
[ro.BACKUP_APP_ADJ]: [6]
[ro.HOME_APP_ADJ]: [3]
[ro.HIDDEN_APP_MIN_ADJ]: [7]
[ro.EMPTY_APP_ADJ]: [15]

Credits

Zacharias.maladroit

XDA's devs for some reference of some tweaks in Zach's scripts

zeppelinrox Supercharger scripts

nikademus - Fugutweaks

ForeverSupra - Fugutweaks ICS

ChainFire - Touchscreen Tweaks

Sources for libsqlite

https://github.com/CyanogenMod/android_external_sqlite

File: sqlite3.c (sqlite v3.7.2)

Modified:

-73097: aNew->safety_level = 3;
+73097: aNew->safety_level = 1;

-105161: db->aDb[0].safety_level = 3;
+105161: db->aDb[0].safety_level = 1;

Currently working devices

Samsung Galaxy S i9000

Samsung Galaxy S II i9100

Samsung Captivate

Samsung Vibrant

Samsung Galaxy S 4G

Samsung Galaxy S Plus i9001

Samsung Galaxy Note

Samsung Infuse 4G

Samsung Galaxy Tab

Samsung Galaxy S Plus i9001

Samsung Galaxy SL i9003

Samsung Galaxy SII AT&T i777

Samsung Galaxy Nexus

----------------------------------------------------------------------------------------------------------------------------

BUY me a cup of coffee if you enjoy my work. It'll motivate me to work harder and faster :)