[HOWTO] Change system settings via updater-script

481 posts
Thanks Meter: 613
By joedeuce, Senior Member on 27th April 2012, 01:01 AM
Post Reply Email Thread
I'm not responsible for any broken devices, promises, or relationships!

While working on a theme for an AOKP based ROM, I ran into some problems setting theme colors for a couple items - most notably battery bar color and status bar clock color. For the purpose of keeping things simple, these will be the two settings focused on.

To begin, you first may wanna take a little crash course in sqlite use in Android:
http://davanum.wordpress.com/2007/12...te3-databases/ (thanks to Davanum Srinivas for sqlite help)

Now, let's open our settings.db and have a look around:
(Items in blue are for you to type!)
[email protected]:/ # sqlite3 /data/data/com.android.providers.settings/databases/settings.db
SQLite version 3.7.4
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
Now, at the sqlite prompt:
sqlite> select * from system;
Here we see all the settings contained in the system table of the settings database, but we are only interested in the two shown above (for now )

To save database space, colors are stored in integer format (google has plenty of info on this), and by converting the -13388315 from above to hex, we see the good ole' ics blue hex code (#FF33B5E5).

But we want ORANGE (#FFFA9600 to be exact) so we are gonna use -354816 as our integer.

Back at the sqlite prompt:
sqlite> insert into system values(null, 'statusbar_clock_color', '-354816');
insert into system values(null, 'statusbar_clock_color', '-354816');
Now if we reboot the phone, we will see our new clock color.

We can change these settings after flashing a ROM/mod by using the run_program() function in the updater-script as follows:
run_program("/system/xbin/sqlite3", "/data/data/com.android.providers.settings/databases/settings.db", "insert into system values(null, 'statusbar_clock_color','-354816');");
run_program("/system/xbin/sqlite3", "/data/data/com.android.providers.settings/databases/settings.db", "insert into system values(null, 'statusbar_battery_bar_color','-354816');");
Obviously /system and /data must both be mounted prior to the sqlite commands being issued.

I'll try to respond to any questions, but I'm not always the best at explaining things.

I would love to know of a better way to do this, so if you can help the community, don't hold back!

Thanks to all my brothers/sisters of The Android Collective for their hard work, dedication, and loyalty.
The Following 17 Users Say Thank You to joedeuce For This Useful Post: [ View ] Gift joedeuce Ad-Free
Post Reply Subscribe to Thread

aokp, collective, settings, sqlite

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes