2009年8月13日 星期四

sqlite3: useful examples

Android has sqlite3 as its database engine. Some useful examples on using sqlite3 are:

1. To open the system settings database:
sqlite3 /data/data/com.android.providers.settings/databases/settings.db

2. To check out tables of current database:
sqlite>.tables

3. To dump a table:
sqlite> .dump secure
BEGIN TRANSACTION;
CREATE TABLE secure (_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT UNIQUE ON CONFLICT REPLACE,value TEXT);
INSERT INTO "secure" VALUES(1,'bluetooth_on','0');
INSERT INTO "secure" VALUES(2,'data_roaming','0');
INSERT INTO "secure" VALUES(3,'install_non_market_apps','0');
INSERT INTO "secure" VALUES(4,'location_providers_allowed','network');
INSERT INTO "secure" VALUES(5,'device_provisioned','1');
INSERT INTO "secure" VALUES(6,'network_preference','1');
INSERT INTO "secure" VALUES(7,'usb_mass_storage_enabled','1');
INSERT INTO "secure" VALUES(9,'wifi_networks_available_notification_on','1');
INSERT INTO "secure" VALUES(10,'mock_location','1');
INSERT INTO "secure" VALUES(11,'enabled_input_methods','com.android.inputmethod.latin/.LatinIME');
INSERT INTO "secure" VALUES(17,'wifi_on','1');
INSERT INTO "secure" VALUES(20,'default_input_method','com.android.inputmethod.latin/.LatinIME');
INSERT INTO "secure" VALUES(21,'adb_enabled','1');
CREATE INDEX secureIndex1 ON secure (name);
COMMIT;
sqlite>

4. To insert an entry in the 'system' table
sqlite> insert into system (name, value) values ('an_example','7');

5. To update an entry in the 'system' table
sqlite> update system set value='8' where name='an_example';

6. To delete an entry in the 'system' table
sqlite> delete from system where name='an_example';

Reference:
http://www.shokhirev.com/nikolai/abc/sql/sql.html

2009年8月4日 星期二

Android build name decoding

JBQ at Google provides how to interpret Android build names at http://groups.google.com/group/android-platform/browse_thread/thread/3670ed63a7d9e3ab?hl=en.

Also mentioned in the above URL are status of branches and who should use what.

2009年7月29日 星期三

Useful tool: unyaffs

To get proprietary files from ADP1 factory image, unyaffs is useful. http://code.google.com/p/unyaffs/

I downloaded both unyaffs.c and unyaffs.h. And:
pfeng@fengdroid:~/android/tools/unyaffs$ gcc -O2 -o unyaffs unyaffs.c
pfeng@fengdroid:~/android/tools/unyaffs$ strip unyaffs
pfeng@fengdroid:~/android/tools/unyaffs$ ls
unyaffs unyaffs.c unyaffs.h


Steps to get all the files from the factory image, using 1.5 as an example:
1. Download the ADP1 factory image files from HTC: http://www.htc.com/www/support/android/adp.html
2. pfeng@fengdroid:~/android/htc$ unzip signed-dream_devphone_userdebug-img-148830.zip
Archive: signed-dream_devphone_userdebug-img-148830.zip
inflating: boot.img
inflating: recovery.img
inflating: system.img
inflating: userdata.img
inflating: android-info.txt
3. pfeng@fengdroid:~/android/htc/system$ sudo ~/bin/unyaffs ../system.img

2009年7月21日 星期二

Installing Android NDK on Ubuntu 8.04

1. Get NDK from here: http://developer.android.com/sdk/ndk/1.5_r1/index.html

2. Follow the instruction on setting it up.

3. On my Ubuntu PC, it has the following problem:

pfeng@pfeng-uatu:~/android-ndk$ ./build/host-setup.sh
./build/host-setup.sh: 23: source: not found
Detecting host toolchain.

./build/host-setup.sh: 57: force_32bit_binaries: not found
./build/host-setup.sh: 58: setup_toolchain: not found
./build/host-setup.sh: 60: cannot create : Directory nonexistent
Can't create directory for host config file: out/host

4. It appears that a bash command: source is used. However, on Ubuntu, due to performance reason, /bin/sh is now linked to /bin/dash, not /bin/bash, fro details, see https://wiki.ubuntu.com/DashAsBinSh.

5. So I have to modify ./build/host-setup.sh, from #!/bin/sh to #!/bin/bash. It works like a charm!

2009年4月16日 星期四

Android ADP1 Official Original Images from HTC

Good news to people who have lost the original factory images! HTC has made the factory images available for download! And instructions to do so. Here is the link:

http://www.htc.com/www/support/android/adp.html

Two methods are listed. I myself have to go with fastboot way, as I have lost totally everything, i.e. no original factory bootloader.

Recovery


It seems like recovery mode would always flash the /sdcard/update.zip file. Sample ommand line to transfer file from PC to G1 are:
$adb push a-pc-file /sdcard/update.zip
$adb shell sync

The sync line is important as G1 runs Linux and sync is necessary to make sure everything is written to the sdcard, including file system buffers and page cache.

To enter recovery mode:
Reboot G1 with HOME button pressed. It should display a "!" icon.

To enable log output:
Press ALT+l (lower case L) to enable log output. Keyboard needs to be opened, of course.

To install the update:
Press ALT+s to install the update.

To write the image:
Press HOME and BACK keys together to write the image, update the firmware, and automatically reboot.

Flash New Images

To be safe, erase userdata and cache by the following:
$fastboot erase userdata
$fastboot erase cache

Alternatively, adding a -w option can effectively erase those areas too.
$fastboot update .zip [-w]

Useful Links

Google discussion group http://groups.google.com/group/Android-DevPhone-Updating